1
1
#include " ecsact/cli/commands/build/cc_compiler.hh"
2
2
3
3
#include < filesystem>
4
- #include < cstddef>
4
+ #include < string>
5
+ #include < string_view>
5
6
#include < fstream>
6
7
#include < boost/process.hpp>
7
8
#include " nlohmann/json.hpp"
8
- #include " magic_enum.hpp"
9
9
#include " ecsact/cli/commands/build/cc_compiler.hh"
10
10
#include " ecsact/cli/commands/build/cc_compiler_util.hh"
11
11
#include " ecsact/cli/report.hh"
@@ -115,13 +115,16 @@ static auto vsdevcmd_env_var(
115
115
const fs::path& vsdevcmd_path,
116
116
const std::string& env_var_name
117
117
) -> std::vector<std::string> {
118
+ auto proc_env = boost::this_process::environment ();
118
119
auto result = std::vector<std::string>{};
119
- auto is = bp::ipstream{};
120
+ auto std_is = bp::ipstream{};
121
+ auto err_is = bp::ipstream{};
120
122
auto extract_script_proc = bp::child{
121
- vsdevcmd_path.string (),
123
+ fs::absolute ( vsdevcmd_path) .string (),
122
124
bp::args ({env_var_name}),
123
- bp::std_out > is,
124
- bp::std_err > bp::null,
125
+ bp::std_out > std_is,
126
+ bp::std_err > err_is,
127
+ bp::std_in < bp::null,
125
128
};
126
129
127
130
auto subcommand_id =
@@ -132,21 +135,29 @@ static auto vsdevcmd_env_var(
132
135
.arguments = {env_var_name},
133
136
});
134
137
135
- for (;;) {
136
- std::string var;
137
- std::getline (is, var, ' ;' );
138
- boost::trim_right (var);
139
- if (var.empty ()) {
140
- break ;
138
+ auto line = std::string{};
139
+ while (std::getline (std_is, line, ' ;' )) {
140
+ boost::trim_right (line);
141
+ if (!line.empty ()) {
142
+ result.emplace_back (line);
141
143
}
142
- result.emplace_back (std::move (var));
143
144
}
144
145
145
- extract_script_proc.detach ();
146
+ while (std::getline (err_is, line)) {
147
+ boost::trim (line);
148
+ if (!line.empty ()) {
149
+ ecsact::cli::report (ecsact::cli::subcommand_stderr_message{
150
+ .id = subcommand_id,
151
+ .line = line
152
+ });
153
+ }
154
+ }
155
+
156
+ extract_script_proc.wait ();
146
157
147
158
ecsact::cli::report (subcommand_end_message{
148
159
.id = subcommand_id,
149
- .exit_code = 0 , // We detached, so we don't have an exit code
160
+ .exit_code = extract_script_proc. exit_code (),
150
161
});
151
162
152
163
return result;
@@ -288,7 +299,16 @@ static auto cc_vswhere( //
288
299
};
289
300
290
301
auto standard_include_paths = vsdevcmd_env_varl (" INCLUDE" );
302
+ if (standard_include_paths.empty ()) {
303
+ ecsact::cli::report_error (" Extracted INCLUDE paths is empty" );
304
+ return {};
305
+ }
306
+
291
307
auto standard_lib_paths = vsdevcmd_env_varl (" LIB" );
308
+ if (standard_lib_paths.empty ()) {
309
+ ecsact::cli::report_error (" Extracted LIB paths is empty" );
310
+ return {};
311
+ }
292
312
293
313
// https://github.com/microsoft/vswhere/wiki/Find-VC
294
314
auto version_text_path = std::format (
0 commit comments