diff --git a/ecsact/cli/commands/build/build_recipe.cc b/ecsact/cli/commands/build/build_recipe.cc index 63e9512..cbf1115 100644 --- a/ecsact/cli/commands/build/build_recipe.cc +++ b/ecsact/cli/commands/build/build_recipe.cc @@ -473,7 +473,7 @@ auto ecsact::build_recipe::merge( // if(std::holds_alternative(src)) { source_path src_path = std::get(src); if(!src_path.path.is_absolute()) { - src_path.path = fs::relative( + src_path.path = fs::proximate( target.base_directory() / src_path.path, base.base_directory() ); diff --git a/ecsact/cli/commands/build/recipe/cook.cc b/ecsact/cli/commands/build/recipe/cook.cc index 8af7a46..2d346d4 100644 --- a/ecsact/cli/commands/build/recipe/cook.cc +++ b/ecsact/cli/commands/build/recipe/cook.cc @@ -309,25 +309,34 @@ static auto handle_source( // } for(auto path : paths) { - if(!fs::exists(src_path)) { + if(!fs::exists(path)) { ecsact::cli::report_error( "Source file {} does not exist", - src_path.generic_string() + path.generic_string() ); return 1; } + if(fs::is_directory(path)) { + ecsact::cli::report_warning( + "Ignoring directory source {} ", + path.generic_string() + ); + continue; + } auto rel_outdir = outdir; - if(auto stripped = path_strip_prefix(src_path, before_glob)) { + if(auto stripped = path_strip_prefix(path, before_glob)) { rel_outdir = outdir / *stripped; } + rel_outdir = rel_outdir.lexically_normal(); + fs::create_directories(rel_outdir, ec); - fs::copy(src_path, rel_outdir, ec); + fs::copy(path, rel_outdir, ec); if(ec) { ecsact::cli::report_error( "Failed to copy source {} to {}: {}", - src_path.generic_string(), + path.generic_string(), rel_outdir.generic_string(), ec.message() ); @@ -339,6 +348,13 @@ static auto handle_source( // rel_outdir.generic_string() ); } + + ecsact::cli::report_info( + "Copied {} to {}", + path.string(), + rel_outdir.string(), + ec.message() + ); } return 0; diff --git a/ecsact/cli/commands/recipe-bundle/build_recipe_bundle.cc b/ecsact/cli/commands/recipe-bundle/build_recipe_bundle.cc index 79a698c..e986491 100644 --- a/ecsact/cli/commands/recipe-bundle/build_recipe_bundle.cc +++ b/ecsact/cli/commands/recipe-bundle/build_recipe_bundle.cc @@ -296,11 +296,15 @@ auto ecsact::build_recipe_bundle::create( // return src; }, [&](build_recipe::source_path src) -> source_visitor_result_t { + auto src_path = src.path; + if(!src_path.is_absolute()) { + src_path = recipe.base_directory() / src.path; + } auto src_path_basename = src.path.filename(); auto archive_rel_path = (fs::path{"files"} / src.outdir.value_or(".") / src_path_basename) .lexically_normal(); - auto file_buffer = read_file(src.path); + auto file_buffer = read_file(src_path); if(!file_buffer) { return std::logic_error{"read file fail"};