diff --git a/main.cpp b/main.cpp index edbf673..00556d4 100644 --- a/main.cpp +++ b/main.cpp @@ -320,9 +320,17 @@ bool HeadersNeedRecompile(FileInfo file, std::filesystem::file_time_type object_ return false; } -bool MustRecompile(FileInfo file) { - std::string object_file = build_path + folder_char + std::filesystem::path(file.filename).stem().string() + ".o"; +std::string generate_object_file_name(std::string filename) { + std::filesystem::path cwd = std::filesystem::weakly_canonical(std::filesystem::current_path()); + std::filesystem::path target = std::filesystem::weakly_canonical(filename); + std::string out = std::filesystem::relative(target, cwd).replace_extension("o").generic_string(); + for (char& c : out) if (c == folder_char[0]) c = '.'; + return build_path + folder_char + out; +} +bool MustRecompile(FileInfo file) { + std::string object_file = generate_object_file_name(file.filename); + // si el objecte no existeix, fa falta recompilar if (!std::filesystem::exists(object_file)) { return true; @@ -342,7 +350,7 @@ bool MustRecompile(FileInfo file) { } void Recompile(std::string source_file) { - std::string object_file = build_path + folder_char + std::filesystem::path(source_file).stem().string() + ".o"; + std::string object_file = generate_object_file_name(source_file); must_link = true; std::string command = compiler + " " + source_file + " " + cppflags + " -c -o " + object_file; //std::cout << command << std::endl; diff --git a/version.h b/version.h index c6817ab..9856c92 100644 --- a/version.h +++ b/version.h @@ -1,3 +1,3 @@ #pragma once -#define LAGUEIRTO_VERSION "2.1.1" +#define LAGUEIRTO_VERSION "2.1.2"