- [NEW] Permet compilar en directoris recursius, exemple: "source+"

This commit is contained in:
2026-04-01 16:54:49 +02:00
parent d8f884957d
commit 7f018ba2a9

View File

@@ -301,37 +301,81 @@ int main(int argc, char *argv[])
std::filesystem::create_directory(build_path);
}
auto source_paths = split(source_path);
auto source_paths = split(source_path);
for (auto src_path : source_paths)
for (auto src_path : source_paths)
{
bool recursive = false;
if (!src_path.empty() && src_path.back() == '+')
{
#ifdef _WIN32
std::replace(src_path.begin(), src_path.end(), '/', '\\');
#endif
recursive = true;
src_path.pop_back();
}
if (!std::filesystem::is_directory(src_path))
#ifdef _WIN32
std::replace(src_path.begin(), src_path.end(), '/', '\\');
#endif
if (!std::filesystem::is_directory(src_path))
{
if (std::filesystem::is_regular_file(src_path))
{
if (std::filesystem::is_regular_file(src_path) && getFileExtension(src_path)=="cpp")
std::string ext = getFileExtension(src_path);
if (ext == "cpp" || ext == "c")
{
MaybeRecompile(src_path);
} else {
std::cout << "ERROR: '" << src_path <<"' does not exists." << std::endl;
}
else
{
std::cout << "ERROR: '" << src_path << "' is not a .c/.cpp file." << std::endl;
exit(1);
}
} else {
std::string path = "." + folder_char + src_path;
for (const auto & entry : std::filesystem::directory_iterator(path))
}
else
{
std::cout << "ERROR: '" << src_path << "' does not exist." << std::endl;
exit(1);
}
}
else
{
std::string path = "." + folder_char + src_path;
if (recursive)
{
for (const auto &entry : std::filesystem::recursive_directory_iterator(path))
{
if (!entry.is_regular_file()) continue;
std::string source_file = entry.path().string();
std::string file_extension = getFileExtension(source_file);
if (file_extension=="cpp" || file_extension=="c")
std::string ext = getFileExtension(source_file);
if ((ext == "cpp" || ext == "c") &&
!contains(exclude, entry.path().filename()))
{
if (!contains(exclude, entry.path().filename()))
MaybeRecompile(source_file);
MaybeRecompile(source_file);
}
}
}
else
{
for (const auto &entry : std::filesystem::directory_iterator(path))
{
if (!entry.is_regular_file()) continue;
std::string source_file = entry.path().string();
std::string ext = getFileExtension(source_file);
if ((ext == "cpp" || ext == "c") &&
!contains(exclude, entry.path().filename()))
{
MaybeRecompile(source_file);
}
}
}
}
}
if (must_link)
{