|
|
@@ -2,22 +2,33 @@
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
|
|
#include "cmGlobalGhsMultiGenerator.h"
|
|
|
|
|
|
-#include "cmsys/SystemTools.hxx"
|
|
|
-
|
|
|
-#include "cmAlgorithms.h"
|
|
|
#include "cmDocumentationEntry.h"
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
#include "cmGeneratorTarget.h"
|
|
|
-#include "cmGhsMultiTargetGenerator.h"
|
|
|
+#include "cmGhsMultiGpj.h"
|
|
|
+#include "cmLocalGenerator.h"
|
|
|
#include "cmLocalGhsMultiGenerator.h"
|
|
|
#include "cmMakefile.h"
|
|
|
#include "cmState.h"
|
|
|
+#include "cmStateTypes.h"
|
|
|
+#include "cmSystemTools.h"
|
|
|
#include "cmVersion.h"
|
|
|
#include "cmake.h"
|
|
|
|
|
|
+#include <algorithm>
|
|
|
+#include <map>
|
|
|
+#include <ostream>
|
|
|
+#include <string.h>
|
|
|
+#include <utility>
|
|
|
+
|
|
|
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)
|
|
|
@@ -25,9 +36,7 @@ cmGlobalGhsMultiGenerator::cmGlobalGhsMultiGenerator(cmake* cm)
|
|
|
cm->GetState()->SetGhsMultiIDE(true);
|
|
|
}
|
|
|
|
|
|
-cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator()
|
|
|
-{
|
|
|
-}
|
|
|
+cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator() = default;
|
|
|
|
|
|
cmLocalGenerator* cmGlobalGhsMultiGenerator::CreateLocalGenerator(
|
|
|
cmMakefile* mf)
|
|
|
@@ -64,7 +73,8 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
|
|
|
/* no toolset was found */
|
|
|
if (tsp.empty()) {
|
|
|
return false;
|
|
|
- } else if (ts.empty()) {
|
|
|
+ }
|
|
|
+ if (ts.empty()) {
|
|
|
std::string message;
|
|
|
message =
|
|
|
"Green Hills MULTI: -T <toolset> not specified; defaulting to \"";
|
|
|
@@ -86,7 +96,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
|
|
|
const char* prevTool = mf->GetDefinition("CMAKE_MAKE_PROGRAM");
|
|
|
|
|
|
/* check if the toolset changed from last generate */
|
|
|
- if (prevTool != NULL && (gbuild != prevTool)) {
|
|
|
+ if (prevTool != nullptr && (gbuild != prevTool)) {
|
|
|
std::string message = "toolset build tool: ";
|
|
|
message += gbuild;
|
|
|
message += "\nDoes not match the previously used build tool: ";
|
|
|
@@ -95,13 +105,12 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
|
|
|
"directory or choose a different binary directory.";
|
|
|
cmSystemTools::Error(message);
|
|
|
return false;
|
|
|
- } else {
|
|
|
- /* store the toolset that is being used for this build */
|
|
|
- mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM", gbuild.c_str(),
|
|
|
- "build program to use", cmStateEnums::INTERNAL,
|
|
|
- true);
|
|
|
}
|
|
|
|
|
|
+ /* store the toolset that is being used for this build */
|
|
|
+ mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM", gbuild.c_str(),
|
|
|
+ "build program to use", cmStateEnums::INTERNAL, true);
|
|
|
+
|
|
|
mf->AddDefinition("CMAKE_SYSTEM_VERSION", tsp.c_str());
|
|
|
|
|
|
return true;
|
|
|
@@ -110,7 +119,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
|
|
|
bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p,
|
|
|
cmMakefile* mf)
|
|
|
{
|
|
|
- if (p == "") {
|
|
|
+ if (p.empty()) {
|
|
|
cmSystemTools::Message(
|
|
|
"Green Hills MULTI: -A <arch> not specified; defaulting to \"arm\"");
|
|
|
std::string arch = "arm";
|
|
|
@@ -201,7 +210,7 @@ void cmGlobalGhsMultiGenerator::WriteFileHeader(std::ostream& fout)
|
|
|
fout << "#!gbuild" << std::endl;
|
|
|
fout << "#" << std::endl
|
|
|
<< "# CMAKE generated file: DO NOT EDIT!" << std::endl
|
|
|
- << "# Generated by \"" << this->GetActualName() << "\""
|
|
|
+ << "# Generated by \"" << GetActualName() << "\""
|
|
|
<< " Generator, CMake Version " << cmVersion::GetMajorVersion() << "."
|
|
|
<< cmVersion::GetMinorVersion() << std::endl
|
|
|
<< "#" << std::endl
|
|
|
@@ -296,7 +305,7 @@ void cmGlobalGhsMultiGenerator::WriteSubProjects(
|
|
|
if (projName && projType) {
|
|
|
cmLocalGenerator* lg = target->GetLocalGenerator();
|
|
|
std::string dir = lg->GetCurrentBinaryDirectory();
|
|
|
- dir = root->MaybeConvertToRelativePath(rootBinaryDir, dir.c_str());
|
|
|
+ dir = root->MaybeConvertToRelativePath(rootBinaryDir, dir);
|
|
|
if (dir == ".") {
|
|
|
dir.clear();
|
|
|
} else {
|
|
|
@@ -319,7 +328,7 @@ void cmGlobalGhsMultiGenerator::WriteSubProjects(
|
|
|
fname += "REF";
|
|
|
fname += FILE_EXTENSION;
|
|
|
|
|
|
- cmGeneratedFileStream fref(fname.c_str());
|
|
|
+ cmGeneratedFileStream fref(fname);
|
|
|
fref.SetCopyIfDifferent(true);
|
|
|
|
|
|
this->WriteFileHeader(fref);
|
|
|
@@ -360,7 +369,7 @@ void cmGlobalGhsMultiGenerator::OutputTopLevelProject(
|
|
|
fname += ".top";
|
|
|
fname += FILE_EXTENSION;
|
|
|
|
|
|
- cmGeneratedFileStream fout(fname.c_str());
|
|
|
+ cmGeneratedFileStream fout(fname);
|
|
|
fout.SetCopyIfDifferent(true);
|
|
|
|
|
|
this->WriteTopLevelProject(fout, root, generators);
|
|
|
@@ -376,9 +385,12 @@ cmGlobalGhsMultiGenerator::GenerateBuildCommand(
|
|
|
std::vector<std::string> const& makeOptions)
|
|
|
{
|
|
|
GeneratedMakeCommand makeCommand = {};
|
|
|
- const char* gbuild =
|
|
|
- this->CMakeInstance->GetCacheDefinition("CMAKE_MAKE_PROGRAM");
|
|
|
- makeCommand.Add(this->SelectMakeProgram(makeProgram, (std::string)gbuild));
|
|
|
+ std::string gbuild;
|
|
|
+ if (const char* gbuildCached =
|
|
|
+ this->CMakeInstance->GetCacheDefinition("CMAKE_MAKE_PROGRAM")) {
|
|
|
+ gbuild = gbuildCached;
|
|
|
+ }
|
|
|
+ makeCommand.Add(this->SelectMakeProgram(makeProgram, gbuild));
|
|
|
|
|
|
if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) {
|
|
|
makeCommand.Add("-parallel");
|
|
|
@@ -424,7 +436,7 @@ void cmGlobalGhsMultiGenerator::WriteMacros(std::ostream& fout)
|
|
|
{
|
|
|
char const* ghsGpjMacros =
|
|
|
this->GetCMakeInstance()->GetCacheDefinition("GHS_GPJ_MACROS");
|
|
|
- if (NULL != ghsGpjMacros) {
|
|
|
+ if (nullptr != ghsGpjMacros) {
|
|
|
std::vector<std::string> expandedList;
|
|
|
cmSystemTools::ExpandListArgument(std::string(ghsGpjMacros), expandedList);
|
|
|
for (std::string const& arg : expandedList) {
|
|
|
@@ -457,7 +469,7 @@ void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives(std::ostream& fout)
|
|
|
|
|
|
char const* const customization =
|
|
|
this->GetCMakeInstance()->GetCacheDefinition("GHS_CUSTOMIZATION");
|
|
|
- if (NULL != customization && strlen(customization) > 0) {
|
|
|
+ if (nullptr != customization && strlen(customization) > 0) {
|
|
|
fout << "customization=" << trimQuotes(customization) << std::endl;
|
|
|
this->GetCMakeInstance()->MarkCliAsUsed("GHS_CUSTOMIZATION");
|
|
|
}
|