{ | |||||
"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": {} | |||||
} | |||||
} | |||||
} | |||||
} |
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: 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 | Remote-Package: spdlog 1.4.2; git url=https://github.com/gabime/spdlog.git ref=v1.4.2 auto=spdlog/spdlog | ||||
catalog_path_flag cat_path{cmd}; | catalog_path_flag cat_path{cmd}; | ||||
repo_path_flag repo_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_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_apps{cmd, "no-apps", "Do not compile and link applications", {"no-apps"}}; | ||||
args::Flag no_warnings{cmd, "no-warings", "Disable build warnings", {"no-warnings"}}; | args::Flag no_warnings{cmd, "no-warings", "Disable build warnings", {"no-warnings"}}; | ||||
if (lm_index) { | if (lm_index) { | ||||
params.existing_lm_index = lm_index.Get(); | params.existing_lm_index = lm_index.Get(); | ||||
} else { | } else { | ||||
// Download and build dependencies | |||||
// Build the dependencies | // Build the dependencies | ||||
auto cat = cat_path.open(); | |||||
auto solved_deps = cat.solve_requirements(man.dependencies); | |||||
params.dep_sdists = dds::repository::with_repository( // | params.dep_sdists = dds::repository::with_repository( // | ||||
this->repo_path.Get(), | 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::repo_flags::write_lock | dds::repo_flags::create_if_absent, | ||||
[&](dds::repository repo) { | [&](dds::repository repo) { | ||||
// Download dependencies | |||||
for (const dds::package_id& pk : solved_deps) { | for (const dds::package_id& pk : solved_deps) { | ||||
auto exists = !!repo.find(pk); | auto exists = !!repo.find(pk); | ||||
if (!exists) { | 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; | |||||
} | } | ||||
}; | }; | ||||
cli_build build{cli}; | cli_build build{cli}; | ||||
cli_sdist sdist{cli}; | cli_sdist sdist{cli}; | ||||
cli_repo repo{cli}; | cli_repo repo{cli}; | ||||
cli_deps deps{cli}; | |||||
cli_catalog catalog{cli}; | cli_catalog catalog{cli}; | ||||
try { | try { | ||||
parser.ParseCLI(argc, argv); | parser.ParseCLI(argc, argv); | ||||
return sdist.run(); | return sdist.run(); | ||||
} else if (repo.cmd) { | } else if (repo.cmd) { | ||||
return repo.run(); | return repo.run(); | ||||
} else if (deps.cmd) { | |||||
return deps.run(); | |||||
} else if (catalog.cmd) { | } else if (catalog.cmd) { | ||||
return catalog.run(); | return catalog.run(); | ||||
} else { | } else { |
fs::remove_all(sd_dest); | fs::remove_all(sd_dest); | ||||
} | } | ||||
fs::rename(tmp_copy, 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()); | spdlog::info("Source distribution '{}' successfully exported", sd.manifest.pkg_id.to_string()); | ||||
} | } | ||||
def project_dir_arg(self) -> str: | def project_dir_arg(self) -> str: | ||||
return f'--project-dir={self.source_root}' | 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, *, | def deps_build(self, *, | ||||
toolchain: str = None) -> subprocess.CompletedProcess: | toolchain: str = None) -> subprocess.CompletedProcess: | ||||
return self.run([ | return self.run([ | ||||
return self.run([ | return self.run([ | ||||
'build', | 'build', | ||||
f'--out={self.build_dir}', | 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-tests'] if not tests else [], | ||||
['--no-apps'] if not apps else [], | ['--no-apps'] if not apps else [], | ||||
['--no-warnings'] if not warnings else [], | ['--no-warnings'] if not warnings else [], | ||||
['--export'] if export else [], | ['--export'] if export else [], | ||||
f'--toolchain={toolchain or self.default_builtin_toolchain}', | |||||
f'--repo-dir={self.repo_dir}', | |||||
self.project_dir_arg, | self.project_dir_arg, | ||||
]) | ]) | ||||
) | ) | ||||
@dds_conf | |||||
def test_ls(dds: DDS): | |||||
dds.run(['deps', 'ls']) | |||||
@dds_conf | @dds_conf | ||||
def test_deps_build(dds: DDS): | def test_deps_build(dds: DDS): | ||||
dds.catalog_import(dds.source_root / 'catalog.json') | dds.catalog_import(dds.source_root / 'catalog.json') | ||||
assert not dds.repo_dir.exists() | 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') | @dds_fixture_conf_1('use-remote') | ||||
def test_use_nlohmann_json_remote(dds: DDS): | def test_use_nlohmann_json_remote(dds: DDS): | ||||
dds.catalog_import(dds.source_root / 'catalog.json') | dds.catalog_import(dds.source_root / 'catalog.json') | ||||
dds.deps_get() | |||||
dds.build(apps=True) | dds.build(apps=True) | ||||
app_exe = dds.build_dir / f'app{dds.exe_suffix}' | app_exe = dds.build_dir / f'app{dds.exe_suffix}' |
def test_get_build_use_spdlog(dds: DDS): | def test_get_build_use_spdlog(dds: DDS): | ||||
dds.catalog_import(dds.source_root / 'catalog.json') | 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_fname = 'gcc.tc.dds' if 'gcc' in dds.default_builtin_toolchain else 'msvc.tc.dds' | ||||
tc = str(dds.test_dir / tc_fname) | tc = str(dds.test_dir / tc_fname) | ||||
dds.build(toolchain=tc, apps=True) | dds.build(toolchain=tc, apps=True) |
else: | else: | ||||
assert False, 'impossible' | assert False, 'impossible' | ||||
ci_repo_dir = paths.BUILD_DIR / '_ci-repo' | |||||
if not opts.skip_deps: | if not opts.skip_deps: | ||||
ci_repo_dir = paths.BUILD_DIR / '_ci-repo' | |||||
if ci_repo_dir.exists(): | if ci_repo_dir.exists(): | ||||
shutil.rmtree(ci_repo_dir) | shutil.rmtree(ci_repo_dir) | ||||
self_deps_get(paths.PREBUILT_DDS, ci_repo_dir) | self_deps_get(paths.PREBUILT_DDS, ci_repo_dir) | ||||
dds_flags=['--warnings', '--tests', '--apps']) | dds_flags=['--warnings', '--tests', '--apps']) | ||||
print('Main build PASSED!') | 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( | self_build( | ||||
paths.CUR_BUILT_DDS, | paths.CUR_BUILT_DDS, | ||||
toolchain=opts.toolchain, | 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!') | print('Bootstrap test PASSED!') | ||||
return pytest.main([ | return pytest.main([ |