From 0f062681d515416b24273f007a777f948f4b5100 Mon Sep 17 00:00:00 2001 From: Ezekiel Warren Date: Tue, 6 Aug 2024 16:03:38 -0700 Subject: [PATCH 1/2] feat: report bad extractions as an error --- ecsact/cli/commands/build/cc_compiler.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ecsact/cli/commands/build/cc_compiler.cc b/ecsact/cli/commands/build/cc_compiler.cc index e4984b7..dc63167 100644 --- a/ecsact/cli/commands/build/cc_compiler.cc +++ b/ecsact/cli/commands/build/cc_compiler.cc @@ -132,14 +132,12 @@ static auto vsdevcmd_env_var( .arguments = {env_var_name}, }); - for(;;) { - std::string var; - std::getline(is, var, ';'); + auto var = std::string{}; + while(std::getline(is, var, ';')) { boost::trim_right(var); - if(var.empty()) { - break; + if(!var.empty()) { + result.emplace_back(var); } - result.emplace_back(std::move(var)); } extract_script_proc.detach(); @@ -288,7 +286,16 @@ static auto cc_vswhere( // }; auto standard_include_paths = vsdevcmd_env_varl("INCLUDE"); + if(standard_include_paths.empty()) { + ecsact::cli::report_error("Extracted INCLUDE paths is empty"); + return {}; + } + auto standard_lib_paths = vsdevcmd_env_varl("LIB"); + if(standard_lib_paths.empty()) { + ecsact::cli::report_error("Extracted LIB paths is empty"); + return {}; + } // https://github.com/microsoft/vswhere/wiki/Find-VC auto version_text_path = std::format( From cd834760db7adec718ec0206de70433c67943492 Mon Sep 17 00:00:00 2001 From: Ezekiel Warren Date: Wed, 7 Aug 2024 08:48:56 -0700 Subject: [PATCH 2/2] 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;