mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-24 23:28:32 -05:00
GHS: Only print bsp and os directives if specified by user
-- standalone platforms will not build if bsp/os is specified in project file -- integrity platforms will always print these directives because they are required -- cleanup -os_dir setting allow customization of the actual setting because it is determined by tool-set customization files remove variable that was set but never used -- add message when using default values
This commit is contained in:
@@ -9,6 +9,9 @@ mark_as_advanced(GHS_OS_ROOT)
|
||||
set(GHS_OS_DIR "NOTFOUND" CACHE PATH "GHS platform OS directory")
|
||||
mark_as_advanced(GHS_OS_DIR)
|
||||
|
||||
set(GHS_OS_DIR_OPTION "-os_dir " CACHE STRING "GHS compiler os option")
|
||||
mark_as_advanced(GHS_OS_DIR)
|
||||
|
||||
#set GHS_OS_DIR if not set by user
|
||||
if ( NOT GHS_OS_DIR )
|
||||
if (EXISTS ${GHS_OS_ROOT})
|
||||
@@ -23,8 +26,11 @@ if ( NOT GHS_OS_DIR )
|
||||
endif ()
|
||||
|
||||
#filter based on platform name
|
||||
if (GHS_TARGET_PLATFORM STREQUAL "integrity")
|
||||
if (GHS_TARGET_PLATFORM MATCHES "integrity")
|
||||
list(FILTER GHS_CANDIDATE_OS_DIRS INCLUDE REGEX "int[0-9][0-9][0-9][0-9a-z].*")
|
||||
else() #fall-back for standalone
|
||||
unset(GHS_CANDIDATE_OS_DIRS)
|
||||
set(GHS_OS_DIR "IGNORE")
|
||||
endif ()
|
||||
|
||||
if (GHS_CANDIDATE_OS_DIRS)
|
||||
|
||||
@@ -20,7 +20,6 @@ const char* cmGlobalGhsMultiGenerator::DEFAULT_TOOLSET_ROOT = "C:/ghs";
|
||||
|
||||
cmGlobalGhsMultiGenerator::cmGlobalGhsMultiGenerator(cmake* cm)
|
||||
: cmGlobalGenerator(cm)
|
||||
, OSDirRelative(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -130,6 +129,8 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p,
|
||||
|
||||
const char* tgtPlatform = mf->GetDefinition("GHS_TARGET_PLATFORM");
|
||||
if (tgtPlatform == nullptr) {
|
||||
cmSystemTools::Message("Green Hills MULTI: GHS_TARGET_PLATFORM not "
|
||||
"specified; defaulting to \"integrity\"");
|
||||
tgtPlatform = "integrity";
|
||||
}
|
||||
|
||||
@@ -221,45 +222,62 @@ void cmGlobalGhsMultiGenerator::OpenBuildFileStream()
|
||||
this->Open(std::string(""), buildFilePath, &this->TargetFolderBuildStreams);
|
||||
OpenBuildFileStream(GetBuildFileStream());
|
||||
|
||||
char const* osDir =
|
||||
this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR");
|
||||
if (NULL == osDir) {
|
||||
osDir = "";
|
||||
cmSystemTools::Error("GHS_OS_DIR cache variable must be set");
|
||||
} else {
|
||||
this->GetCMakeInstance()->MarkCliAsUsed("GHS_OS_DIR");
|
||||
}
|
||||
std::string fOSDir(this->trimQuotes(osDir));
|
||||
std::replace(fOSDir.begin(), fOSDir.end(), '\\', '/');
|
||||
if (!fOSDir.empty() && ('c' == fOSDir[0] || 'C' == fOSDir[0])) {
|
||||
this->OSDirRelative = false;
|
||||
} else {
|
||||
this->OSDirRelative = true;
|
||||
this->WriteMacros();
|
||||
this->WriteHighLevelDirectives();
|
||||
GhsMultiGpj::WriteGpjTag(GhsMultiGpj::PROJECT, this->GetBuildFileStream());
|
||||
this->WriteDisclaimer(this->GetBuildFileStream());
|
||||
*this->GetBuildFileStream() << "# Top Level Project File" << std::endl;
|
||||
|
||||
// Specify BSP option if supplied by user
|
||||
// -- not all platforms require this entry in the project file
|
||||
// integrity platforms require this field; use default if needed
|
||||
std::string platform;
|
||||
if (const char* p =
|
||||
this->GetCMakeInstance()->GetCacheDefinition("GHS_TARGET_PLATFORM")) {
|
||||
platform = p;
|
||||
}
|
||||
|
||||
std::string bspName;
|
||||
char const* bspCache =
|
||||
this->GetCMakeInstance()->GetCacheDefinition("GHS_BSP_NAME");
|
||||
if (bspCache) {
|
||||
if (char const* bspCache =
|
||||
this->GetCMakeInstance()->GetCacheDefinition("GHS_BSP_NAME")) {
|
||||
bspName = bspCache;
|
||||
this->GetCMakeInstance()->MarkCliAsUsed("GHS_BSP_NAME");
|
||||
} else {
|
||||
bspName = "IGNORE";
|
||||
}
|
||||
if (bspName.empty() || bspName.compare("IGNORE") == 0) {
|
||||
|
||||
if (platform.find("integrity") != std::string::npos &&
|
||||
cmSystemTools::IsOff(bspName.c_str())) {
|
||||
const char* a =
|
||||
this->GetCMakeInstance()->GetCacheDefinition("CMAKE_GENERATOR_PLATFORM");
|
||||
bspName = "sim";
|
||||
bspName += (a ? a : "");
|
||||
}
|
||||
|
||||
this->WriteMacros();
|
||||
this->WriteHighLevelDirectives();
|
||||
if (!cmSystemTools::IsOff(bspName.c_str())) {
|
||||
*this->GetBuildFileStream() << " -bsp " << bspName << std::endl;
|
||||
}
|
||||
|
||||
GhsMultiGpj::WriteGpjTag(GhsMultiGpj::PROJECT, this->GetBuildFileStream());
|
||||
this->WriteDisclaimer(this->GetBuildFileStream());
|
||||
*this->GetBuildFileStream() << "# Top Level Project File" << std::endl;
|
||||
*this->GetBuildFileStream() << " -bsp " << bspName << std::endl;
|
||||
// Specify OS DIR if supplied by user
|
||||
// -- not all platforms require this entry in the project file
|
||||
std::string osDir;
|
||||
std::string osDirOption;
|
||||
if (char const* osDirCache =
|
||||
this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR")) {
|
||||
osDir = osDirCache;
|
||||
}
|
||||
|
||||
this->WriteCompilerOptions(fOSDir);
|
||||
if (char const* osDirOptionCache =
|
||||
this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR_OPTION")) {
|
||||
osDirOption = osDirOptionCache;
|
||||
}
|
||||
|
||||
if (!cmSystemTools::IsOff(osDir.c_str()) ||
|
||||
platform.find("integrity") != std::string::npos) {
|
||||
std::replace(osDir.begin(), osDir.end(), '\\', '/');
|
||||
*this->GetBuildFileStream()
|
||||
<< " " << osDirOption << "\"" << osDir << "\"" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void cmGlobalGhsMultiGenerator::CloseBuildFileStream(
|
||||
@@ -368,12 +386,6 @@ void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives()
|
||||
}
|
||||
}
|
||||
|
||||
void cmGlobalGhsMultiGenerator::WriteCompilerOptions(std::string const& fOSDir)
|
||||
{
|
||||
*this->GetBuildFileStream()
|
||||
<< " -os_dir=\"" << fOSDir << "\"" << std::endl;
|
||||
}
|
||||
|
||||
void cmGlobalGhsMultiGenerator::WriteDisclaimer(std::ostream* os)
|
||||
{
|
||||
(*os) << "#" << std::endl
|
||||
|
||||
@@ -85,7 +85,6 @@ public:
|
||||
std::map<std::string, cmGeneratedFileStream*>* fileMap);
|
||||
|
||||
static std::string trimQuotes(std::string const& str);
|
||||
inline bool IsOSDirRelative() { return this->OSDirRelative; }
|
||||
|
||||
protected:
|
||||
void Generate() override;
|
||||
@@ -105,7 +104,6 @@ private:
|
||||
|
||||
void WriteMacros();
|
||||
void WriteHighLevelDirectives();
|
||||
void WriteCompilerOptions(std::string const& fOSDir);
|
||||
|
||||
static void AddFilesUpToPathNewBuildFile(
|
||||
cmGeneratedFileStream* mainBuildFile,
|
||||
@@ -126,7 +124,6 @@ private:
|
||||
|
||||
std::vector<std::string> LibDirs;
|
||||
|
||||
bool OSDirRelative;
|
||||
static const char* DEFAULT_BUILD_PROGRAM;
|
||||
static const char* DEFAULT_TOOLSET_ROOT;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user