From ec955eb6726b31e26d17c34474619b60f3563194 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 15 Jun 2024 14:24:14 +0200 Subject: Automatically depend on YMakefile (rebuild if necessary), tests --- file.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'file.cpp') diff --git a/file.cpp b/file.cpp index 6211471..2284cb3 100644 --- a/file.cpp +++ b/file.cpp @@ -14,9 +14,9 @@ using namespace std::string_literals; const fs::path YMakefile{"YMakefile"}; // type of file can be built from dependencies -bool is_buildable_by_extension(const fs::path& p) { +bool is_buildable_by_name(const fs::path& p) { fs::path ext{p.extension()}; - return ext.empty() || ext == ".o" || is_dynamic_lib(p) || is_dynamic_lib_link(p) || is_static_lib(p) ; + return (ext.empty() || ext == ".o" || is_dynamic_lib(p) || is_dynamic_lib_link(p) || is_static_lib(p)) && p.filename() != YMakefile; } namespace { @@ -48,6 +48,16 @@ bool is_dynamic_lib_link(const std::filesystem::path& p) return name.find(".so") != name.npos && std::count(name.begin(), name.end(), '.') < 4; } +bool is_lib(const std::filesystem::path& p) +{ + return is_dynamic_lib(p) || is_static_lib(p) || is_dynamic_lib_link(p) || is_external_lib(p); +} + +bool is_linkable(const std::filesystem::path& p) +{ + return is_lib(p) || p.extension() == ".o"; +} + // in: libxyz.so.1.2.3 // out: libxyz.so.1 std::filesystem::path soname_shorter(const std::filesystem::path& p) @@ -119,7 +129,7 @@ bool is_static_lib(const std::filesystem::path& p) bool is_external_lib(const std::filesystem::path& p) { - return !(is_static_lib(p) || is_dynamic_lib(p) || is_dynamic_lib_link(p)); + return !(is_static_lib(p) || is_dynamic_lib(p) || is_dynamic_lib_link(p)) && p.filename() != YMakefile; } std::filesystem::path simplified_path(const std::filesystem::path& p) -- cgit v1.2.3