Skip to content

Commit

Permalink
feat: allow c++ sources outside src dir (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy authored Mar 31, 2024
1 parent 9b8aed9 commit 431c80b
Show file tree
Hide file tree
Showing 3 changed files with 358 additions and 416 deletions.
2 changes: 1 addition & 1 deletion ecsact/cli/commands/build/build_recipe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static auto parse_sources( //
}
result.emplace_back(source_path{
.path = path,
.outdir = "src",
.outdir = ".",
});
}
}
Expand Down
38 changes: 36 additions & 2 deletions ecsact/cli/commands/build/recipe/cook.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,37 @@ static auto download_file(boost::url url, fs::path out_file_path) -> int {
#endif
}

static auto is_cpp_file(fs::path p) -> bool {
if(!p.has_extension()) {
return false;
}

constexpr auto valid_extensions = std::array{
".c",
".cc",
".cpp",
".cxx",
".c++",
".C",
".h",
".hh",
".hpp",
".hxx",
".ipp",
".inc",
".inl",
".H",
};

for(auto extension : valid_extensions) {
if(p.extension() == extension) {
return true;
}
}

return false;
}

static auto handle_source( //
ecsact::build_recipe::source_fetch src,
const ecsact::cli::cook_recipe_options& options
Expand Down Expand Up @@ -577,7 +608,7 @@ auto ecsact::cli::cook_recipe( //

ecsact::cli::report_info("Compiling {}", output_path.string());

auto src_dir = recipe_options.work_dir / "src";
auto src_dir = recipe_options.work_dir;
auto inc_dir = recipe_options.work_dir / "include";

auto inc_dirs = std::vector{inc_dir};
Expand All @@ -592,7 +623,10 @@ auto ecsact::cli::cook_recipe( //
if(!entry.is_regular_file()) {
continue;
}
source_files.emplace_back(entry.path());

if(is_cpp_file(entry)) {
source_files.emplace_back(entry.path());
}
}

if(source_files.empty()) {
Expand Down
Loading

0 comments on commit 431c80b

Please # to comment.