From 0404efe786b1e2c5c28065a53e55ec77217e7b49 Mon Sep 17 00:00:00 2001 From: Naren Manimohan Date: Thu, 21 Mar 2019 17:00:04 +0100 Subject: GHS: Add support for GHS Multi Generator in Linux --- Help/generator/Green Hills MULTI.rst | 4 ++-- Help/release/dev/ghs-linux.rst | 4 ++++ Help/variable/CMAKE_MAKE_PROGRAM.rst | 3 ++- Modules/CMakeDetermineCompilerId.cmake | 14 +++++++++++--- Modules/Platform/GHS-MULTI-Initialize.cmake | 6 +++++- Source/CMakeLists.txt | 24 ++++++++++++++++-------- Source/cmGlobalGhsMultiGenerator.cxx | 5 +++++ Source/cmake.cxx | 9 +++++++-- 8 files changed, 52 insertions(+), 17 deletions(-) create mode 100644 Help/release/dev/ghs-linux.rst diff --git a/Help/generator/Green Hills MULTI.rst b/Help/generator/Green Hills MULTI.rst index e474682..09c5b15 100644 --- a/Help/generator/Green Hills MULTI.rst +++ b/Help/generator/Green Hills MULTI.rst @@ -33,12 +33,12 @@ Cache variables that are used for toolset and target system customization: * ``GHS_TOOLSET_ROOT`` | Root path for ``toolset`` searches. - | Defaults to ``C:/ghs``. + | Defaults to ``C:/ghs`` in Windows or ``/usr/ghs`` in Linux. * ``GHS_OS_ROOT`` | Root path for RTOS searches. - | Defaults to ``C:/ghs``. + | Defaults to ``C:/ghs`` in Windows or ``/usr/ghs`` in Linux. * ``GHS_OS_DIR`` diff --git a/Help/release/dev/ghs-linux.rst b/Help/release/dev/ghs-linux.rst new file mode 100644 index 0000000..6b663c8 --- /dev/null +++ b/Help/release/dev/ghs-linux.rst @@ -0,0 +1,4 @@ +ghs-linux +--------- + +* The :generator:`Green Hills MULTI` generator is now available on Linux. diff --git a/Help/variable/CMAKE_MAKE_PROGRAM.rst b/Help/variable/CMAKE_MAKE_PROGRAM.rst index 56df2df..a3c8b7c 100644 --- a/Help/variable/CMAKE_MAKE_PROGRAM.rst +++ b/Help/variable/CMAKE_MAKE_PROGRAM.rst @@ -52,7 +52,8 @@ to configure the project: possible. * The :generator:`Green Hills MULTI` generator sets this to the full - path to ``gbuild.exe`` based upon the toolset being used. + path to ``gbuild.exe(Windows)`` or ``gbuild(Linux)`` based upon + the toolset being used. Once the generator has initialized a particular value for this variable, changing the value has undefined behavior. diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 59dab6d..594f85b 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -431,10 +431,18 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} ) # Match the compiler location line printed out. set(ghs_toolpath "${CMAKE_MAKE_PROGRAM}") - string(REPLACE "/gbuild.exe" "/" ghs_toolpath ${ghs_toolpath}) - string(REPLACE / "\\\\" ghs_toolpath ${ghs_toolpath}) + if(CMAKE_HOST_UNIX) + string(REPLACE "/gbuild" "/" ghs_toolpath ${ghs_toolpath}) + else() + string(REPLACE "/gbuild.exe" "/" ghs_toolpath ${ghs_toolpath}) + string(REPLACE / "\\\\" ghs_toolpath ${ghs_toolpath}) + endif() if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "(${ghs_toolpath}[^ ]*)") - set(_comp "${CMAKE_MATCH_1}.exe") + if(CMAKE_HOST_UNIX) + set(_comp "${CMAKE_MATCH_1}") + else() + set(_comp "${CMAKE_MATCH_1}.exe") + endif() if(EXISTS "${_comp}") file(TO_CMAKE_PATH "${_comp}" _comp) set(CMAKE_${lang}_COMPILER_ID_TOOL "${_comp}" PARENT_SCOPE) diff --git a/Modules/Platform/GHS-MULTI-Initialize.cmake b/Modules/Platform/GHS-MULTI-Initialize.cmake index 25004c6..db65d14 100644 --- a/Modules/Platform/GHS-MULTI-Initialize.cmake +++ b/Modules/Platform/GHS-MULTI-Initialize.cmake @@ -3,7 +3,11 @@ #Setup Green Hills MULTI specific compilation information -set(GHS_OS_ROOT "C:/ghs" CACHE PATH "GHS platform OS search root directory") +if(CMAKE_HOST_UNIX) + set(GHS_OS_ROOT "/usr/ghs" CACHE PATH "GHS platform OS search root directory") +else() + set(GHS_OS_ROOT "C:/ghs" CACHE PATH "GHS platform OS search root directory") +endif() mark_as_advanced(GHS_OS_ROOT) set(GHS_OS_DIR "NOTFOUND" CACHE PATH "GHS platform OS directory") diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 696826f..f65e78f 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -727,14 +727,6 @@ if (WIN32) cmVisualStudioSlnParser.cxx cmVisualStudioWCEPlatformParser.h cmVisualStudioWCEPlatformParser.cxx - cmGlobalGhsMultiGenerator.cxx - cmGlobalGhsMultiGenerator.h - cmLocalGhsMultiGenerator.cxx - cmLocalGhsMultiGenerator.h - cmGhsMultiTargetGenerator.cxx - cmGhsMultiTargetGenerator.h - cmGhsMultiGpj.cxx - cmGhsMultiGpj.h cmVSSetupHelper.cxx cmVSSetupHelper.h ) @@ -754,6 +746,22 @@ if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux") ) endif() +# GHS support +# Works only for windows and linux +if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(SRCS ${SRCS} + cmGlobalGhsMultiGenerator.cxx + cmGlobalGhsMultiGenerator.h + cmLocalGhsMultiGenerator.cxx + cmLocalGhsMultiGenerator.h + cmGhsMultiTargetGenerator.cxx + cmGhsMultiTargetGenerator.h + cmGhsMultiGpj.cxx + cmGhsMultiGpj.h + ) +endif() + + # Ninja support set(SRCS ${SRCS} cmGlobalNinjaGenerator.cxx diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index dd2e100..690398f 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -22,8 +22,13 @@ #include const char* cmGlobalGhsMultiGenerator::FILE_EXTENSION = ".gpj"; +#ifdef __linux__ +const char* cmGlobalGhsMultiGenerator::DEFAULT_BUILD_PROGRAM = "gbuild"; +const char* cmGlobalGhsMultiGenerator::DEFAULT_TOOLSET_ROOT = "/usr/ghs"; +#elif defined(_WIN32) const char* cmGlobalGhsMultiGenerator::DEFAULT_BUILD_PROGRAM = "gbuild.exe"; const char* cmGlobalGhsMultiGenerator::DEFAULT_TOOLSET_ROOT = "C:/ghs"; +#endif cmGlobalGhsMultiGenerator::cmGlobalGhsMultiGenerator(cmake* cm) : cmGlobalGenerator(cm) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 08e284e..69dc26b 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -48,7 +48,6 @@ #if defined(_WIN32) && !defined(__CYGWIN__) # if !defined(CMAKE_BOOT_MINGW) # include "cmGlobalBorlandMakefileGenerator.h" -# include "cmGlobalGhsMultiGenerator.h" # include "cmGlobalJOMMakefileGenerator.h" # include "cmGlobalNMakeMakefileGenerator.h" # include "cmGlobalVisualStudio10Generator.h" @@ -84,6 +83,10 @@ # include "cmExtraEclipseCDT4Generator.h" #endif +#if defined(__linux__) || defined(_WIN32) +# include "cmGlobalGhsMultiGenerator.h" +#endif + #if defined(__APPLE__) # if defined(CMAKE_BUILD_WITH_CMAKE) # include "cmGlobalXCodeGenerator.h" @@ -1833,13 +1836,15 @@ void cmake::AddDefaultGenerators() this->Generators.push_back(cmGlobalBorlandMakefileGenerator::NewFactory()); this->Generators.push_back(cmGlobalNMakeMakefileGenerator::NewFactory()); this->Generators.push_back(cmGlobalJOMMakefileGenerator::NewFactory()); - this->Generators.push_back(cmGlobalGhsMultiGenerator::NewFactory()); # endif this->Generators.push_back(cmGlobalMSYSMakefileGenerator::NewFactory()); this->Generators.push_back(cmGlobalMinGWMakefileGenerator::NewFactory()); #endif this->Generators.push_back(cmGlobalUnixMakefileGenerator3::NewFactory()); #if defined(CMAKE_BUILD_WITH_CMAKE) +# if defined(__linux__) || defined(_WIN32) + this->Generators.push_back(cmGlobalGhsMultiGenerator::NewFactory()); +# endif this->Generators.push_back(cmGlobalNinjaGenerator::NewFactory()); #endif #if defined(CMAKE_USE_WMAKE) -- cgit v0.12