Browse Source

Range v0.11 compatibility

default_compile_flags
vector-of-bool 4 years ago
parent
commit
fe92d539cd
12 changed files with 47 additions and 35 deletions
  1. +1
    -0
      src/dds.main.cpp
  2. +1
    -0
      src/dds/build/file_deps.cpp
  3. +1
    -0
      src/dds/build/plan/archive.cpp
  4. +1
    -0
      src/dds/build/plan/compile_exec.cpp
  5. +1
    -0
      src/dds/build/plan/full.cpp
  6. +1
    -0
      src/dds/build/plan/library.cpp
  7. +9
    -8
      src/dds/catalog/catalog.cpp
  8. +3
    -2
      src/dds/library/root.cpp
  9. +15
    -24
      src/dds/repo/repo.cpp
  10. +1
    -0
      src/dds/source/dist.cpp
  11. +3
    -1
      src/dds/source/root.cpp
  12. +10
    -0
      src/dds/util/ranges.hpp

+ 1
- 0
src/dds.main.cpp View File

#include <dds/util/signal.hpp> #include <dds/util/signal.hpp>


#include <range/v3/action/join.hpp> #include <range/v3/action/join.hpp>
#include <range/v3/range/conversion.hpp>
#include <range/v3/view/concat.hpp> #include <range/v3/view/concat.hpp>
#include <range/v3/view/group_by.hpp> #include <range/v3/view/group_by.hpp>
#include <range/v3/view/transform.hpp> #include <range/v3/view/transform.hpp>

+ 1
- 0
src/dds/build/file_deps.cpp View File

#include <dds/util/shlex.hpp> #include <dds/util/shlex.hpp>
#include <dds/util/string.hpp> #include <dds/util/string.hpp>


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



+ 1
- 0
src/dds/build/plan/archive.cpp View File

#include <dds/util/log.hpp> #include <dds/util/log.hpp>
#include <dds/util/time.hpp> #include <dds/util/time.hpp>


#include <range/v3/range/conversion.hpp>
#include <range/v3/view/transform.hpp> #include <range/v3/view/transform.hpp>


using namespace dds; using namespace dds;

+ 1
- 0
src/dds/build/plan/compile_exec.cpp View File

#include <dds/util/string.hpp> #include <dds/util/string.hpp>
#include <dds/util/time.hpp> #include <dds/util/time.hpp>


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



+ 1
- 0
src/dds/build/plan/full.cpp View File

#include <dds/error/errors.hpp> #include <dds/error/errors.hpp>
#include <dds/util/parallel.hpp> #include <dds/util/parallel.hpp>


#include <range/v3/range/conversion.hpp>
#include <range/v3/view/concat.hpp> #include <range/v3/view/concat.hpp>
#include <range/v3/view/filter.hpp> #include <range/v3/view/filter.hpp>
#include <range/v3/view/join.hpp> #include <range/v3/view/join.hpp>

+ 1
- 0
src/dds/build/plan/library.cpp View File

#include <dds/util/algo.hpp> #include <dds/util/algo.hpp>
#include <dds/util/log.hpp> #include <dds/util/log.hpp>


#include <range/v3/range/conversion.hpp>
#include <range/v3/view/concat.hpp> #include <range/v3/view/concat.hpp>
#include <range/v3/view/filter.hpp> #include <range/v3/view/filter.hpp>
#include <range/v3/view/transform.hpp> #include <range/v3/view/transform.hpp>

+ 9
- 8
src/dds/catalog/catalog.cpp View File

#include <dds/error/errors.hpp> #include <dds/error/errors.hpp>
#include <dds/solve/solve.hpp> #include <dds/solve/solve.hpp>
#include <dds/util/log.hpp> #include <dds/util/log.hpp>
#include <dds/util/ranges.hpp>


#include <json5/parse_data.hpp> #include <json5/parse_data.hpp>
#include <neo/assert.hpp> #include <neo/assert.hpp>
}; };


std::vector<package_id> catalog::all() const noexcept { std::vector<package_id> catalog::all() const noexcept {
return sqlite3::exec_iter<std::string, std::string>( //
return view_safe(sqlite3::exec_iter<std::string, std::string>( //
_stmt_cache, _stmt_cache,
"SELECT name, version FROM dds_cat_pkgs"_sql)
"SELECT name, version FROM dds_cat_pkgs"_sql))
| ranges::views::transform(pair_to_pkg_id) // | ranges::views::transform(pair_to_pkg_id) //
| ranges::to_vector; | ranges::to_vector;
} }


std::vector<package_id> catalog::by_name(std::string_view sv) const noexcept { std::vector<package_id> catalog::by_name(std::string_view sv) const noexcept {
return sqlite3::exec_iter<std::string, std::string>( //
return view_safe(sqlite3::exec_iter<std::string, std::string>( //
_stmt_cache, _stmt_cache,
R"( R"(
SELECT name, version SELECT name, version
FROM dds_cat_pkgs FROM dds_cat_pkgs
WHERE name = ? WHERE name = ?
)"_sql, )"_sql,
std::tie(sv)) //
std::tie(sv))) //
| ranges::views::transform(pair_to_pkg_id) // | ranges::views::transform(pair_to_pkg_id) //
| ranges::to_vector; | ranges::to_vector;
} }


std::vector<dependency> catalog::dependencies_of(const package_id& pkg) const noexcept { std::vector<dependency> catalog::dependencies_of(const package_id& pkg) const noexcept {
dds_log(trace, "Lookup dependencies of {}@{}", pkg.name, pkg.version.to_string()); dds_log(trace, "Lookup dependencies of {}@{}", pkg.name, pkg.version.to_string());
return sqlite3::exec_iter<std::string,
std::string,
std::string>( //
return view_safe(sqlite3::exec_iter<std::string,
std::string,
std::string>( //
_stmt_cache, _stmt_cache,
R"( R"(
WITH this_pkg_id AS ( WITH this_pkg_id AS (
WHERE pkg_id IN this_pkg_id WHERE pkg_id IN this_pkg_id
ORDER BY dep_name ORDER BY dep_name
)"_sql, )"_sql,
std::forward_as_tuple(pkg.name, pkg.version.to_string())) //
std::forward_as_tuple(pkg.name, pkg.version.to_string()))) //
| ranges::views::transform([](auto&& pair) { | ranges::views::transform([](auto&& pair) {
auto& [name, low, high] = pair; auto& [name, low, high] = pair;
auto dep auto dep

+ 3
- 2
src/dds/library/root.cpp View File

#include <dds/source/root.hpp> #include <dds/source/root.hpp>
#include <dds/util/algo.hpp> #include <dds/util/algo.hpp>
#include <dds/util/log.hpp> #include <dds/util/log.hpp>
#include <dds/util/ranges.hpp>


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


if (fs::is_directory(pf_libs_dir)) { if (fs::is_directory(pf_libs_dir)) {
extend(ret, extend(ret,
fs::directory_iterator(pf_libs_dir) //
| ranges::views::filter(has_library_dirs) //
view_safe(fs::directory_iterator(pf_libs_dir)) //
| ranges::views::filter(has_library_dirs) //
| ranges::views::transform( | ranges::views::transform(
[&](auto p) { return library_root::from_directory(fs::canonical(p)); })); [&](auto p) { return library_root::from_directory(fs::canonical(p)); }));
} }

+ 15
- 24
src/dds/repo/repo.cpp View File

#include <dds/source/dist.hpp> #include <dds/source/dist.hpp>
#include <dds/util/log.hpp> #include <dds/util/log.hpp>
#include <dds/util/paths.hpp> #include <dds/util/paths.hpp>
#include <dds/util/ranges.hpp>
#include <dds/util/string.hpp> #include <dds/util/string.hpp>


#include <range/v3/action/sort.hpp> #include <range/v3/action/sort.hpp>


using namespace ranges; using namespace ranges;


namespace {
void repository::_log_blocking(path_ref dirpath) noexcept {
dds_log(warn, "Another process has the repository directory locked [{}]", dirpath.string());
dds_log(warn, "Waiting for repository to be released...");
}

void repository::_init_repo_dir(path_ref dirpath) noexcept { fs::create_directories(dirpath); }


auto load_sdists(path_ref root) {
using namespace ranges;
using namespace ranges::views;
fs::path repository::default_local_path() noexcept { return dds_data_dir() / "repo"; }


repository repository::_open_for_directory(bool writeable, path_ref dirpath) {
auto try_read_sdist = [](path_ref p) -> std::optional<sdist> { auto try_read_sdist = [](path_ref p) -> std::optional<sdist> {
if (starts_with(p.filename().string(), ".")) { if (starts_with(p.filename().string(), ".")) {
return std::nullopt; return std::nullopt;
} }
}; };


return
auto entries =
// Get the top-level `name-version` dirs // Get the top-level `name-version` dirs
fs::directory_iterator(root) //
view_safe(fs::directory_iterator(dirpath)) //
// // Convert each dir into an `sdist` object // // Convert each dir into an `sdist` object
| transform(try_read_sdist) //
| ranges::views::transform(try_read_sdist) //
// // Drop items that failed to load // // Drop items that failed to load
| filter([](auto&& opt) { return opt.has_value(); }) //
| transform([](auto&& opt) { return *opt; }) //
;
}

} // namespace
| ranges::views::filter([](auto&& opt) { return opt.has_value(); }) //
| ranges::views::transform([](auto&& opt) { return *opt; }) //
| to<sdist_set>();


void repository::_log_blocking(path_ref dirpath) noexcept {
dds_log(warn, "Another process has the repository directory locked [{}]", dirpath.string());
dds_log(warn, "Waiting for repository to be released...");
}

void repository::_init_repo_dir(path_ref dirpath) noexcept { fs::create_directories(dirpath); }

fs::path repository::default_local_path() noexcept { return dds_data_dir() / "repo"; }

repository repository::_open_for_directory(bool writeable, path_ref dirpath) {
sdist_set entries = load_sdists(dirpath) | to<sdist_set>();
return {writeable, dirpath, std::move(entries)}; return {writeable, dirpath, std::move(entries)};
} }



+ 1
- 0
src/dds/source/dist.cpp View File



#include <neo/assert.hpp> #include <neo/assert.hpp>
#include <range/v3/algorithm/sort.hpp> #include <range/v3/algorithm/sort.hpp>
#include <range/v3/range/conversion.hpp>
#include <range/v3/view/filter.hpp> #include <range/v3/view/filter.hpp>


using namespace dds; using namespace dds;

+ 3
- 1
src/dds/source/root.cpp View File

#include "./root.hpp" #include "./root.hpp"


#include <dds/util/ranges.hpp>

#include <range/v3/range/conversion.hpp> #include <range/v3/range/conversion.hpp>
#include <range/v3/view/filter.hpp> #include <range/v3/view/filter.hpp>
#include <range/v3/view/transform.hpp> #include <range/v3/view/transform.hpp>
using namespace ranges::views; using namespace ranges::views;
// Collect all source files from the directory // Collect all source files from the directory
return // return //
fs::recursive_directory_iterator(path) //
view_safe(fs::recursive_directory_iterator(path)) //
| filter([](auto&& entry) { return entry.is_regular_file(); }) // | filter([](auto&& entry) { return entry.is_regular_file(); }) //
| transform([&](auto&& entry) { return source_file::from_path(entry, path); }) // | transform([&](auto&& entry) { return source_file::from_path(entry, path); }) //
// source_file::from_path returns an optional. Drop nulls // source_file::from_path returns an optional. Drop nulls

+ 10
- 0
src/dds/util/ranges.hpp View File

#pragma once

namespace dds {

template <typename T>
constexpr auto& view_safe(T&& t) {
return t;
}

} // namespace dds

Loading…
Cancel
Save