| 104 | } |
| 105 | |
| 106 | int cmInstallScriptHandler::Install(unsigned int j, |
| 107 | cmInstrumentation& instrumentation) |
| 108 | { |
| 109 | cm::uv_loop_ptr loop; |
| 110 | loop.init(); |
| 111 | std::vector<InstallScriptRunner> runners; |
| 112 | runners.reserve(this->scripts.size()); |
| 113 | |
| 114 | std::vector<std::string> instrument_arg; |
| 115 | if (instrumentation.HasQuery()) { |
| 116 | instrument_arg = { cmSystemTools::GetCTestCommand(), |
| 117 | "--instrument", |
| 118 | "--command-type", |
| 119 | "install", |
| 120 | "--build-dir", |
| 121 | this->binaryDir, |
| 122 | "--config", |
| 123 | "", |
| 124 | "--" }; |
| 125 | } |
| 126 | |
| 127 | for (auto& script : this->scripts) { |
| 128 | if (!instrument_arg.empty()) { |
| 129 | instrument_arg[7] = script.config; // --config <script.config> |
| 130 | } |
| 131 | script.command.insert(script.command.begin(), instrument_arg.begin(), |
| 132 | instrument_arg.end()); |
| 133 | runners.emplace_back(script); |
| 134 | } |
| 135 | std::size_t working = 0; |
| 136 | std::size_t installed = 0; |
| 137 | std::size_t i = 0; |
| 138 | |
| 139 | std::function<void()> queueScripts; |
| 140 | queueScripts = [&runners, &working, &installed, &i, &loop, j, |
| 141 | &queueScripts]() { |
| 142 | for (auto queue = std::min(j - working, runners.size() - i); queue > 0; |
| 143 | --queue) { |
| 144 | ++working; |
| 145 | runners[i].start(loop, |
| 146 | [&runners, &working, &installed, i, &queueScripts]() { |
| 147 | runners[i].printResult(++installed, runners.size()); |
| 148 | --working; |
| 149 | queueScripts(); |
| 150 | }); |
| 151 | ++i; |
| 152 | } |
| 153 | }; |
| 154 | queueScripts(); |
| 155 | uv_run(loop, UV_RUN_DEFAULT); |
| 156 | |
| 157 | // Write install manifest |
| 158 | std::string install_manifest; |
| 159 | if (this->component.empty()) { |
| 160 | install_manifest = "install_manifest.txt"; |
| 161 | } else { |
| 162 | cmsys::RegularExpression regEntry; |
| 163 | if (regEntry.compile("^[a-zA-Z0-9_.+-]+$") && |
nothing calls this directly
no test coverage detected