From 9da7f08eb0f34f52561a62d7cf1004621b7d83c2 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Mon, 16 Jan 2023 17:51:57 +0100 Subject: Make file extensions abstract based on tool-chain type. --- src/tools.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/tools.h') 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 #include #include +#include #include "ctor.h" @@ -94,3 +95,27 @@ std::vector to_strings(ctor::toolchain toolchain, const ctor::ar_flag& flag); std::vector 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); -- cgit v1.2.3