diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2023-06-08 12:50:10 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2023-08-29 14:51:30 (GMT) |
commit | ec124582acf966db9e6ddb226b53021fe6be591a (patch) | |
tree | bd0b3056158f944b5469aa364cd7720e83acd766 /Source/cmcmd.cxx | |
parent | 5420639a8d696055577de638e0952d6936706f18 (diff) | |
download | CMake-ec124582acf966db9e6ddb226b53021fe6be591a.zip CMake-ec124582acf966db9e6ddb226b53021fe6be591a.tar.gz CMake-ec124582acf966db9e6ddb226b53021fe6be591a.tar.bz2 |
cmProcessTools::RunProcess(): Replace cmsysProcess with cmUVProcessChain
And convert the VCS code to std::vector<std::string>.
Diffstat (limited to 'Source/cmcmd.cxx')
-rw-r--r-- | Source/cmcmd.cxx | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 2ac9d8e..1263bb2 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -28,6 +28,7 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTransformDepfile.h" +#include "cmUVHandlePtr.h" #include "cmUVProcessChain.h" #include "cmUVStream.h" #include "cmUtils.hxx" @@ -295,14 +296,8 @@ int CLCompileAndDependencies(const std::vector<std::string>& args) } } - std::unique_ptr<cmsysProcess, void (*)(cmsysProcess*)> cp( - cmsysProcess_New(), cmsysProcess_Delete); - std::vector<const char*> argv(command.size() + 1); - std::transform(command.begin(), command.end(), argv.begin(), - [](std::string const& s) { return s.c_str(); }); - argv.back() = nullptr; - cmsysProcess_SetCommand(cp.get(), argv.data()); - cmsysProcess_SetWorkingDirectory(cp.get(), currentBinaryDir.c_str()); + cmUVProcessChainBuilder builder; + builder.AddCommand(command).SetWorkingDirectory(currentBinaryDir); cmsys::ofstream fout(depFile.c_str()); if (!fout) { @@ -313,22 +308,18 @@ int CLCompileAndDependencies(const std::vector<std::string>& args) CLOutputLogger errLogger(std::cerr); // Start the process. - cmProcessTools::RunProcess(cp.get(), &includeParser, &errLogger); + auto result = + cmProcessTools::RunProcess(builder, &includeParser, &errLogger); + auto const& subStatus = result.front(); int status = 0; // handle status of process - switch (cmsysProcess_GetState(cp.get())) { - case cmsysProcess_State_Exited: - status = cmsysProcess_GetExitValue(cp.get()); - break; - case cmsysProcess_State_Exception: - status = 1; - break; - case cmsysProcess_State_Error: - status = 2; - break; - default: - break; + if (subStatus.SpawnResult != 0) { + status = 2; + } else if (subStatus.TermSignal != 0) { + status = 1; + } else { + status = subStatus.ExitStatus; } if (status != 0) { |