fix(cli): resolve the project and build roots to absolute paths
Actions run with their own working directory, so a relative
--build-dir (as CI passes) left relative source paths in the graph and
a dependency's snapshot sources could not be opened
('cc1plus: ... No such file or directory'). The build/test/install
commands now normalize both roots up front.
Verified locally: 'vbs install --build-dir build/repro-rel' failed
before and installs successfully now.
This commit is contained in:
1 parent
b6b9527c9c
commit
9d2165cade
1 file changed
+37
-4
+37
-4
@@ -453,9 +453,26 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
||||
jobs = static_cast<std::size_t>(parsed_jobs);
|
||||
}
|
||||
|
||||
const std::filesystem::path project_root{opts.project_arg};
|
||||
// Absolute roots: actions run with their own working directory, so relative
|
||||
// paths baked into the graph (e.g. a dependency's snapshot sources) would not
|
||||
// resolve.
|
||||
std::error_code root_ec;
|
||||
const std::filesystem::path project_root =
|
||||
std::filesystem::absolute(opts.project_arg, root_ec).lexically_normal();
|
||||
if (root_ec) {
|
||||
std::cerr << cmd_name << ": cannot resolve project directory '"
|
||||
<< opts.project_arg << "': " << root_ec.message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
const std::filesystem::path build_root =
|
||||
opts.build_arg ? std::filesystem::path{*opts.build_arg} : (project_root / "build");
|
||||
opts.build_arg
|
||||
? std::filesystem::absolute(*opts.build_arg, root_ec).lexically_normal()
|
||||
: (project_root / "build");
|
||||
if (root_ec) {
|
||||
std::cerr << cmd_name << ": cannot resolve build directory '" << *opts.build_arg
|
||||
<< "': " << root_ec.message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
auto trusted_keys =
|
||||
combine_trusted_keys(opts.trusted_public_keys, opts.trusted_key_files, project_root);
|
||||
if (!trusted_keys) {
|
||||
@@ -2582,9 +2599,25 @@ int execute_install_command(const InstallCmdOptions &opts) {
|
||||
}
|
||||
}
|
||||
|
||||
const std::filesystem::path project_root{opts.project_arg};
|
||||
// Absolute roots: the self-hosted dependency build runs actions with their
|
||||
// own working directory, so relative graph paths would not resolve.
|
||||
std::error_code root_ec;
|
||||
const std::filesystem::path project_root =
|
||||
std::filesystem::absolute(opts.project_arg, root_ec).lexically_normal();
|
||||
if (root_ec) {
|
||||
std::cerr << "vbs install: cannot resolve project directory '" << opts.project_arg
|
||||
<< "': " << root_ec.message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
const std::filesystem::path build_root =
|
||||
opts.build_arg ? std::filesystem::path{*opts.build_arg} : (project_root / "build");
|
||||
opts.build_arg
|
||||
? std::filesystem::absolute(*opts.build_arg, root_ec).lexically_normal()
|
||||
: (project_root / "build");
|
||||
if (root_ec) {
|
||||
std::cerr << "vbs install: cannot resolve build directory '" << *opts.build_arg
|
||||
<< "': " << root_ec.message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
Install::InstallOptions iopts;
|
||||
iopts.prefix = *opts.prefix_arg;
|
||||
|
||||
Reference in new issue
Block a user