提交 d65b186f 编写于 作者: L Levi Armstrong 提交者: GitHub

Get Cxx Flags from flags.make file (#72)

上级 7b631f50
......@@ -115,15 +115,13 @@ void ROSBuildConfiguration::sourceWorkspace()
ROSProject *prj = qobject_cast<ROSProject *>(target()->project());
QProcess process;
if (ROSUtils::sourceWorkspace(&process, prj->projectDirectory(), prj->distribution(), m_buildSystem))
{
Utils::Environment source_env = Utils::Environment(process.processEnvironment().toStringList());
source_env.set(QLatin1String("PWD"), prj->projectDirectory().toString());
QList<Utils::EnvironmentItem> diff = baseEnvironment().diff(source_env);
if (!diff.isEmpty())
setUserEnvironmentChanges(diff);
}
ROSUtils::WorkspaceInfo workspaceInfo = ROSUtils::getWorkspaceInfo(prj->projectDirectory(), m_buildSystem, prj->distribution());
Utils::Environment source_env(ROSUtils::getWorkspaceEnvironment(workspaceInfo).toStringList());
QList<Utils::EnvironmentItem> diff = baseEnvironment().diff(source_env);
if (!diff.isEmpty())
setUserEnvironmentChanges(diff);
}
NamedWidget *ROSBuildConfiguration::createConfigWidget()
......
......@@ -121,10 +121,12 @@ bool ROSCatkinMakeStep::init(QList<const BuildStep *> &earlierSteps)
}
// TODO: Need to get build data (build directory, environment, etc.) based on build System
ROSUtils::WorkspaceInfo workspaceInfo = ROSUtils::getWorkspaceInfo(bc->project()->projectDirectory(), bc->buildSystem(), bc->project()->distribution());
ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander());
pp->setWorkingDirectory(bc->project()->projectDirectory().toString());
Utils::Environment env(ROSUtils::getWorkspaceEnvironment(bc->project()->projectDirectory(), bc->project()->distribution(), bc->buildSystem()).toStringList());
Utils::Environment env(ROSUtils::getWorkspaceEnvironment(workspaceInfo).toStringList());
// Force output to english for the parsers. Do this here and not in the toolchain's
// addToEnvironment() to not screw up the users run environment.
env.set(QLatin1String("LC_ALL"), QLatin1String("C"));
......@@ -313,11 +315,12 @@ void ROSCatkinMakeStepWidget::updateDetails()
m_makeStep->m_makeArguments = m_ui->makeArgumentsLineEdit->text();
ROSBuildConfiguration *bc = m_makeStep->rosBuildConfiguration();
Utils::Environment env(ROSUtils::getWorkspaceEnvironment(bc->project()->projectDirectory(), bc->project()->distribution(), bc->buildSystem()).toStringList());
ROSUtils::WorkspaceInfo workspaceInfo = ROSUtils::getWorkspaceInfo(bc->project()->projectDirectory(), bc->buildSystem(), bc->project()->distribution());
Utils::Environment env(ROSUtils::getWorkspaceEnvironment(workspaceInfo).toStringList());
ProcessParameters param;
param.setMacroExpander(bc->macroExpander());
param.setWorkingDirectory(bc->buildDirectory().toString());
param.setWorkingDirectory(workspaceInfo.buildPath.toString());
param.setEnvironment(env);
param.setCommand(m_makeStep->makeCommand());
param.setArguments(m_makeStep->allArguments(bc->cmakeBuildType(), false));
......
......@@ -131,11 +131,12 @@ bool ROSCatkinToolsStep::init(QList<const BuildStep *> &earlierSteps)
// Set Catkin Tools Active Profile
ROSUtils::setCatkinToolsActiveProfile(bc->project()->projectDirectory(), activeProfile());
ROSUtils::WorkspaceInfo workspaceInfo = ROSUtils::getWorkspaceInfo(bc->project()->projectDirectory(), bc->buildSystem(), bc->project()->distribution());
ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander());
pp->setWorkingDirectory(ROSUtils::getWorkspaceBuildSpace(bc->project()->projectDirectory(), bc->buildSystem()).toString());
Utils::Environment env(ROSUtils::getWorkspaceEnvironment(bc->project()->projectDirectory(), bc->project()->distribution(), bc->buildSystem()).toStringList());
pp->setWorkingDirectory(workspaceInfo.buildPath.toString());
Utils::Environment env(ROSUtils::getWorkspaceEnvironment(workspaceInfo).toStringList());
qDebug() << env.toStringList();
// Force output to english for the parsers. Do this here and not in the toolchain's
// addToEnvironment() to not screw up the users run environment.
......@@ -377,11 +378,12 @@ void ROSCatkinToolsStepWidget::updateDetails()
m_makeStep->m_makeArguments = m_ui->makeArgumentsLineEdit->text();
ROSBuildConfiguration *bc = m_makeStep->rosBuildConfiguration();
Utils::Environment env(ROSUtils::getWorkspaceEnvironment(bc->project()->projectDirectory(), bc->project()->distribution(), bc->buildSystem()).toStringList());
ROSUtils::WorkspaceInfo workspaceInfo = ROSUtils::getWorkspaceInfo(bc->project()->projectDirectory(), bc->buildSystem(), bc->project()->distribution());
Utils::Environment env(ROSUtils::getWorkspaceEnvironment(workspaceInfo).toStringList());
ProcessParameters param;
param.setMacroExpander(bc->macroExpander());
param.setWorkingDirectory(bc->buildDirectory().toString());
param.setWorkingDirectory(workspaceInfo.buildPath.toString());
param.setEnvironment(env);
param.setCommand(m_makeStep->makeCommand());
param.setArguments(m_makeStep->allArguments(bc->cmakeBuildType(), false));
......
......@@ -199,7 +199,8 @@ void ROSProject::refreshCppCodeModel()
const Utils::FileName sysRoot = SysRootKitInformation::sysRoot(activeTarget()->kit());
// TODO: Need to run this in its own thread
m_wsPackageInfo = ROSUtils::getWorkspacePackageInfo(projectDirectory(), rosBuildConfiguration()->buildSystem(), &m_wsPackageInfo);
ROSUtils::WorkspaceInfo workspaceInfo = ROSUtils::getWorkspaceInfo(projectDirectory(), rosBuildConfiguration()->buildSystem(), distribution());
m_wsPackageInfo = ROSUtils::getWorkspacePackageInfo(workspaceInfo, &m_wsPackageInfo);
CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
......@@ -218,30 +219,32 @@ void ROSProject::refreshCppCodeModel()
QStringList workspaceFiles = m_workspaceWatcher->getWorkspaceFiles();
foreach(ROSUtils::PackageInfo package, m_wsPackageInfo)
{
CppTools::ProjectPartBuilder ppBuilder(pInfo);
ppBuilder.setDisplayName(package.name);
ppBuilder.setQtVersion(activeQtVersion);
QSet<QString> toolChainIncludes;
foreach (const HeaderPath &hp, toolChain->systemHeaderPaths(package.flags, sysRoot))
toolChainIncludes.insert(hp.path());
QStringList includePaths;
foreach (const QString &i, package.includes) {
if (!toolChainIncludes.contains(i))
includePaths.append(i);
}
ppBuilder.setIncludePaths(includePaths);
ppBuilder.setCxxFlags(package.flags);
QStringList packageFiles = workspaceFiles.filter(package.path + QDir::separator());
const QList<Id> languages = ppBuilder.createProjectPartsForFiles(packageFiles);
foreach (Id language, languages)
setProjectLanguage(language, true);
foreach(ROSUtils::PackageTargetInfo targetInfo, package.buildInfo.targets)
{
CppTools::ProjectPartBuilder ppBuilder(pInfo);
ppBuilder.setDisplayName(targetInfo.name);
ppBuilder.setQtVersion(activeQtVersion);
QSet<QString> toolChainIncludes;
foreach (const HeaderPath &hp, toolChain->systemHeaderPaths(targetInfo.flags, sysRoot))
toolChainIncludes.insert(hp.path());
QStringList includePaths;
foreach (const QString &i, targetInfo.includes) {
if (!toolChainIncludes.contains(i))
includePaths.append(i);
}
ppBuilder.setIncludePaths(includePaths);
ppBuilder.setCxxFlags(targetInfo.flags);
const QList<Id> languages = ppBuilder.createProjectPartsForFiles(packageFiles);
foreach (Id language, languages)
setProjectLanguage(language, true);
}
}
pInfo.finish();
m_codeModelFuture = modelManager->updateProjectInfo(pInfo);
......
......@@ -266,7 +266,9 @@ Core::GeneratedFiles ROSProjectWizard::generateFiles(const QWizard *w,
ROSUtils::ROSProjectFileContent projectFileContent;
projectFileContent.defaultBuildSystem = wizard->buildSystem();
projectFileContent.distribution = wizard->distribution();
projectFileContent.watchDirectories.append(QDir(ROSUtils::getWorkspaceSourceSpace(wizard->workspaceDirectory(), projectFileContent.defaultBuildSystem).toString()).dirName());
ROSUtils::WorkspaceInfo workspaceInfo = ROSUtils::getWorkspaceInfo(wizard->workspaceDirectory(), projectFileContent.defaultBuildSystem, wizard->distribution());
projectFileContent.watchDirectories.append(QDir(workspaceInfo.sourcePath.toString()).dirName());
Core::GeneratedFile generatedWorkspaceFile(workspaceFileName);
QString content;
......
此差异已折叠。
......@@ -24,10 +24,7 @@
#include <QProcess>
#include <QProcessEnvironment>
#include <QXmlStreamWriter>
namespace Utils {
class FileName;
} // namespace Utils
#include <utils/fileutils.h>
namespace ROSProjectManager {
namespace Internal {
......@@ -45,34 +42,69 @@ public:
BuildTypeMinSizeRel = 3
};
enum TargetType {
ExecutableType = 0,
StaticLibraryType = 1,
DynamicLibraryType = 2,
UtilityType = 3
};
/** @brief The FolderContent struct used to store file and folder information */
struct FolderContent {
QStringList files; /**< @brief Directory Files */
QStringList directories; /**< @brief Directory Subdirectories */
};
/** @brief Contains all relavent package information */
struct PackageInfo {
QString name; /**< @brief Package Name */
QString path; /**< @brief Package directory path */
QString filepath; /**< @brief Package package.xml filepath */
QStringList includes; /**< @brief Package include directories */
QStringList flags; /**< @brief Package cxx build flags */
QString cbpFile; /**< @brief Path to the CodeBlocks file */
/** @brief Contains relavent workspace information */
struct WorkspaceInfo {
Utils::FileName path;
Utils::FileName sourcePath;
Utils::FileName buildPath;
Utils::FileName develPath;
Utils::FileName installPath;
Utils::FileName logPath;
QString rosDistribution;
BuildSystem buildSystem;
};
struct PackageTargetInfo {
QString name; /**< @brief Target name */
TargetType type; /**< @brief Target type */
Utils::FileName flagsFile; /**< @brief Path to the Target's flags.cmake file */
QStringList includes; /**< @brief Target's include directories */
QStringList flags; /**< @brief Target's cxx build flags */
QStringList defines; /**< @brief Target's defines build flags */
};
typedef QList<PackageTargetInfo> PackageTargetInfoList;
/** @brief Contains a packages relavent build informations */
struct PackageBuildInfo {
Utils::FileName cbpFile; /**< @brief Path to the Package's CodeBlocks file */
PackageTargetInfoList targets; /**< @brief List of packages target's */
/**
* @brief Check if package exists.
* @brief Check if build information exists.
* @return True if exists, otherwise false.
*/
bool exists();
};
/** @brief Contains all relavent package information */
struct PackageInfo {
QString name; /**< @brief Package Name */
QString path; /**< @brief Package directory path */
Utils::FileName filepath; /**< @brief Package package.xml filepath */
PackageBuildInfo buildInfo; /**< @brief Package build information */
/**
* @brief Check if CodeBlocks file exists
* @brief Check if package exists.
* @return True if exists, otherwise false.
*/
bool cbpFileExists();
bool exists();
};
typedef QMap<QString, PackageBuildInfo> PackageBuildInfoMap;
typedef QMap<QString, PackageInfo> PackageInfoMap;
/** @brief Contains project file information */
......@@ -100,48 +132,36 @@ public:
/**
* @brief Source Workspace
* @param process QProcess to execute the ROS bash command
* @param workspaceDir Workspace directory
* @param rosDistribution ROS distribution
* @param buildSystem Workspace build system
* @param workspaceInfo Workspace information
* @return True if successful
*/
static bool sourceWorkspace(QProcess *process,
const Utils::FileName &workspaceDir,
const QString &rosDistribution,
const BuildSystem &buildSystem);
const WorkspaceInfo &workspaceInfo);
/**
* @brief Check whether the provided workspace has been initialized
* @param workspaceDir Workspace directory
* @param buildSystem Workspace build system
* @param workspaceInfo Workspace information
* @return True if workspace is initialized, otherwise false
*/
static bool isWorkspaceInitialized(const Utils::FileName &workspaceDir,
const BuildSystem &BuildSystem);
static bool isWorkspaceInitialized(const WorkspaceInfo &WorkspaceInfo);
/**
* @brief Initialize workspace
* @param process QProcess to execute the ROS bash command
* @param workspaceDir Workspace directory
* @param rosDistribution ROS Distribution
* @param buildSystem Workspace build system
* @param workspaceInfo Workspace information
* @return True if successfully executed, otherwise false
*/
static bool initializeWorkspace(QProcess *process,
const Utils::FileName &workspaceDir,
const QString &rosDistribution,
const BuildSystem &buildSystem);
const WorkspaceInfo &workspaceInfo);
/**
* @brief Build workspace
* @param process QProcess to execute the catkin_make
* @param workspaceDir Workspace Directory
* @param buildSystem Workspace build system
* @param workspaceInfo Workspace information
* @return True if successfully executed, otherwise false
*/
static bool buildWorkspace(QProcess *process,
const Utils::FileName &workspaceDir,
const ROSUtils::BuildSystem &buildSystem);
const WorkspaceInfo &workspaceInfo);
/**
* @brief Gets a list of installed ROS Distributions
......@@ -176,13 +196,21 @@ public:
QStringList &fileList);
/**
* @brief Get all of the workspace packages and its neccessary information.
* @brief Get relevant workspace information
* @param workspaceDir Path of the workspace
* @param buildSystem Workspace build system
* @return Workspace information
*/
static WorkspaceInfo getWorkspaceInfo(const Utils::FileName &workspaceDir,
const BuildSystem &buildSystem,
const QString &rosDistribution);
/**
* @brief Get all of the workspace packages and its neccessary information.
* @param workspaceInfo Workspace information
* @return QMap(Package Name, PackageInfo)
*/
static PackageInfoMap getWorkspacePackageInfo(const Utils::FileName &workspaceDir,
const BuildSystem &buildSystem,
static PackageInfoMap getWorkspacePackageInfo(const WorkspaceInfo &workspaceInfo,
const PackageInfoMap *cachedPackageInfo = NULL);
/**
......@@ -195,21 +223,10 @@ public:
/**
* @brief Get all of the ros packages within the provided workspace directory.
* @param workspaceDir Workspace directory path
* @param buildSystem Workspace build system
* @param workspaceInfo Workspace information
* @return QMap(Package Name, Path to package)
*/
static QMap<QString, QString> getWorkspacePackages(const Utils::FileName &workspaceDir,
const BuildSystem &buildSystem);
/**
* @brief Get all of the code block files within workspace build directory.
* @param workspaceDir Workspace directory path
* @param buildSystem Workspace build system
* @return QMap(CodeBlock File Name, CodeBlock File Path)
*/
static QMap<QString, QString> getWorkspaceCodeBlockFiles(const Utils::FileName &workspaceDir,
const BuildSystem &buildSystem);
static QMap<QString, QString> getWorkspacePackages(const WorkspaceInfo &workspaceInfo);
/**
* @brief Gets all launch files associated to a package
......@@ -306,43 +323,13 @@ public:
*/
static QString getCMakeBuildTypeArgument(ROSUtils::BuildType &buildType);
/**
* @brief Get workspace source directory path
* @param workspaceDir Workspace directory path
* @param buildSystem Build system
* @return Utils::FileName Path to source directory
*/
static Utils::FileName getWorkspaceSourceSpace(const Utils::FileName &workspaceDir,
const BuildSystem &buildSystem);
/**
* @brief Get workspace build directory path
* @param workspaceDir Workspace directory path
* @param buildSystem Build system
* @return Utils::FileName Path to build directory
*/
static Utils::FileName getWorkspaceBuildSpace(const Utils::FileName &workspaceDir,
const BuildSystem &buildSystem);
/**
* @brief Get workspace devel directory path
* @param workspaceDir Workspace directory path
* @param buildSystem Build system
* @return Utils::FileName Path to devel directory
*/
static Utils::FileName getWorkspaceDevelSpace(const Utils::FileName &workspaceDir,
const BuildSystem &buildSystem);
/**
* @brief Get workspace environment
* @param workspaceDir Workspace directory path
* @param workspaceInfo Workspace information
* @param rosDistribution ROS distribution (Hydro, Indigo, etc.)
* @param buildSystem Build system
* @return QProcessEnvironment
*/
static QProcessEnvironment getWorkspaceEnvironment(const Utils::FileName &workspaceDir,
const QString &rosDistribution,
const BuildSystem &buildSystem);
static QProcessEnvironment getWorkspaceEnvironment(const WorkspaceInfo &workspaceInfo);
private:
/**
......@@ -356,13 +343,11 @@ private:
/**
* @brief This will parse the CodeBlock file and get the build info (incudes, Cxx Flags, etc.)
* @todo Need to figure out how to Cxx Flags.
* @param workspaceDir Workspace directory path
* @param buildSystem Workspace build system
* @param workspaceInfo Workspace information
* @param package Package Info Objects
* @return True if successful, otherwise false.
*/
static bool getPackageBuildInfo(const Utils::FileName &workspaceDir,
const BuildSystem &buildSystem,
static bool getPackageBuildInfo(const WorkspaceInfo &workspaceInfo,
PackageInfo &package);
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册