Skip to content

Commit 431c80b

Browse files
authored
feat: allow c++ sources outside src dir (#75)
1 parent 9b8aed9 commit 431c80b

File tree

3 files changed

+358
-416
lines changed

3 files changed

+358
-416
lines changed

ecsact/cli/commands/build/build_recipe.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static auto parse_sources( //
150150
}
151151
result.emplace_back(source_path{
152152
.path = path,
153-
.outdir = "src",
153+
.outdir = ".",
154154
});
155155
}
156156
}

ecsact/cli/commands/build/recipe/cook.cc

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,37 @@ static auto download_file(boost::url url, fs::path out_file_path) -> int {
123123
#endif
124124
}
125125

126+
static auto is_cpp_file(fs::path p) -> bool {
127+
if(!p.has_extension()) {
128+
return false;
129+
}
130+
131+
constexpr auto valid_extensions = std::array{
132+
".c",
133+
".cc",
134+
".cpp",
135+
".cxx",
136+
".c++",
137+
".C",
138+
".h",
139+
".hh",
140+
".hpp",
141+
".hxx",
142+
".ipp",
143+
".inc",
144+
".inl",
145+
".H",
146+
};
147+
148+
for(auto extension : valid_extensions) {
149+
if(p.extension() == extension) {
150+
return true;
151+
}
152+
}
153+
154+
return false;
155+
}
156+
126157
static auto handle_source( //
127158
ecsact::build_recipe::source_fetch src,
128159
const ecsact::cli::cook_recipe_options& options
@@ -577,7 +608,7 @@ auto ecsact::cli::cook_recipe( //
577608

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

580-
auto src_dir = recipe_options.work_dir / "src";
611+
auto src_dir = recipe_options.work_dir;
581612
auto inc_dir = recipe_options.work_dir / "include";
582613

583614
auto inc_dirs = std::vector{inc_dir};
@@ -592,7 +623,10 @@ auto ecsact::cli::cook_recipe( //
592623
if(!entry.is_regular_file()) {
593624
continue;
594625
}
595-
source_files.emplace_back(entry.path());
626+
627+
if(is_cpp_file(entry)) {
628+
source_files.emplace_back(entry.path());
629+
}
596630
}
597631

598632
if(source_files.empty()) {

0 commit comments

Comments
 (0)