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 /file.cpp | |
parent | a7e016c2c633667b561a0f26ebde88cb26571d1c (diff) |
Build static and dynamic libs
Diffstat (limited to 'file.cpp')
-rw-r--r-- | file.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -16,7 +16,7 @@ const fs::path YMakefile{"YMakefile"}; // type of file can be built from dependencies bool is_buildable_by_extension(const fs::path& p) { fs::path ext{p.extension()}; - return ext.empty() || ext == ".o" || is_dynamic_lib(p) || is_static_lib(p) ; + return ext.empty() || ext == ".o" || is_dynamic_lib(p) || is_dynamic_lib_link(p) || is_static_lib(p) ; } namespace { @@ -29,6 +29,11 @@ bool is_compile_unit_source_by_extension(const fs::path& p) { return compile_unit_source_types.find(ext) != compile_unit_source_types.end(); } +bool is_executable_target(const std::filesystem::path& p) +{ + return p.extension().empty(); +} + // e.g. libxyz.so.1.2.3 (the shorter versions are links to this one) bool is_dynamic_lib(const std::filesystem::path& p) { @@ -36,6 +41,13 @@ bool is_dynamic_lib(const std::filesystem::path& p) return name.find(".so.") != name.npos && std::count(name.begin(), name.end(), '.') == 4; } +// e.g. libxyz.so.1 libxyz.so +bool is_dynamic_lib_link(const std::filesystem::path& p) +{ + std::string name{p.filename()}; + return name.find(".so") != name.npos && std::count(name.begin(), name.end(), '.') < 4; +} + // in: libxyz.so.1.2.3 // out: libxyz.so.1 std::filesystem::path soname_shorter(const std::filesystem::path& p) @@ -95,7 +107,7 @@ std::filesystem::path simplified_path(const std::filesystem::path& p) return p; } -bool is_executable(const std::string& file) { +bool is_executable_command(const std::string& file) { std::vector<std::string> paths {Reichwein::Stringhelper::split(env_value("PATH"), ":")}; for (const auto& i: paths) { |