@@ -3,7 +3,6 @@ | |||
#include <dds/build/plan/compile_file.hpp> | |||
#include <dds/logging.hpp> | |||
#include <dds/proc.hpp> | |||
#include <dds/project.hpp> | |||
#include <dds/source.hpp> | |||
#include <dds/toolchain.hpp> | |||
#include <dds/usage_reqs.hpp> | |||
@@ -158,8 +157,6 @@ void dds::build(const build_params& params, const package_manifest& man) { | |||
plan.archive_all(env, params.parallel_jobs); | |||
plan.link_all(env, params.parallel_jobs); | |||
auto project = project::from_directory(params.root); | |||
// int n_test_fails = 0; | |||
// for (path_ref test_exe : all_tests) { | |||
// spdlog::info("Running test: {}", fs::relative(test_exe, params.out_root).string()); |
@@ -236,7 +236,7 @@ struct cli_sdist { | |||
int run() { | |||
auto repo_dir = repo_where.Get(); | |||
// TODO: Generate a unique name to avoid conflicts | |||
auto tmp_sdist = repo_dir / ".tmp.sdist"; | |||
auto tmp_sdist = dds::fs::temp_directory_path() / ".dds-sdist"; | |||
if (dds::fs::exists(tmp_sdist)) { | |||
dds::fs::remove_all(tmp_sdist); | |||
} |
@@ -1,42 +0,0 @@ | |||
#include <dds/project.hpp> | |||
#include <dds/source.hpp> | |||
#include <range/v3/range/conversion.hpp> | |||
#include <range/v3/view/filter.hpp> | |||
#include <range/v3/view/transform.hpp> | |||
using namespace dds; | |||
namespace { | |||
bool has_library_dirs(path_ref p) { return fs::exists(p / "src") || fs::exists(p / "include"); } | |||
std::vector<library> collect_submodules(path_ref pf_libs_dir) { | |||
if (!fs::exists(pf_libs_dir)) { | |||
return {}; | |||
} | |||
using namespace ranges::views; | |||
return fs::directory_iterator(pf_libs_dir) // | |||
| filter(has_library_dirs) // | |||
| transform([](auto&& entry) { return library::from_directory(entry); }) // | |||
| ranges::to_vector; | |||
} | |||
} // namespace | |||
project project::from_directory(path_ref pf_dir_path) { | |||
std::optional<library> main_lib; | |||
if (has_library_dirs(pf_dir_path)) { | |||
main_lib = library::from_directory(pf_dir_path); | |||
} | |||
package_manifest man; | |||
auto man_path = pf_dir_path / "package.dds"; | |||
if (fs::is_regular_file(man_path)) { | |||
man = package_manifest::load_from_file(man_path); | |||
} | |||
return project(pf_dir_path, | |||
std::move(main_lib), | |||
collect_submodules(pf_dir_path / "libs"), | |||
std::move(man)); | |||
} |
@@ -1,43 +0,0 @@ | |||
#pragma once | |||
#include <dds/library.hpp> | |||
#include <dds/package_manifest.hpp> | |||
#include <dds/util/fs.hpp> | |||
#include <optional> | |||
#include <vector> | |||
namespace dds { | |||
class project { | |||
fs::path _root; | |||
std::optional<library> _main_lib; | |||
std::vector<library> _submodules; | |||
package_manifest _man; | |||
project(path_ref root, | |||
std::optional<library>&& ml, | |||
std::vector<library>&& mods, | |||
package_manifest&& man) | |||
: _root(root) | |||
, _main_lib(std::move(ml)) | |||
, _submodules(std::move(mods)) | |||
, _man(std::move(man)) {} | |||
public: | |||
static project from_directory(path_ref pr_dir); | |||
const library* main_library() const noexcept { | |||
if (_main_lib) { | |||
return &*_main_lib; | |||
} | |||
return nullptr; | |||
} | |||
auto& submodules() const noexcept { return _submodules; } | |||
auto& manifest() const noexcept { return _man; } | |||
path_ref root() const noexcept { return _root; } | |||
}; | |||
} // namespace dds |
@@ -1,6 +1,5 @@ | |||
#include "./sdist.hpp" | |||
#include <dds/project.hpp> | |||
#include <dds/temp.hpp> | |||
#include <dds/util/fs.hpp> | |||
@@ -100,28 +99,25 @@ sdist dds::create_sdist(const sdist_params& params) { | |||
} | |||
sdist dds::create_sdist_in_dir(path_ref out, const sdist_params& params) { | |||
auto project = project::from_directory(params.project_dir); | |||
auto libs = collect_libraries(params.project_dir); | |||
browns::md5 md5; | |||
if (project.main_library()) { | |||
sdist_copy_library(out, *project.main_library(), params, md5); | |||
for (const library& lib : libs) { | |||
sdist_copy_library(out, lib, params, md5); | |||
} | |||
for (const library& submod : project.submodules()) { | |||
sdist_copy_library(out, submod, params, md5); | |||
} | |||
auto man_path = project.root() / "package.dds"; | |||
auto man_path = params.project_dir / "package.dds"; | |||
if (!fs::is_regular_file(man_path)) { | |||
throw std::runtime_error(fmt::format( | |||
"Creating a source distribution requires a package.dds file for the project")); | |||
} | |||
sdist_export_file(out, params.project_dir, man_path, md5); | |||
auto pkg_man = package_manifest::load_from_file(man_path); | |||
md5.pad(); | |||
auto hash_str = browns::format_digest(md5.digest()); | |||
spdlog::info("Generated export as {}-{}", project.manifest().name, hash_str); | |||
spdlog::info("Generated export as {}-{}", pkg_man.name, hash_str); | |||
std::vector<lm::pair> pairs; | |||
pairs.emplace_back("MD5-Hash", hash_str); |