From 8a4dfbbbe76a2aef35427b7915d6e28bab165c43 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 12 May 2024 16:07:53 +0200 Subject: Build static and dynamic libs --- file.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'file.cpp') diff --git a/file.cpp b/file.cpp index 6de8b07..31695e5 100644 --- a/file.cpp +++ b/file.cpp @@ -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 paths {Reichwein::Stringhelper::split(env_value("PATH"), ":")}; for (const auto& i: paths) { -- cgit v1.2.3