Parcourir la source

Function to collect library objects from a sdist/repo root

default_compile_flags
vector-of-bool il y a 5 ans
Parent
révision
84e19ec7ff
2 fichiers modifiés avec 30 ajouts et 1 suppressions
  1. +28
    -1
      src/dds/library.cpp
  2. +2
    -0
      src/dds/library.hpp

+ 28
- 1
src/dds/library.cpp Voir le fichier

@@ -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 Voir le fichier

@@ -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

Chargement…
Annuler
Enregistrer