summaryrefslogtreecommitdiff
path: root/src/rebuild.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2022-07-31 13:31:27 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2022-07-31 13:34:54 +0200
commite1030dc6e69863438fe35a628bd6af9abc814b4a (patch)
tree004d6c9c22fe62dc77159f896b9ee0fae069dcb5 /src/rebuild.cc
parent809000494b2e0c34dc6ecae228c046c5eba2a820 (diff)
Convert absolute source_location paths to relative ones.
Diffstat (limited to 'src/rebuild.cc')
-rw-r--r--src/rebuild.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/rebuild.cc b/src/rebuild.cc
index a82e0cc..9ddf5ba 100644
--- a/src/rebuild.cc
+++ b/src/rebuild.cc
@@ -7,6 +7,7 @@
#include <filesystem>
#include <algorithm>
#include <source_location>
+#include <cstring>
#include "configure.h"
#include "libctor.h"
@@ -30,7 +31,17 @@ int reg(BuildConfigurations (*cb)(const Settings&),
exit(1);
}
- configFiles[numConfigFiles].file = location.file_name();
+ auto loc = std::filesystem::path(location.file_name());
+ if(loc.is_absolute())
+ {
+ auto pwd = std::filesystem::current_path();
+ auto rel = std::filesystem::relative(loc, pwd);
+ configFiles[numConfigFiles].file = strdup(rel.string().data()); // NOTE: This intentionally leaks memory
+ }
+ else
+ {
+ configFiles[numConfigFiles].file = location.file_name();
+ }
configFiles[numConfigFiles].cb = cb;
++numConfigFiles;