From cd834760db7adec718ec0206de70433c67943492 Mon Sep 17 00:00:00 2001 From: Ezekiel Warren Date: Wed, 7 Aug 2024 08:48:56 -0700 Subject: [PATCH] fix: use absolute paths for vs extract batch * in unreal the temp directory passed to the CLI on windows uses '/' which caused the batch file to not be found --- ecsact/cli/commands/build/cc_compiler.cc | 39 ++++++++++++++++-------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/ecsact/cli/commands/build/cc_compiler.cc b/ecsact/cli/commands/build/cc_compiler.cc index dc63167..db0488a 100644 --- a/ecsact/cli/commands/build/cc_compiler.cc +++ b/ecsact/cli/commands/build/cc_compiler.cc @@ -1,11 +1,11 @@ #include "ecsact/cli/commands/build/cc_compiler.hh" #include -#include +#include +#include #include #include #include "nlohmann/json.hpp" -#include "magic_enum.hpp" #include "ecsact/cli/commands/build/cc_compiler.hh" #include "ecsact/cli/commands/build/cc_compiler_util.hh" #include "ecsact/cli/report.hh" @@ -115,13 +115,16 @@ static auto vsdevcmd_env_var( const fs::path& vsdevcmd_path, const std::string& env_var_name ) -> std::vector { + auto proc_env = boost::this_process::environment(); auto result = std::vector{}; - auto is = bp::ipstream{}; + auto std_is = bp::ipstream{}; + auto err_is = bp::ipstream{}; auto extract_script_proc = bp::child{ - vsdevcmd_path.string(), + fs::absolute(vsdevcmd_path).string(), bp::args({env_var_name}), - bp::std_out > is, - bp::std_err > bp::null, + bp::std_out > std_is, + bp::std_err > err_is, + bp::std_in < bp::null, }; auto subcommand_id = @@ -132,19 +135,29 @@ static auto vsdevcmd_env_var( .arguments = {env_var_name}, }); - auto var = std::string{}; - while(std::getline(is, var, ';')) { - boost::trim_right(var); - if(!var.empty()) { - result.emplace_back(var); + auto line = std::string{}; + while(std::getline(std_is, line, ';')) { + boost::trim_right(line); + if(!line.empty()) { + result.emplace_back(line); + } + } + + while(std::getline(err_is, line)) { + boost::trim(line); + if(!line.empty()) { + ecsact::cli::report(ecsact::cli::subcommand_stderr_message{ + .id = subcommand_id, + .line = line + }); } } - extract_script_proc.detach(); + extract_script_proc.wait(); ecsact::cli::report(subcommand_end_message{ .id = subcommand_id, - .exit_code = 0, // We detached, so we don't have an exit code + .exit_code = extract_script_proc.exit_code(), }); return result;