diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2023-01-16 17:51:57 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2023-01-16 17:51:57 +0100 |
commit | 9da7f08eb0f34f52561a62d7cf1004621b7d83c2 (patch) | |
tree | 012a9620b5a52f7a1098d04a1cb6c45404e41e1b /src/tools.h | |
parent | a257c2f4d333969c73d8b27124e658db6430645a (diff) |
Make file extensions abstract based on tool-chain type.
Diffstat (limited to 'src/tools.h')
-rw-r--r-- | src/tools.h | 25 |
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); |