浏览代码

Separate type to record dependencies only

default_compile_flags
vector-of-bool 5 年前
父节点
当前提交
b12bdf83ec
共有 8 个文件被更改,包括 72 次插入10 次删除
  1. +5
    -5
      src/dds.main.cpp
  2. +17
    -0
      src/dds/deps.cpp
  3. +10
    -1
      src/dds/deps.hpp
  4. +1
    -0
      src/dds/source/dist.cpp
  5. +1
    -0
      tests/dds.py
  6. +21
    -0
      tests/deps/build-deps/project/catalog.json
  7. +0
    -2
      tests/deps/build-deps/project/deps.dds
  8. +17
    -2
      tests/deps/build-deps/test_build_deps.py

+ 5
- 5
src/dds.main.cpp 查看文件

@@ -615,12 +615,11 @@ struct cli_build_deps {
dds::builder bd;
dds::sdist_build_params sdist_params;

auto all_file_deps
= deps_files.Get() //
auto all_file_deps = deps_files.Get() //
| ranges::views::transform([&](auto dep_fpath) {
spdlog::info("Reading deps from {}", dep_fpath.string());
return dds::package_manifest::load_from_file(dep_fpath).dependencies;
})
spdlog::info("Reading deps from {}", dep_fpath.string());
return dds::dependency_manifest::from_file(dep_fpath).dependencies;
})
| ranges::actions::join;

auto cmd_deps = ranges::views::transform(deps.Get(), [&](auto dep_str) {
@@ -650,6 +649,7 @@ struct cli_build_deps {
assert(sdist_ptr);
dds::sdist_build_params deps_params;
deps_params.subdir = sdist_ptr->manifest.pkg_id.to_string();
spdlog::info("Dependency: {}", sdist_ptr->manifest.pkg_id.to_string());
bd.add(*sdist_ptr, deps_params);
}
});

+ 17
- 0
src/dds/deps.cpp 查看文件

@@ -40,3 +40,20 @@ dependency dependency::parse_depends_string(std::string_view str) {
str));
}
}

dependency_manifest dependency_manifest::from_file(path_ref fpath) {
auto kvs = lm::parse_file(fpath);
dependency_manifest ret;
lm::read(
fmt::format("Reading dependencies from '{}'", fpath.string()),
kvs,
[&](auto, auto key, auto val) {
if (key == "Depends") {
ret.dependencies.push_back(dependency::parse_depends_string(val));
return true;
}
return false;
},
lm::reject_unknown());
return ret;
}

+ 10
- 1
src/dds/deps.hpp 查看文件

@@ -1,6 +1,6 @@
#pragma once

#include <dds/build/plan/full.hpp>
#include <dds/util/fs.hpp>

#include <pubgrub/interval.hpp>
#include <semver/range.hpp>
@@ -19,4 +19,13 @@ struct dependency {
static dependency parse_depends_string(std::string_view str);
};

/**
* Represents a dependency listing file, which is a subset of a package manifest
*/
struct dependency_manifest {
std::vector<dependency> dependencies;

static dependency_manifest from_file(path_ref where);
};

} // namespace dds

+ 1
- 0
src/dds/source/dist.cpp 查看文件

@@ -1,5 +1,6 @@
#include "./dist.hpp"

#include <dds/library/library.hpp>
#include <dds/temp.hpp>
#include <dds/util/fs.hpp>


+ 1
- 0
tests/dds.py 查看文件

@@ -74,6 +74,7 @@ class DDS:
return self.run([
'build-deps',
f'--toolchain={toolchain or self.default_builtin_toolchain}',
f'--catalog={self.catalog_path}',
f'--repo-dir={self.repo_dir}',
f'--out={self.deps_build_dir}',
f'--lmi-path={self.lmi_path}',

+ 21
- 0
tests/deps/build-deps/project/catalog.json 查看文件

@@ -0,0 +1,21 @@
{
"version": 1,
"packages": {
"neo-sqlite3": {
"0.1.0": {
"git": {
"url": "https://github.com/vector-of-bool/neo-sqlite3.git",
"ref": "0.1.0"
},
"depends": {}
},
"0.2.2": {
"git": {
"url": "https://github.com/vector-of-bool/neo-sqlite3.git",
"ref": "0.2.2"
},
"depends": {}
}
}
}
}

+ 0
- 2
tests/deps/build-deps/project/deps.dds 查看文件

@@ -1,4 +1,2 @@
Name: dummy
Version: 0.0.0

Depends: neo-sqlite3 +0.0.0

+ 17
- 2
tests/deps/build-deps/test_build_deps.py 查看文件

@@ -1,7 +1,22 @@
from tests import dds, DDS


def test_build_deps(dds: DDS):
def test_build_deps_from_file(dds: DDS):
assert not dds.deps_build_dir.is_dir()
dds.catalog_import(dds.source_root / 'catalog.json')
dds.build_deps(['-d', 'deps.dds'])
assert dds.deps_build_dir.is_dir()
assert (dds.deps_build_dir / 'neo-sqlite3@0.1.0').is_dir()


def test_build_deps_from_cmd(dds: DDS):
assert not dds.deps_build_dir.is_dir()
dds.catalog_import(dds.source_root / 'catalog.json')
dds.build_deps(['neo-sqlite3 =0.1.0'])
assert (dds.deps_build_dir / 'neo-sqlite3@0.1.0').is_dir()


def test_multiple_deps(dds: DDS):
assert not dds.deps_build_dir.is_dir()
dds.catalog_import(dds.source_root / 'catalog.json')
dds.build_deps(['neo-sqlite3 ^0.1.0', 'neo-sqlite3 ~0.2.0'])
assert (dds.deps_build_dir / 'neo-sqlite3@0.2.2').is_dir()

正在加载...
取消
保存