- [NEW] Permet compilar en directoris recursius, exemple: "source+"
This commit is contained in:
76
main.cpp
76
main.cpp
@@ -301,37 +301,81 @@ int main(int argc, char *argv[])
|
|||||||
std::filesystem::create_directory(build_path);
|
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
|
recursive = true;
|
||||||
std::replace(src_path.begin(), src_path.end(), '/', '\\');
|
src_path.pop_back();
|
||||||
#endif
|
}
|
||||||
|
|
||||||
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);
|
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);
|
exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
std::string path = "." + folder_char + src_path;
|
else
|
||||||
for (const auto & entry : std::filesystem::directory_iterator(path))
|
{
|
||||||
|
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 source_file = entry.path().string();
|
||||||
std::string file_extension = getFileExtension(source_file);
|
std::string ext = getFileExtension(source_file);
|
||||||
if (file_extension=="cpp" || file_extension=="c")
|
|
||||||
|
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)
|
if (must_link)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user