diff options
author | Roland Reichwein <mail@reichwein.it> | 2024-05-12 16:07:53 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2024-05-12 16:07:53 +0200 |
commit | 8a4dfbbbe76a2aef35427b7915d6e28bab165c43 (patch) | |
tree | 5df3fe373ca755d51d8b06b7515ca3c296f54cc6 /LanguageSettings.cpp | |
parent | a7e016c2c633667b561a0f26ebde88cb26571d1c (diff) |
Build static and dynamic libs
Diffstat (limited to 'LanguageSettings.cpp')
-rw-r--r-- | LanguageSettings.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/LanguageSettings.cpp b/LanguageSettings.cpp index 8da144f..5eae731 100644 --- a/LanguageSettings.cpp +++ b/LanguageSettings.cpp @@ -74,7 +74,6 @@ std::string LanguageSettings::getLinkCommand(const std::filesystem::path& target const std::vector<std::filesystem::path> &inputs, const std::vector<std::string>& link_libs) const { - std::string input_string{std::accumulate(inputs.begin(), inputs.end(), std::string{}, [](const std::string& sum, const fs::path& p){ return sum + " " + p.string(); })}; @@ -84,11 +83,10 @@ std::string LanguageSettings::getLinkCommand(const std::filesystem::path& target AR, target.string(), input_string); - } else { + } else if (is_executable_target(target) || is_dynamic_lib(target)) { // dynamic link: -shared -Wl,-soname,libXXX.so.N -o libXXX.so.N.M.O - std::string LDFLAGS_add{is_dynamic_lib(target) ? fmt::format(" -shared -Wl,-soname,{} -o {}", - soname_shorter(target.string()).string(), - target.string()) : ""s}; + std::string LDFLAGS_add{is_dynamic_lib(target) ? fmt::format(" -shared -Wl,-soname,{}", + soname_shorter(target.string()).string()) : ""s}; std::string link_libs_string{std::accumulate(link_libs.begin(), link_libs.end(), std::string(), [](const std::string& sum, const std::string& i){ return sum + " -l" + i; })}; @@ -103,6 +101,14 @@ std::string LanguageSettings::getLinkCommand(const std::filesystem::path& target LIBS.empty() ? ""s : (" "s + LIBS), link_libs_string, target.string()); + } else if (is_dynamic_lib_link(target)) { + // special case for dynamic libs: add links + if (inputs.size() != 1) { + throw std::runtime_error("For symlink "s + target.string() + ", can link to exactly one file, found "s + std::to_string(inputs.size())); + } + return fmt::format("ln -sf {} {}", inputs[0].filename().string(), target.string()); + } else { + throw std::runtime_error("No implementation for target type: "s + target.string()); } } @@ -116,8 +122,6 @@ std::string LanguageSettings::getDepCommand(const std::filesystem::path& target, // variables: // CC // CFLAGS -// AR // ARFLAGS // AS // ASFLAGS -// dynamic lib: |