瀏覽代碼

Function to collect library objects from a sdist/repo root

default_compile_flags
vector-of-bool 5 年之前
父節點
當前提交
84e19ec7ff
共有 2 個文件被更改,包括 30 次插入1 次删除
  1. +28
    -1
      src/dds/library.cpp
  2. +2
    -0
      src/dds/library.hpp

+ 28
- 1
src/dds/library.cpp 查看文件

@@ -1,9 +1,11 @@
#include <dds/library.hpp>

#include <dds/build/source_dir.hpp>
#include <dds/build/compile.hpp>
#include <dds/build/source_dir.hpp>
#include <dds/util/algo.hpp>

#include <range/v3/view/filter.hpp>
#include <range/v3/view/transform.hpp>
#include <spdlog/spdlog.h>

using namespace dds;
@@ -81,4 +83,29 @@ shared_compile_file_rules library::base_compile_rules() const noexcept {
ret.include_dirs().push_back(src_dir.path);
}
return ret;
}

auto has_library_dirs
= [](path_ref dir) { return fs::exists(dir / "src") || fs::exists(dir / "include"); };

std::vector<library> dds::collect_libraries(path_ref root, std::string_view basename) {
std::vector<library> ret;
if (has_library_dirs(root)) {
ret.emplace_back(library::from_directory(root, basename));
}

auto pf_libs_dir = root / "libs";

if (fs::is_directory(pf_libs_dir)) {
extend(ret,
fs::directory_iterator(pf_libs_dir) //
| ranges::views::filter(has_library_dirs) //
| ranges::views::transform([&](auto p) {
return library::from_directory(p,
fmt::format("{}-{}",
basename,
p.path().filename().string()));
}));
}
return ret;
}

+ 2
- 0
src/dds/library.hpp 查看文件

@@ -56,4 +56,6 @@ struct library_build_params {
shared_compile_file_rules compile_rules;
};

std::vector<library> collect_libraries(path_ref where, std::string_view basename);

} // namespace dds

Loading…
取消
儲存