diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmAddCustomCommandCommand.cxx | 10 | ||||
-rw-r--r-- | Source/cmAddCustomTargetCommand.cxx | 20 | ||||
-rw-r--r-- | Source/cmCustomCommand.cxx | 10 | ||||
-rw-r--r-- | Source/cmCustomCommand.h | 6 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 9 | ||||
-rw-r--r-- | Source/cmPolicies.cxx | 160 | ||||
-rw-r--r-- | Source/cmUVProcessChain.cxx | 4 | ||||
-rw-r--r-- | Source/cmUVProcessChain.h | 2 |
9 files changed, 111 insertions, 112 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 38046ab..d6546f2 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 27) -set(CMake_VERSION_PATCH 20230726) +set(CMake_VERSION_PATCH 20230727) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 044b5df..b1589ff 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -334,15 +334,6 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args, return false; } - // If using a GNU Make generator and `JOB_SERVER_AWARE` is set then - // prefix all commands with '+'. - if (cmIsOn(job_server_aware) && - mf.GetGlobalGenerator()->IsGNUMakeJobServerAware()) { - for (auto& commandLine : commandLines) { - commandLine.insert(commandLine.begin(), "+"); - } - } - // Choose which mode of the command to use. auto cc = cm::make_unique<cmCustomCommand>(); cc->SetByproducts(byproducts); @@ -353,6 +344,7 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args, cc->SetUsesTerminal(uses_terminal); cc->SetDepfile(depfile); cc->SetJobPool(job_pool); + cc->SetJobserverAware(cmIsOn(job_server_aware)); cc->SetCommandExpandLists(command_expand_lists); cc->SetDependsExplicitOnly(depends_explicit_only); if (source.empty() && output.empty()) { diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index 6339062..711eaa5 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -55,7 +55,7 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args, const char* comment = nullptr; std::vector<std::string> sources; std::string job_pool; - std::string JOB_SERVER_AWARE; + std::string job_server_aware; // Keep track of parser state. enum tdoing @@ -67,7 +67,7 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args, doing_comment, doing_source, doing_job_pool, - doing_JOB_SERVER_AWARE, + doing_job_server_aware, doing_nothing }; tdoing doing = doing_command; @@ -106,7 +106,7 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args, } else if (copy == "JOB_POOL") { doing = doing_job_pool; } else if (copy == "JOB_SERVER_AWARE") { - doing = doing_JOB_SERVER_AWARE; + doing = doing_job_server_aware; } else if (copy == "COMMAND") { doing = doing_command; @@ -153,8 +153,8 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args, case doing_job_pool: job_pool = copy; break; - case doing_JOB_SERVER_AWARE: - JOB_SERVER_AWARE = copy; + case doing_job_server_aware: + job_server_aware = copy; break; default: status.SetError("Wrong syntax. Unknown type of argument."); @@ -220,15 +220,6 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args, return false; } - // If using a GNU Make generator and `JOB_SERVER_AWARE` is set then - // prefix all commands with '+'. - if (cmIsOn(JOB_SERVER_AWARE) && - mf.GetGlobalGenerator()->IsGNUMakeJobServerAware()) { - for (auto& commandLine : commandLines) { - commandLine.insert(commandLine.begin(), "+"); - } - } - // Add the utility target to the makefile. auto cc = cm::make_unique<cmCustomCommand>(); cc->SetWorkingDirectory(working_directory.c_str()); @@ -240,6 +231,7 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args, cc->SetUsesTerminal(uses_terminal); cc->SetCommandExpandLists(command_expand_lists); cc->SetJobPool(job_pool); + cc->SetJobserverAware(cmIsOn(job_server_aware)); cmTarget* target = mf.AddUtilityCommand(targetName, excludeFromAll, std::move(cc)); diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index e12cf70..9958e4d 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -194,6 +194,16 @@ void cmCustomCommand::SetJobPool(const std::string& job_pool) this->JobPool = job_pool; } +bool cmCustomCommand::GetJobserverAware() const +{ + return this->JobserverAware; +} + +void cmCustomCommand::SetJobserverAware(bool b) +{ + this->JobserverAware = b; +} + #define DEFINE_CC_POLICY_ACCESSOR(P) \ cmPolicies::PolicyStatus cmCustomCommand::Get##P##Status() const \ { \ diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index 1e68dbf..167e601 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -115,6 +115,11 @@ public: const std::string& GetJobPool() const; void SetJobPool(const std::string& job_pool); + /** Set/Get whether this custom command should be given access to the + jobserver (if possible). */ + bool GetJobserverAware() const; + void SetJobserverAware(bool b); + #define DECLARE_CC_POLICY_ACCESSOR(P) \ cmPolicies::PolicyStatus Get##P##Status() const; CM_FOR_EACH_CUSTOM_COMMAND_POLICY(DECLARE_CC_POLICY_ACCESSOR) @@ -139,6 +144,7 @@ private: std::string WorkingDirectory; std::string Depfile; std::string JobPool; + bool JobserverAware = false; bool HaveComment = false; bool EscapeAllowMakeVars = false; bool EscapeOldStyle = true; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 3c6b303..e26a6ea 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1080,6 +1080,15 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand( // Setup the proper working directory for the commands. this->CreateCDCommand(commands1, dir, relative); + cmGlobalUnixMakefileGenerator3* gg = + static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); + + // Prefix the commands with the jobserver prefix "+" + if (ccg.GetCC().GetJobserverAware() && gg->IsGNUMakeJobServerAware()) { + std::transform(commands1.begin(), commands1.end(), commands1.begin(), + [](std::string const& cmd) { return cmStrCat("+", cmd); }); + } + // push back the custom commands cm::append(commands, commands1); } diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index d5e5725..d89c8c8 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -123,23 +123,23 @@ static void DiagnoseAncientPolicies( { std::ostringstream e; e << "The project requests behavior compatible with CMake version \"" - << majorVer << "." << minorVer << "." << patchVer + << majorVer << '.' << minorVer << '.' << patchVer << "\", which requires the OLD behavior for some policies:\n"; for (cmPolicies::PolicyID i : ancient) { - e << " " << idToString(i) << ": " << idToShortDescription(i) << "\n"; + e << " " << idToString(i) << ": " << idToShortDescription(i) << '\n'; } e << "However, this version of CMake no longer supports the OLD " - << "behavior for these policies. " - << "Please either update your CMakeLists.txt files to conform to " - << "the new behavior or use an older version of CMake that still " - << "supports the old behavior."; + "behavior for these policies. " + "Please either update your CMakeLists.txt files to conform to " + "the new behavior or use an older version of CMake that still " + "supports the old behavior."; mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); } static bool GetPolicyDefault(cmMakefile* mf, std::string const& policy, cmPolicies::PolicyStatus* defaultSetting) { - std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy; + std::string defaultVar = cmStrCat("CMAKE_POLICY_DEFAULT_", policy); std::string const& defaultValue = mf->GetSafeDefinition(defaultVar); if (defaultValue == "NEW") { *defaultSetting = cmPolicies::NEW; @@ -148,10 +148,10 @@ static bool GetPolicyDefault(cmMakefile* mf, std::string const& policy, } else if (defaultValue.empty()) { *defaultSetting = cmPolicies::WARN; } else { - std::ostringstream e; - e << defaultVar << " has value \"" << defaultValue - << R"(" but must be "OLD", "NEW", or "" (empty).)"; - mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); + mf->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat(defaultVar, " has value \"", defaultValue, + R"(" but must be "OLD", "NEW", or "" (empty).)")); return false; } @@ -170,10 +170,11 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, unsigned int minTweak = 0; if (sscanf(version_min.c_str(), "%u.%u.%u.%u", &minMajor, &minMinor, &minPatch, &minTweak) < 2) { - std::ostringstream e; - e << "Invalid policy version value \"" << version_min << "\". " - << "A numeric major.minor[.patch[.tweak]] must be given."; - mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); + mf->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Invalid policy version value \"", version_min, + "\". " + "A numeric major.minor[.patch[.tweak]] must be given.")); return false; } @@ -199,13 +200,14 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, minMinor == cmVersion::GetMinorVersion() && minPatch == cmVersion::GetPatchVersion() && minTweak > cmVersion::GetTweakVersion())) { - std::ostringstream e; - e << "An attempt was made to set the policy version of CMake to \"" - << version_min << "\" which is greater than this version of CMake. " - << "This is not allowed because the greater version may have new " - << "policies not known to this CMake. " - << "You may need a newer CMake version to build this project."; - mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); + mf->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("An attempt was made to set the policy version of CMake to \"", + version_min, + "\" which is greater than this version of CMake. ", + "This is not allowed because the greater version may have new " + "policies not known to this CMake. " + "You may need a newer CMake version to build this project.")); return false; } @@ -221,10 +223,11 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, unsigned int maxTweak = 0; if (sscanf(version_max.c_str(), "%u.%u.%u.%u", &maxMajor, &maxMinor, &maxPatch, &maxTweak) < 2) { - std::ostringstream e; - e << "Invalid policy max version value \"" << version_max << "\". " - << "A numeric major.minor[.patch[.tweak]] must be given."; - mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); + mf->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Invalid policy max version value \"", version_max, + "\". " + "A numeric major.minor[.patch[.tweak]] must be given.")); return false; } @@ -234,11 +237,10 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, minPatch > maxPatch) || (minMajor == maxMajor && minMinor == maxMinor && minPatch == maxPatch && minTweak > maxTweak)) { - std::ostringstream e; - e << "Policy VERSION range \"" << version_min << "..." << version_max - << "\"" - << " specifies a larger minimum than maximum."; - mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); + mf->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Policy VERSION range \"", version_min, "...", version_max, + "\" specifies a larger minimum than maximum.")); return false; } @@ -328,61 +330,49 @@ bool cmPolicies::GetPolicyID(const char* id, cmPolicies::PolicyID& pid) //! return a warning string for a given policy std::string cmPolicies::GetPolicyWarning(cmPolicies::PolicyID id) { - std::ostringstream msg; - msg << "Policy " << idToString(id) - << " is not set: " - "" - << idToShortDescription(id) - << " " - "Run \"cmake --help-policy " - << idToString(id) - << "\" for " - "policy details. " - "Use the cmake_policy command to set the policy " - "and suppress this warning."; - return msg.str(); + return cmStrCat("Policy ", idToString(id), + " is not set: ", idToShortDescription(id), + " " + "Run \"cmake --help-policy ", + idToString(id), + "\" for " + "policy details. " + "Use the cmake_policy command to set the policy " + "and suppress this warning."); } std::string cmPolicies::GetPolicyDeprecatedWarning(cmPolicies::PolicyID id) { - std::ostringstream msg; - /* clang-format off */ - msg << - "The OLD behavior for policy " << idToString(id) << " " + return cmStrCat( + "The OLD behavior for policy ", idToString(id), + " " "will be removed from a future version of CMake.\n" "The cmake-policies(7) manual explains that the OLD behaviors of all " "policies are deprecated and that a policy should be set to OLD only " "under specific short-term circumstances. Projects should be ported " - "to the NEW behavior and not rely on setting a policy to OLD." - ; - /* clang-format on */ - return msg.str(); + "to the NEW behavior and not rely on setting a policy to OLD."); } //! return an error string for when a required policy is unspecified std::string cmPolicies::GetRequiredPolicyError(cmPolicies::PolicyID id) { - std::ostringstream error; - error << "Policy " << idToString(id) - << " is not set to NEW: " - "" - << idToShortDescription(id) - << " " - "Run \"cmake --help-policy " - << idToString(id) - << "\" for " - "policy details. " - "CMake now requires this policy to be set to NEW by the project. " - "The policy may be set explicitly using the code\n" - " cmake_policy(SET " - << idToString(id) - << " NEW)\n" - "or by upgrading all policies with the code\n" - " cmake_policy(VERSION " - << idToVersion(id) - << ") # or later\n" - "Run \"cmake --help-command cmake_policy\" for more information."; - return error.str(); + return cmStrCat( + "Policy ", idToString(id), + " is not set to NEW: ", idToShortDescription(id), + " " + "Run \"cmake --help-policy ", + idToString(id), + "\" for policy details. " + "CMake now requires this policy to be set to NEW by the project. " + "The policy may be set explicitly using the code\n" + " cmake_policy(SET ", + idToString(id), + " NEW)\n" + "or by upgrading all policies with the code\n" + " cmake_policy(VERSION ", + idToVersion(id), + ") # or later\n" + "Run \"cmake --help-command cmake_policy\" for more information."); } //! Get the default status for a policy @@ -395,18 +385,18 @@ cmPolicies::PolicyStatus cmPolicies::GetPolicyStatus( std::string cmPolicies::GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id) { std::string pid = idToString(id); - std::ostringstream e; - e << "Policy " << pid << " may not be set to OLD behavior because this " - << "version of CMake no longer supports it. " - << "The policy was introduced in " - << "CMake version " << idToVersion(id) - << ", and use of NEW behavior is now required." - << "\n" - << "Please either update your CMakeLists.txt files to conform to " - << "the new behavior or use an older version of CMake that still " - << "supports the old behavior. " - << "Run cmake --help-policy " << pid << " for more information."; - return e.str(); + return cmStrCat( + "Policy ", pid, + " may not be set to OLD behavior because this " + "version of CMake no longer supports it. " + "The policy was introduced in CMake version ", + idToVersion(id), + ", and use of NEW behavior is now required." + "\n" + "Please either update your CMakeLists.txt files to conform to " + "the new behavior or use an older version of CMake that still " + "supports the old behavior. Run cmake --help-policy ", + pid, " for more information."); } cmPolicies::PolicyStatus cmPolicies::PolicyMap::Get( diff --git a/Source/cmUVProcessChain.cxx b/Source/cmUVProcessChain.cxx index 3de7ae5..119851c 100644 --- a/Source/cmUVProcessChain.cxx +++ b/Source/cmUVProcessChain.cxx @@ -393,12 +393,12 @@ bool cmUVProcessChain::Valid() const return this->Data->Valid; } -bool cmUVProcessChain::Wait(int64_t milliseconds) +bool cmUVProcessChain::Wait(uint64_t milliseconds) { bool timeout = false; cm::uv_timer_ptr timer; - if (milliseconds >= 0) { + if (milliseconds > 0) { timer.init(*this->Data->Loop, &timeout); timer.start( [](uv_timer_t* handle) { diff --git a/Source/cmUVProcessChain.h b/Source/cmUVProcessChain.h index d7a4a0e..5ba1bf9 100644 --- a/Source/cmUVProcessChain.h +++ b/Source/cmUVProcessChain.h @@ -102,7 +102,7 @@ public: int ErrorStream(); bool Valid() const; - bool Wait(int64_t milliseconds = -1); + bool Wait(uint64_t milliseconds = 0); std::vector<const Status*> GetStatus() const; const Status& GetStatus(std::size_t index) const; bool Finished() const; |