Преглед на файлове

Downloading deps now takes place as part of the main build

default_compile_flags
vector-of-bool преди 5 години
родител
ревизия
a2b36cc5df
променени са 8 файла, в които са добавени 107 реда и са изтрити 119 реда
  1. +79
    -0
      catalog.json
  2. +0
    -1
      remote.dds
  3. +12
    -94
      src/dds/dds.main.cpp
  4. +1
    -0
      src/dds/repo/repo.cpp
  5. +3
    -13
      tests/dds.py
  6. +2
    -8
      tests/deps/do_test.py
  7. +0
    -1
      tests/deps/use-spdlog/use_spdlog_test.py
  8. +10
    -2
      tools/ci.py

+ 79
- 0
catalog.json Целия файл

@@ -0,0 +1,79 @@
{
"version": 1,
"packages": {
"range-v3": {
"0.10.0": {
"git": {
"url": "https://github.com/ericniebler/range-v3.git",
"ref": "0.10.0",
"auto-lib": "Niebler/range-v3"
},
"depends": {}
}
},
"spdlog": {
"1.4.2": {
"git": {
"url": "https://github.com/gabime/spdlog.git",
"ref": "v1.4.2",
"auto-lib": "spdlog/spdlog"
},
"depends": {}
}
},
"nlohmann-json": {
"3.7.1": {
"git": {
"url": "https://github.com/vector-of-bool/json.git",
"ref": "dds/3.7.1"
},
"depends": {}
}
},
"ms-wil": {
"2019.11.10": {
"git": {
"url": "https://github.com/vector-of-bool/wil.git",
"ref": "dds/2019.11.10"
},
"depends": {}
}
},
"neo-buffer": {
"0.1.0": {
"git": {
"url": "https://github.com/vector-of-bool/neo-buffer.git",
"ref": "0.1.0"
},
"depends": {}
}
},
"neo-sqlite3": {
"0.2.2": {
"git": {
"url": "https://github.com/vector-of-bool/neo-sqlite3.git",
"ref": "0.2.2"
},
"depends": {}
}
},
"semver": {
"0.2.1": {
"git": {
"url": "https://github.com/vector-of-bool/semver.git",
"ref": "0.2.1"
},
"depends": {}
}
},
"pubgrub": {
"0.1.2": {
"git": {
"url": "https://github.com/vector-of-bool/pubgrub.git",
"ref": "0.1.2"
},
"depends": {}
}
}
}
}

+ 0
- 1
remote.dds Целия файл

@@ -1,4 +1,3 @@
Remote-Package: range-v3 0.9.1; git url=https://github.com/ericniebler/range-v3.git ref=0.9.1 auto=Niebler/range-v3
Remote-Package: range-v3 0.10.0; git url=https://github.com/ericniebler/range-v3.git ref=0.10.0 auto=Niebler/range-v3
Remote-Package: spdlog 1.4.2; git url=https://github.com/gabime/spdlog.git ref=v1.4.2 auto=spdlog/spdlog


+ 12
- 94
src/dds/dds.main.cpp Целия файл

@@ -483,11 +483,6 @@ struct cli_build {
catalog_path_flag cat_path{cmd};
repo_path_flag repo_path{cmd};

args::Flag do_download_deps{cmd,
"download-deps",
"Download any missing dependencies from the catalog",
{"download-deps"}};

args::Flag no_tests{cmd, "no-tests", "Do not build and run tests", {"no-tests"}};
args::Flag no_apps{cmd, "no-apps", "Do not compile and link applications", {"no-apps"}};
args::Flag no_warnings{cmd, "no-warings", "Disable build warnings", {"no-warnings"}};
@@ -531,104 +526,30 @@ struct cli_build {
if (lm_index) {
params.existing_lm_index = lm_index.Get();
} else {
// Download and build dependencies
// Build the dependencies
auto cat = cat_path.open();
auto solved_deps = cat.solve_requirements(man.dependencies);
params.dep_sdists = dds::repository::with_repository( //
this->repo_path.Get(),
dds::repo_flags::read | dds::repo_flags::create_if_absent,
[&](dds::repository repo) { return repo.solve(man.dependencies); });
}
dds::build(params, man);
return 0;
}
};

/*
######## ######## ######## ######
## ## ## ## ## ## ##
## ## ## ## ## ##
## ## ###### ######## ######
## ## ## ## ##
## ## ## ## ## ##
######## ######## ## ######
*/

struct cli_deps {
cli_base& base;
args::Command cmd{base.cmd_group, "deps", "Obtain/inspect/build deps for the project"};

common_flags _flags{cmd};
common_project_flags project{cmd};

args::Group deps_group{cmd, "Subcommands"};

dds::package_manifest load_package_manifest() {
return dds::package_manifest::load_from_file(project.root.Get() / "package.dds");
}

struct {
cli_deps& parent;
args::Command cmd{parent.deps_group, "ls", "List project dependencies"};
common_flags _common{cmd};

int run() {
const auto man = parent.load_package_manifest();
for (const auto& dep : man.dependencies) {
std::cout << dep.name << " " << dep.versions << '\n';
}
return 0;
}
} ls{*this};

struct {
cli_deps& parent;
args::Command cmd{parent.deps_group,
"get",
"Ensure we have local copies of the project dependencies"};
common_flags _common{cmd};

repo_path_flag repo_where{cmd};
catalog_path_flag catalog_path{cmd};

int run() {
auto man = parent.load_package_manifest();
auto catalog = catalog_path.open();
bool failed = false;
auto solved_deps = catalog.solve_requirements(man.dependencies);
dds::repository::with_repository( //
repo_where.Get(),
dds::repo_flags::write_lock | dds::repo_flags::create_if_absent,
[&](dds::repository repo) {
// Download dependencies
for (const dds::package_id& pk : solved_deps) {
auto exists = !!repo.find(pk);
if (!exists) {
spdlog::info("Pull remote: {}", pk.to_string());
auto opt_pkg = catalog.get(pk);
if (opt_pkg) {
auto tsd = dds::get_package_sdist(*opt_pkg);
repo.add_sdist(tsd.sdist, dds::if_exists::ignore);
} else {
spdlog::error("No remote listing for {}", pk.to_string());
failed = true;
}
} else {
spdlog::info("Okay: {}", pk.to_string());
spdlog::info("Download dependency: {}", pk.to_string());
auto opt_pkg = cat.get(pk);
assert(opt_pkg);
auto tsd = dds::get_package_sdist(*opt_pkg);
repo.add_sdist(tsd.sdist, dds::if_exists::throw_exc);
}
}
return repo.solve(man.dependencies);
});
if (failed) {
return 1;
}
return 0;
}
} get{*this};

int run() {
if (ls.cmd) {
return ls.run();
} else if (get.cmd) {
return get.run();
}
std::terminate();
dds::build(params, man);
return 0;
}
};

@@ -655,7 +576,6 @@ int main(int argc, char** argv) {
cli_build build{cli};
cli_sdist sdist{cli};
cli_repo repo{cli};
cli_deps deps{cli};
cli_catalog catalog{cli};
try {
parser.ParseCLI(argc, argv);
@@ -680,8 +600,6 @@ int main(int argc, char** argv) {
return sdist.run();
} else if (repo.cmd) {
return repo.run();
} else if (deps.cmd) {
return deps.run();
} else if (catalog.cmd) {
return catalog.run();
} else {

+ 1
- 0
src/dds/repo/repo.cpp Целия файл

@@ -95,6 +95,7 @@ void repository::add_sdist(const sdist& sd, if_exists ife_action) {
fs::remove_all(sd_dest);
}
fs::rename(tmp_copy, sd_dest);
_sdists.insert(sdist::from_directory(sd_dest));
spdlog::info("Source distribution '{}' successfully exported", sd.manifest.pkg_id.to_string());
}


+ 3
- 13
tests/dds.py Целия файл

@@ -69,17 +69,6 @@ class DDS:
def project_dir_arg(self) -> str:
return f'--project-dir={self.source_root}'

def deps_ls(self) -> subprocess.CompletedProcess:
return self.run(['deps', 'ls'])

def deps_get(self) -> subprocess.CompletedProcess:
return self.run([
'deps',
'get',
f'--catalog={self.catalog_path}',
self.repo_dir_arg,
])

def deps_build(self, *,
toolchain: str = None) -> subprocess.CompletedProcess:
return self.run([
@@ -101,12 +90,13 @@ class DDS:
return self.run([
'build',
f'--out={self.build_dir}',
f'--toolchain={toolchain or self.default_builtin_toolchain}',
f'--catalog={self.catalog_path}',
f'--repo-dir={self.repo_dir}',
['--no-tests'] if not tests else [],
['--no-apps'] if not apps else [],
['--no-warnings'] if not warnings else [],
['--export'] if export else [],
f'--toolchain={toolchain or self.default_builtin_toolchain}',
f'--repo-dir={self.repo_dir}',
self.project_dir_arg,
])


+ 2
- 8
tests/deps/do_test.py Целия файл

@@ -9,23 +9,17 @@ dds_conf = dds_fixture_conf(
)


@dds_conf
def test_ls(dds: DDS):
dds.run(['deps', 'ls'])


@dds_conf
def test_deps_build(dds: DDS):
dds.catalog_import(dds.source_root / 'catalog.json')
assert not dds.repo_dir.exists()
dds.deps_get()
assert dds.repo_dir.exists(), '`deps get` did not generate a repo directory'
dds.build()
assert dds.repo_dir.exists(), '`Building` did not generate a repo directory'


@dds_fixture_conf_1('use-remote')
def test_use_nlohmann_json_remote(dds: DDS):
dds.catalog_import(dds.source_root / 'catalog.json')
dds.deps_get()
dds.build(apps=True)

app_exe = dds.build_dir / f'app{dds.exe_suffix}'

+ 0
- 1
tests/deps/use-spdlog/use_spdlog_test.py Целия файл

@@ -5,7 +5,6 @@ from dds_ci import proc

def test_get_build_use_spdlog(dds: DDS):
dds.catalog_import(dds.source_root / 'catalog.json')
dds.deps_get()
tc_fname = 'gcc.tc.dds' if 'gcc' in dds.default_builtin_toolchain else 'msvc.tc.dds'
tc = str(dds.test_dir / tc_fname)
dds.build(toolchain=tc, apps=True)

+ 10
- 2
tools/ci.py Целия файл

@@ -98,8 +98,8 @@ def main(argv: Sequence[str]) -> int:
else:
assert False, 'impossible'

ci_repo_dir = paths.BUILD_DIR / '_ci-repo'
if not opts.skip_deps:
ci_repo_dir = paths.BUILD_DIR / '_ci-repo'
if ci_repo_dir.exists():
shutil.rmtree(ci_repo_dir)
self_deps_get(paths.PREBUILT_DDS, ci_repo_dir)
@@ -112,10 +112,18 @@ def main(argv: Sequence[str]) -> int:
dds_flags=['--warnings', '--tests', '--apps'])
print('Main build PASSED!')

cat_path = paths.BUILD_DIR / 'catalog.db'
proc.check_run([
paths.CUR_BUILT_DDS,
'catalog',
'import',
('--catalog', cat_path),
('--json', paths.PROJECT_ROOT / 'catalog.json'),
])
self_build(
paths.CUR_BUILT_DDS,
toolchain=opts.toolchain,
dds_flags=[f'--repo-dir={ci_repo_dir}'])
dds_flags=[f'--repo-dir={ci_repo_dir}', f'--catalog={cat_path}'])
print('Bootstrap test PASSED!')

return pytest.main([

Loading…
Отказ
Запис