summaryrefslogtreecommitdiff
path: root/src/tools.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools.h')
-rw-r--r--src/tools.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/tools.h b/src/tools.h
index b1285ec..4fb6302 100644
--- a/src/tools.h
+++ b/src/tools.h
@@ -6,6 +6,7 @@
#include <vector>
#include <string>
#include <ostream>
+#include <filesystem>
#include "ctor.h"
@@ -94,3 +95,27 @@ std::vector<std::string> to_strings(ctor::toolchain toolchain,
const ctor::ar_flag& flag);
std::vector<std::string> to_strings(ctor::toolchain toolchain,
const ctor::asm_flag& flag);
+
+
+// Get target type from file extension
+// If toolchain is not ::any only extensions for that toolchain will be accepted
+// If no match is found ::unknown will be returned.
+ctor::target_type target_type_from_extension(ctor::toolchain toolchain,
+ const std::filesystem::path& file);
+
+
+// Get appropriate extension from original extension and target type using
+// the toolchain.
+// ie. { gcc, static_lib, ".lib" } will return ".a"
+// { msvc, dynamic_lib, ".dylib" } will return ".dll"
+// ...
+// If the supplied extension is normal for the supplied type and toolchain, then this is used, otherwise a conversion to the default extension to the given toolchain and type is given.
+// The defaults for the toolchains are as follows:
+// toolchain executable static-lib dynamic-lib
+// gcc (none) .a .so(.dylib on macos)
+// clang (none) .a .so(.dylib on macos)
+// msvc .exe .lib .dll
+// mingw .exe .lib .dll
+std::filesystem::path extension(ctor::toolchain toolchain,
+ ctor::target_type target_type,
+ const std::filesystem::path& file);