MCPcopy Create free account
hub / github.com/Kitware/CMake / RunMakeCommand

Method RunMakeCommand

Source/cmCTest.cxx:900–1009  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

898}
899
900bool cmCTest::RunMakeCommand(std::string const& command, std::string& output,
901 int* retVal, char const* dir, cmDuration timeout,
902 std::ostream& ofs, Encoding encoding)
903{
904 // First generate the command and arguments
905 std::vector<std::string> args = cmSystemTools::ParseArguments(command);
906
907 if (args.empty()) {
908 return false;
909 }
910
911 output.clear();
912 cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Run command:");
913 for (auto const& arg : args) {
914 cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, " \"" << arg << "\"");
915 }
916 cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, std::endl);
917
918 // Now create process object
919 cmUVProcessChainBuilder builder;
920 builder.AddCommand(args).SetMergedBuiltinStreams();
921 if (dir) {
922 builder.SetWorkingDirectory(dir);
923 }
924 auto chain = builder.Start();
925 uv_stream_t* outputStream = chain.OutputStream();
926
927 // Initialize tick's
928 std::string::size_type tick = 0;
929 std::string::size_type tick_len = 1024;
930 std::string::size_type tick_line_len = 50;
931
932 cmProcessOutput processOutput(encoding);
933 cmCTestLog(this, HANDLER_PROGRESS_OUTPUT,
934 " Each . represents " << tick_len
935 << " bytes of output\n"
936 " "
937 << std::flush);
938 auto outputHandle = cmUVStreamRead(
939 outputStream,
940 [this, &processOutput, &output, &tick, &tick_len, &tick_line_len,
941 &ofs](std::vector<char> data) {
942 std::string strdata;
943 processOutput.DecodeText(data.data(), data.size(), strdata);
944 for (char& cc : strdata) {
945 if (cc == 0) {
946 cc = '\n';
947 }
948 }
949 output.append(strdata);
950 while (output.size() > (tick * tick_len)) {
951 tick++;
952 cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, "." << std::flush);
953 if (tick % tick_line_len == 0 && tick > 0) {
954 cmCTestLog(this, HANDLER_PROGRESS_OUTPUT,
955 " Size: " << int((double(output.size()) / 1024.0) + 1)
956 << "K\n " << std::flush);
957 }

Callers

nothing calls this directly

Calls 15

cmUVStreamReadFunction · 0.85
OutputStreamMethod · 0.80
DecodeTextMethod · 0.80
appendMethod · 0.80
GetStatusMethod · 0.80
GetExceptionMethod · 0.80
TerminateMethod · 0.80
emptyMethod · 0.45
clearMethod · 0.45
AddCommandMethod · 0.45
SetWorkingDirectoryMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected