GHS: Print status message regarding GHS_OS_DIR
-- Rename platform script so it runs before initial try_compile() in project() command. -- Fix incorrect variable name GHS_OS_DIR_OPTION -- Remove unnecessary ".*" from REGEX expression for GHS_CANDIDATE_OS_DIRS -- Forward GHS_OS_DIR_OPTION to try_compile() and preserve trailing whitespace of the variable.
This commit is contained in:
parent
89abbdd8c8
commit
266dadf868
@ -40,11 +40,12 @@ Cache variables that are used for toolset and target system customization:
|
|||||||
| Root path for RTOS searches.
|
| Root path for RTOS searches.
|
||||||
| Defaults to ``C:/ghs`` in Windows or ``/usr/ghs`` in Linux.
|
| Defaults to ``C:/ghs`` in Windows or ``/usr/ghs`` in Linux.
|
||||||
|
|
||||||
* ``GHS_OS_DIR``
|
* ``GHS_OS_DIR`` and ``GHS_OS_DIR_OPTION``
|
||||||
|
|
||||||
| Sets ``-os_dir`` entry in project file.
|
| Sets ``-os_dir`` entry in project file.
|
||||||
| Defaults to latest platform OS installation at ``GHS_OS_ROOT``. Set this value if
|
| Defaults to latest platform OS installation at ``GHS_OS_ROOT``. Set this value if
|
||||||
a specific RTOS is to be used.
|
a specific RTOS is to be used.
|
||||||
|
| ``GHS_OS_DIR_OPTION`` default value is ``-os_dir``.
|
||||||
|
|
||||||
* ``GHS_BSP_NAME``
|
* ``GHS_BSP_NAME``
|
||||||
|
|
||||||
|
@ -13,39 +13,40 @@ mark_as_advanced(GHS_OS_ROOT)
|
|||||||
set(GHS_OS_DIR "NOTFOUND" CACHE PATH "GHS platform OS directory")
|
set(GHS_OS_DIR "NOTFOUND" CACHE PATH "GHS platform OS directory")
|
||||||
mark_as_advanced(GHS_OS_DIR)
|
mark_as_advanced(GHS_OS_DIR)
|
||||||
|
|
||||||
set(GHS_OS_DIR_OPTION "-os_dir " CACHE STRING "GHS compiler os option")
|
set(GHS_OS_DIR_OPTION "-os_dir " CACHE STRING "GHS compiler OS option")
|
||||||
mark_as_advanced(GHS_OS_DIR)
|
mark_as_advanced(GHS_OS_DIR_OPTION)
|
||||||
|
|
||||||
#set GHS_OS_DIR if not set by user
|
#set GHS_OS_DIR if not set by user
|
||||||
if ( NOT GHS_OS_DIR )
|
if(NOT GHS_OS_DIR)
|
||||||
if (EXISTS ${GHS_OS_ROOT})
|
if(EXISTS ${GHS_OS_ROOT})
|
||||||
|
|
||||||
#get all directories in root directory
|
#get all directories in root directory
|
||||||
FILE(GLOB GHS_CANDIDATE_OS_DIRS
|
FILE(GLOB GHS_CANDIDATE_OS_DIRS
|
||||||
LIST_DIRECTORIES true RELATIVE ${GHS_OS_ROOT} ${GHS_OS_ROOT}/*)
|
LIST_DIRECTORIES true RELATIVE ${GHS_OS_ROOT} ${GHS_OS_ROOT}/*)
|
||||||
FILE(GLOB GHS_CANDIDATE_OS_FILES
|
FILE(GLOB GHS_CANDIDATE_OS_FILES
|
||||||
LIST_DIRECTORIES false RELATIVE ${GHS_OS_ROOT} ${GHS_OS_ROOT}/*)
|
LIST_DIRECTORIES false RELATIVE ${GHS_OS_ROOT} ${GHS_OS_ROOT}/*)
|
||||||
if ( GHS_CANDIDATE_OS_FILES )
|
if(GHS_CANDIDATE_OS_FILES)
|
||||||
list(REMOVE_ITEM GHS_CANDIDATE_OS_DIRS ${GHS_CANDIDATE_OS_FILES})
|
list(REMOVE_ITEM GHS_CANDIDATE_OS_DIRS ${GHS_CANDIDATE_OS_FILES})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
#filter based on platform name
|
#filter based on platform name
|
||||||
if (GHS_TARGET_PLATFORM MATCHES "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].*")
|
list(FILTER GHS_CANDIDATE_OS_DIRS INCLUDE REGEX "int[0-9][0-9][0-9][0-9a-z]")
|
||||||
else() #fall-back for standalone
|
else() #fall-back for standalone
|
||||||
unset(GHS_CANDIDATE_OS_DIRS)
|
unset(GHS_CANDIDATE_OS_DIRS)
|
||||||
set(GHS_OS_DIR "IGNORE")
|
set(GHS_OS_DIR "IGNORE")
|
||||||
endif ()
|
endif()
|
||||||
|
|
||||||
if (GHS_CANDIDATE_OS_DIRS)
|
if(GHS_CANDIDATE_OS_DIRS)
|
||||||
list(SORT GHS_CANDIDATE_OS_DIRS)
|
list(SORT GHS_CANDIDATE_OS_DIRS)
|
||||||
list(GET GHS_CANDIDATE_OS_DIRS -1 GHS_OS_DIR)
|
list(GET GHS_CANDIDATE_OS_DIRS -1 GHS_OS_DIR)
|
||||||
string(CONCAT GHS_OS_DIR ${GHS_OS_ROOT} "/" ${GHS_OS_DIR})
|
string(CONCAT GHS_OS_DIR ${GHS_OS_ROOT} "/" ${GHS_OS_DIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#update cache with new value
|
||||||
set(GHS_OS_DIR "${GHS_OS_DIR}" CACHE PATH "GHS platform OS directory" FORCE)
|
set(GHS_OS_DIR "${GHS_OS_DIR}" CACHE PATH "GHS platform OS directory" FORCE)
|
||||||
endif ()
|
endif()
|
||||||
endif ()
|
endif()
|
||||||
|
|
||||||
set(GHS_BSP_NAME "IGNORE" CACHE STRING "BSP name")
|
set(GHS_BSP_NAME "IGNORE" CACHE STRING "BSP name")
|
||||||
|
|
@ -60,7 +60,8 @@ static std::string const kCMAKE_WARN_DEPRECATED = "CMAKE_WARN_DEPRECATED";
|
|||||||
/* GHS Multi platform variables */
|
/* GHS Multi platform variables */
|
||||||
static std::set<std::string> ghs_platform_vars{
|
static std::set<std::string> ghs_platform_vars{
|
||||||
"GHS_TARGET_PLATFORM", "GHS_PRIMARY_TARGET", "GHS_TOOLSET_ROOT",
|
"GHS_TARGET_PLATFORM", "GHS_PRIMARY_TARGET", "GHS_TOOLSET_ROOT",
|
||||||
"GHS_OS_ROOT", "GHS_OS_DIR", "GHS_BSP_NAME"
|
"GHS_OS_ROOT", "GHS_OS_DIR", "GHS_BSP_NAME",
|
||||||
|
"GHS_OS_DIR_OPTION"
|
||||||
};
|
};
|
||||||
|
|
||||||
static void writeProperty(FILE* fout, std::string const& targetName,
|
static void writeProperty(FILE* fout, std::string const& targetName,
|
||||||
@ -881,7 +882,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
|
|||||||
// Forward the GHS variables to the inner project cache.
|
// Forward the GHS variables to the inner project cache.
|
||||||
for (std::string const& var : ghs_platform_vars) {
|
for (std::string const& var : ghs_platform_vars) {
|
||||||
if (const char* val = this->Makefile->GetDefinition(var)) {
|
if (const char* val = this->Makefile->GetDefinition(var)) {
|
||||||
std::string flag = "-D" + var + "=" + val;
|
std::string flag = "-D" + var + "=" + "'" + val + "'";
|
||||||
cmakeFlags.push_back(std::move(flag));
|
cmakeFlags.push_back(std::move(flag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,17 +132,30 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p,
|
|||||||
cmStateEnums::INTERNAL);
|
cmStateEnums::INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* tgtPlatform = mf->GetDefinition("GHS_TARGET_PLATFORM");
|
/* check if OS location has been updated by platform scripts */
|
||||||
if (tgtPlatform == nullptr) {
|
std::string platform = mf->GetSafeDefinition("GHS_TARGET_PLATFORM");
|
||||||
cmSystemTools::Message("Green Hills MULTI: GHS_TARGET_PLATFORM not "
|
std::string osdir = mf->GetSafeDefinition("GHS_OS_DIR");
|
||||||
"specified; defaulting to \"integrity\"");
|
if (cmSystemTools::IsOff(osdir.c_str()) &&
|
||||||
tgtPlatform = "integrity";
|
platform.find("integrity") != std::string::npos) {
|
||||||
|
if (!this->CMakeInstance->GetIsInTryCompile()) {
|
||||||
|
/* required OS location is not found */
|
||||||
|
std::string m =
|
||||||
|
"Green Hills MULTI: GHS_OS_DIR not specified; No OS found in \"";
|
||||||
|
m += mf->GetSafeDefinition("GHS_OS_ROOT");
|
||||||
|
m += "\"";
|
||||||
|
cmSystemTools::Message(m);
|
||||||
|
}
|
||||||
|
osdir = "GHS_OS_DIR-NOT-SPECIFIED";
|
||||||
|
} else if (!this->CMakeInstance->GetIsInTryCompile() &&
|
||||||
|
cmSystemTools::IsOff(this->OsDir) &&
|
||||||
|
!cmSystemTools::IsOff(osdir)) {
|
||||||
|
/* OS location was updated by auto-selection */
|
||||||
|
std::string m = "Green Hills MULTI: GHS_OS_DIR not specified; found \"";
|
||||||
|
m += osdir;
|
||||||
|
m += "\"";
|
||||||
|
cmSystemTools::Message(m);
|
||||||
}
|
}
|
||||||
|
this->OsDir = osdir;
|
||||||
/* store the platform name for later use */
|
|
||||||
mf->AddCacheDefinition("GHS_TARGET_PLATFORM", tgtPlatform,
|
|
||||||
"Name of GHS target platform.",
|
|
||||||
cmStateEnums::INTERNAL);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -153,6 +166,21 @@ void cmGlobalGhsMultiGenerator::EnableLanguage(
|
|||||||
mf->AddDefinition("CMAKE_SYSTEM_NAME", "GHS-MULTI");
|
mf->AddDefinition("CMAKE_SYSTEM_NAME", "GHS-MULTI");
|
||||||
|
|
||||||
mf->AddDefinition("GHSMULTI", "1"); // identifier for user CMake files
|
mf->AddDefinition("GHSMULTI", "1"); // identifier for user CMake files
|
||||||
|
|
||||||
|
const char* tgtPlatform = mf->GetDefinition("GHS_TARGET_PLATFORM");
|
||||||
|
if (!tgtPlatform) {
|
||||||
|
cmSystemTools::Message("Green Hills MULTI: GHS_TARGET_PLATFORM not "
|
||||||
|
"specified; defaulting to \"integrity\"");
|
||||||
|
tgtPlatform = "integrity";
|
||||||
|
}
|
||||||
|
|
||||||
|
/* store the platform name for later use */
|
||||||
|
mf->AddCacheDefinition("GHS_TARGET_PLATFORM", tgtPlatform,
|
||||||
|
"Name of GHS target platform.", cmStateEnums::STRING);
|
||||||
|
|
||||||
|
/* store original OS location */
|
||||||
|
this->OsDir = mf->GetSafeDefinition("GHS_OS_DIR");
|
||||||
|
|
||||||
this->cmGlobalGenerator::EnableLanguage(l, mf, optional);
|
this->cmGlobalGenerator::EnableLanguage(l, mf, optional);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,22 +289,17 @@ void cmGlobalGhsMultiGenerator::WriteTopLevelProject(
|
|||||||
|
|
||||||
// Specify OS DIR if supplied by user
|
// Specify OS DIR if supplied by user
|
||||||
// -- not all platforms require this entry in the project file
|
// -- not all platforms require this entry in the project file
|
||||||
std::string osDir;
|
if (!cmSystemTools::IsOff(this->OsDir.c_str())) {
|
||||||
std::string osDirOption;
|
const char* osDirOption =
|
||||||
if (char const* osDirCache =
|
this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR_OPTION");
|
||||||
this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR")) {
|
std::replace(this->OsDir.begin(), this->OsDir.end(), '\\', '/');
|
||||||
osDir = osDirCache;
|
fout << " ";
|
||||||
}
|
if (cmSystemTools::IsOff(osDirOption)) {
|
||||||
|
fout << "";
|
||||||
if (char const* osDirOptionCache =
|
} else {
|
||||||
this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR_OPTION")) {
|
fout << osDirOption;
|
||||||
osDirOption = osDirOptionCache;
|
}
|
||||||
}
|
fout << "\"" << this->OsDir << "\"" << std::endl;
|
||||||
|
|
||||||
if (!cmSystemTools::IsOff(osDir.c_str()) ||
|
|
||||||
platform.find("integrity") != std::string::npos) {
|
|
||||||
std::replace(osDir.begin(), osDir.end(), '\\', '/');
|
|
||||||
fout << " " << osDirOption << "\"" << osDir << "\"" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteSubProjects(fout, root, generators);
|
WriteSubProjects(fout, root, generators);
|
||||||
|
@ -120,6 +120,7 @@ private:
|
|||||||
|
|
||||||
std::string trimQuotes(std::string const& str);
|
std::string trimQuotes(std::string const& str);
|
||||||
|
|
||||||
|
std::string OsDir;
|
||||||
static const char* DEFAULT_BUILD_PROGRAM;
|
static const char* DEFAULT_BUILD_PROGRAM;
|
||||||
static const char* DEFAULT_TOOLSET_ROOT;
|
static const char* DEFAULT_TOOLSET_ROOT;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user