Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: WIP trying to fix recipe paths #125

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ecsact/cli/commands/build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ auto ecsact::cli::detail::build_command( //

auto recipe_composite = std::optional<build_recipe>{};
auto recipe_paths = args.at("--recipe").asStringList();
for(auto& recipe_path_str : recipe_paths) {
ecsact::cli::report_warning("RECIPE PATH: {}", recipe_path_str);
}

for(auto& recipe_path_str : recipe_paths) {
auto builtin_path = resolve_builtin_recipe(recipe_path_str, argv);

Expand Down
25 changes: 21 additions & 4 deletions ecsact/cli/commands/build/build_recipe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,28 @@ auto ecsact::build_recipe::merge( //
for(auto& src : target._sources) {
if(std::holds_alternative<source_path>(src)) {
source_path src_path = std::get<source_path>(src);

if(!src_path.path.is_absolute()) {
src_path.path = fs::relative(
target.base_directory() / src_path.path,
base.base_directory()
ecsact::cli::report_warning(
"ORIGINAL SOURCE PATH: {}",
src_path.path.generic_string()
);

src_path.path =
fs::relative(target.base_directory(), base.base_directory()) /
fs::relative(src_path.path, target.base_directory());

ecsact::cli::report_warning(
"NEW SOURCE PATH: {}",
src_path.path.generic_string()
);
ecsact::cli::report_warning(
"TARGET DIR: {}",
target.base_directory().generic_string()
);
ecsact::cli::report_warning(
"BASE DIR: {}",
base.base_directory().generic_string()
);
}

Expand All @@ -475,7 +493,6 @@ auto ecsact::build_recipe::merge( //
fs::relative(target.base_directory() / plugin).generic_string();
}
}

merged_build_recipe._sources.emplace_back(src_codegen);
} else {
merged_build_recipe._sources.push_back(src);
Expand Down
20 changes: 15 additions & 5 deletions ecsact/cli/commands/build/recipe/cook.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ static auto write_file(fs::path path, std::span<std::byte> data) -> void {
}

static auto handle_source( //
fs::path base_directory,
ecsact::build_recipe::source_fetch src,
const ecsact::cli::cook_recipe_options& options
) -> int {
Expand Down Expand Up @@ -239,6 +240,7 @@ static auto handle_source( //
}

static auto handle_source( //
fs::path base_directory,
ecsact::build_recipe::source_codegen src,
const ecsact::cli::cook_recipe_options& options
) -> int {
Expand Down Expand Up @@ -275,6 +277,7 @@ static auto handle_source( //
}

static auto handle_source( //
fs::path base_directory,
ecsact::build_recipe::source_path src,
const ecsact::cli::cook_recipe_options& options
) -> int {
Expand All @@ -285,8 +288,8 @@ static auto handle_source( //
auto ec = std::error_code{};
fs::create_directories(outdir, ec);

auto before_glob = path_before_glob(src.path);
auto paths = expand_path_globs(src.path, ec);
auto before_glob = path_before_glob(base_directory / src.path);
auto paths = expand_path_globs(base_directory / src.path, ec);
if(ec) {
ecsact::cli::report_error(
"Failed to glob {}: {}",
Expand All @@ -297,7 +300,12 @@ static auto handle_source( //
}

for(auto path : paths) {
if(!fs::exists(src.path)) {
if(!fs::exists(base_directory / src.path)) {
ecsact::cli::report_warning(
"Current path: {}",
fs::current_path().generic_string()
);

ecsact::cli::report_error(
"Source file {} does not exist",
src.path.generic_string()
Expand All @@ -310,7 +318,7 @@ static auto handle_source( //
}

fs::create_directories(rel_outdir, ec);
fs::copy(src.path, rel_outdir, ec);
fs::copy(base_directory / src.path, rel_outdir, ec);

if(ec) {
ecsact::cli::report_error(
Expand Down Expand Up @@ -707,7 +715,9 @@ auto ecsact::cli::cook_recipe( //

for(auto& src : recipe.sources()) {
exit_code = std::visit(
[&](auto& src) { return handle_source(src, recipe_options); },
[&](auto& src) {
return handle_source(recipe.base_directory(), src, recipe_options);
},
src
);

Expand Down