From a42e40e78dc3d9c4289a3c9640cae94ecd034373 Mon Sep 17 00:00:00 2001 From: Fred Baksik Date: Sat, 5 Jan 2019 11:01:19 -0500 Subject: 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 --- Modules/Platform/GHS-MULTI-Initialize.cmake | 8 ++- Source/cmGlobalGhsMultiGenerator.cxx | 76 +++++++++++++++++------------ Source/cmGlobalGhsMultiGenerator.h | 3 -- 3 files changed, 51 insertions(+), 36 deletions(-) diff --git a/Modules/Platform/GHS-MULTI-Initialize.cmake b/Modules/Platform/GHS-MULTI-Initialize.cmake index 9b384df..25004c6 100644 --- a/Modules/Platform/GHS-MULTI-Initialize.cmake +++ b/Modules/Platform/GHS-MULTI-Initialize.cmake @@ -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) diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 831c4a9..2d875c7 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -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; + } + + if (char const* osDirOptionCache = + this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR_OPTION")) { + osDirOption = osDirOptionCache; + } - this->WriteCompilerOptions(fOSDir); + 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 diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h index a5aff73..4ab4c56 100644 --- a/Source/cmGlobalGhsMultiGenerator.h +++ b/Source/cmGlobalGhsMultiGenerator.h @@ -85,7 +85,6 @@ public: std::map* 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 LibDirs; - bool OSDirRelative; static const char* DEFAULT_BUILD_PROGRAM; static const char* DEFAULT_TOOLSET_ROOT; }; -- cgit v0.12