| 156 | }; |
| 157 | |
| 158 | int32_t batchCompilation(const char* argv0, const fs::path& batchFile, |
| 159 | const fs::path& outputDir, bool nostdout) { |
| 160 | int32_t returnCode = 0; |
| 161 | |
| 162 | std::error_code ec; |
| 163 | const fs::path cwd = fs::current_path(ec); |
| 164 | if (ec) returnCode |= 1; |
| 165 | |
| 166 | std::ifstream stream; |
| 167 | stream.open(batchFile); |
| 168 | if (!stream.good()) { |
| 169 | returnCode |= 1; |
| 170 | return returnCode; |
| 171 | } |
| 172 | |
| 173 | std::string line; |
| 174 | int32_t count = 0; |
| 175 | SURELOG::ErrorContainer::Stats overallStats; |
| 176 | while (std::getline(stream, line)) { |
| 177 | if (line.empty()) continue; |
| 178 | if (!nostdout) |
| 179 | std::cout << "Processing: " << line << std::endl << std::flush; |
| 180 | |
| 181 | std::vector<std::string> args; |
| 182 | SURELOG::StringUtils::tokenize(line, " \r\t", args); |
| 183 | |
| 184 | if (!outputDir.empty()) { |
| 185 | fs::path cd; |
| 186 | int32_t odirIndex = -1; |
| 187 | for (size_t i = 0, n = args.size() - 1; i < n; i++) { |
| 188 | if (args[i] == cd_opt) { |
| 189 | cd = SURELOG::StringUtils::unquoted(args[++i]); |
| 190 | } else if (args[i] == output_folder_opt) { |
| 191 | odirIndex = ++i; |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | if (odirIndex >= 0) { |
| 196 | fs::path odir = args[odirIndex]; |
| 197 | if (odir.is_relative()) { |
| 198 | odir = outputDir / odir; |
| 199 | } |
| 200 | args[odirIndex] = odir.string(); |
| 201 | } else { |
| 202 | args.push_back("-o"); |
| 203 | args.push_back(outputDir.string()); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | std::vector<const char*> argv; |
| 208 | argv.reserve(args.size()); |
| 209 | argv.push_back(argv0); |
| 210 | for (const std::string& arg : args) { |
| 211 | if (!arg.empty()) { |
| 212 | argv.push_back(arg.c_str()); |
| 213 | } |
| 214 | } |
| 215 | if (argv.size() < 2) continue; |
no test coverage detected