| semver::version version, | semver::version version, | ||||
| const lm::pair_list& pairs) { | const lm::pair_list& pairs) { | ||||
| if (pairs.find("git")) { | if (pairs.find("git")) { | ||||
| std::string url; | |||||
| std::string ref; | |||||
| std::string url; | |||||
| std::string ref; | |||||
| std::optional<lm::usage> auto_id; | |||||
| lm::read(fmt::format("{}: Parsing Git remote listing", context), | lm::read(fmt::format("{}: Parsing Git remote listing", context), | ||||
| pairs, | pairs, | ||||
| lm::read_required("url", url), | lm::read_required("url", url), | ||||
| lm::read_required("ref", ref), | lm::read_required("ref", ref), | ||||
| lm::read_check_eq("git", ""), | lm::read_check_eq("git", ""), | ||||
| lm::read_opt("auto", auto_id, &lm::split_usage_string), | |||||
| lm::reject_unknown()); | lm::reject_unknown()); | ||||
| auto did_insert | |||||
| = out.emplace( | |||||
| remote_listing{std::move(name), version, git_remote_listing{url, ref}}) | |||||
| .second; | |||||
| auto did_insert = out.emplace(remote_listing{std::move(name), | |||||
| version, | |||||
| git_remote_listing{url, ref, auto_id}}) | |||||
| .second; | |||||
| if (!did_insert) { | if (!did_insert) { | ||||
| spdlog::warn("Duplicate remote package defintion for {} {}", | spdlog::warn("Duplicate remote package defintion for {} {}", | ||||
| name, | name, | ||||
| } | } | ||||
| }; | }; | ||||
| temporary_sdist do_pull_sdist(const git_remote_listing& git) { | |||||
| temporary_sdist do_pull_sdist(const remote_listing& listing, const git_remote_listing& git) { | |||||
| auto tmpdir = dds::temporary_dir::create(); | auto tmpdir = dds::temporary_dir::create(); | ||||
| using namespace std::literals; | using namespace std::literals; | ||||
| spdlog::info("Cloning repository: {} [{}] ...", git.url, git.ref); | spdlog::info("Cloning repository: {} [{}] ...", git.url, git.ref); | ||||
| git_res.output)); | git_res.output)); | ||||
| } | } | ||||
| spdlog::info("Create sdist from clone ..."); | spdlog::info("Create sdist from clone ..."); | ||||
| if (git.auto_lib.has_value()) { | |||||
| spdlog::info("Generating library data automatically"); | |||||
| auto pkg_strm = dds::open(tmpdir.path() / "package.dds", std::ios::binary | std::ios::out); | |||||
| pkg_strm << "Name: " << listing.name << '\n' // | |||||
| << "Version: " << listing.version.to_string() << '\n' // | |||||
| << "Namespace: " << git.auto_lib->namespace_; | |||||
| auto lib_strm = dds::open(tmpdir.path() / "library.dds", std::ios::binary | std::ios::out); | |||||
| lib_strm << "Name: " << git.auto_lib->name; | |||||
| } | |||||
| sdist_params params; | sdist_params params; | ||||
| params.project_dir = tmpdir.path(); | params.project_dir = tmpdir.path(); | ||||
| auto sd_tmp_dir = dds::temporary_dir::create(); | auto sd_tmp_dir = dds::temporary_dir::create(); | ||||
| } // namespace | } // namespace | ||||
| temporary_sdist remote_listing::pull_sdist() const { | temporary_sdist remote_listing::pull_sdist() const { | ||||
| auto tsd = visit([](auto&& actual) { return do_pull_sdist(actual); }); | |||||
| auto tsd = visit([&](auto&& actual) { return do_pull_sdist(*this, actual); }); | |||||
| if (tsd.sdist.manifest.name != name) { | if (tsd.sdist.manifest.name != name) { | ||||
| throw std::runtime_error( | throw std::runtime_error( | ||||
| fmt::format("The name in the generated sdist ('{}') does not match the name listed in " | fmt::format("The name in the generated sdist ('{}') does not match the name listed in " |
| #include <dds/sdist.hpp> | #include <dds/sdist.hpp> | ||||
| #include <dds/temp.hpp> | #include <dds/temp.hpp> | ||||
| #include <semver/version.hpp> | #include <semver/version.hpp> | ||||
| #include <libman/library.hpp> | |||||
| #include <set> | #include <set> | ||||
| #include <string> | #include <string> | ||||
| }; | }; | ||||
| struct git_remote_listing { | struct git_remote_listing { | ||||
| std::string url; | |||||
| std::string ref; | |||||
| std::string url; | |||||
| std::string ref; | |||||
| std::optional<lm::usage> auto_lib; | |||||
| void clone(path_ref path) const; | void clone(path_ref path) const; | ||||
| }; | }; |
| library ret; | library ret; | ||||
| std::vector<std::string> uses_strs; | |||||
| std::vector<std::string> links_strs; | |||||
| std::string _type_; | std::string _type_; | ||||
| read(fmt::format("Reading library manifest file '{}'", fpath.string()), | read(fmt::format("Reading library manifest file '{}'", fpath.string()), | ||||
| pairs, | pairs, | ||||
| read_opt("Path", ret.linkable_path), | read_opt("Path", ret.linkable_path), | ||||
| read_accumulate("Include-Path", ret.include_paths), | read_accumulate("Include-Path", ret.include_paths), | ||||
| read_accumulate("Preprocessor-Define", ret.preproc_defs), | read_accumulate("Preprocessor-Define", ret.preproc_defs), | ||||
| read_accumulate("Uses", uses_strs), | |||||
| read_accumulate("Links", links_strs), | |||||
| read_accumulate("Uses", ret.uses, &split_usage_string), | |||||
| read_accumulate("Links", ret.links, &split_usage_string), | |||||
| read_accumulate("Special-Uses", ret.special_uses)); | read_accumulate("Special-Uses", ret.special_uses)); | ||||
| for (auto&& uses_str : uses_strs) { | |||||
| ret.uses.push_back(split_usage_string(uses_str)); | |||||
| } | |||||
| for (auto&& links_str : links_strs) { | |||||
| ret.links.push_back(split_usage_string(links_str)); | |||||
| } | |||||
| auto make_absolute = [&](path_ref p) { return fpath.parent_path() / p; }; | auto make_absolute = [&](path_ref p) { return fpath.parent_path() / p; }; | ||||
| std::transform(ret.include_paths.begin(), | std::transform(ret.include_paths.begin(), | ||||
| ret.include_paths.end(), | ret.include_paths.end(), |
| static nested_kvlist parse(std::string_view s); | static nested_kvlist parse(std::string_view s); | ||||
| }; | }; | ||||
| struct unchanged { | |||||
| template <typename Item> | |||||
| auto operator()(Item&& item) const { | |||||
| return item; | |||||
| } | |||||
| }; | |||||
| template <typename What> | template <typename What> | ||||
| class read_required { | class read_required { | ||||
| std::string_view _key; | std::string_view _key; | ||||
| } | } | ||||
| }; | }; | ||||
| template <typename T> | |||||
| template <typename T, typename Transform = unchanged> | |||||
| class read_opt { | class read_opt { | ||||
| std::string_view _key; | std::string_view _key; | ||||
| T& _ref; | T& _ref; | ||||
| bool _did_read = false; | bool _did_read = false; | ||||
| Transform _tr; | |||||
| public: | public: | ||||
| read_opt(std::string_view key, T& ref) | |||||
| read_opt(std::string_view key, T& ref, Transform tr = unchanged()) | |||||
| : _key(key) | : _key(key) | ||||
| , _ref(ref) {} | |||||
| , _ref(ref) | |||||
| , _tr(std::move(tr)) {} | |||||
| int operator()(std::string_view context, std::string_view key, std::string_view value) { | int operator()(std::string_view context, std::string_view key, std::string_view value) { | ||||
| if (key != _key) { | if (key != _key) { | ||||
| throw std::runtime_error(std::string(context) + ": Duplicated key '" + std::string(key) | throw std::runtime_error(std::string(context) + ": Duplicated key '" + std::string(key) | ||||
| + "' is not allowed."); | + "' is not allowed."); | ||||
| } | } | ||||
| _ref = T(value); | |||||
| _ref = T(_tr(value)); | |||||
| return 1; | return 1; | ||||
| } | } | ||||
| }; | }; | ||||
| } | } | ||||
| }; | }; | ||||
| struct read_empty_set_true { | |||||
| std::string_view _key; | |||||
| bool& _bool; | |||||
| bool _seen = false; | |||||
| bool operator()(std::string_view context, std::string_view key, std::string_view value) { | |||||
| if (key != _key) { | |||||
| return false; | |||||
| } | |||||
| if (value != "") { | |||||
| throw std::runtime_error(std::string(context) + ": Key '" + std::string(key) | |||||
| + "' does not expected a value (Got '" + std::string(value) | |||||
| + "')."); | |||||
| } | |||||
| if (_seen) { | |||||
| throw std::runtime_error(std::string(context) + ": Duplicated key '" + std::string(key) | |||||
| + "'"); | |||||
| } | |||||
| _bool = true; | |||||
| _seen = true; | |||||
| return true; | |||||
| } | |||||
| }; | |||||
| class read_check_eq { | class read_check_eq { | ||||
| std::string_view _key; | std::string_view _key; | ||||
| std::string_view _expect; | std::string_view _expect; | ||||
| } | } | ||||
| }; | }; | ||||
| template <typename Container> | |||||
| template <typename Container, typename Transform = unchanged> | |||||
| class read_accumulate { | class read_accumulate { | ||||
| std::string_view _key; | std::string_view _key; | ||||
| Container& _items; | Container& _items; | ||||
| Transform _tr; | |||||
| public: | public: | ||||
| read_accumulate(std::string_view key, Container& c, Transform tr) | |||||
| : _key(key) | |||||
| , _items(c) | |||||
| , _tr(std::move(tr)) {} | |||||
| read_accumulate(std::string_view key, Container& c) | read_accumulate(std::string_view key, Container& c) | ||||
| : _key(key) | : _key(key) | ||||
| , _items(c) {} | |||||
| , _items(c) | |||||
| , _tr(unchanged()) {} | |||||
| int operator()(std::string_view, std::string_view key, std::string_view value) const { | int operator()(std::string_view, std::string_view key, std::string_view value) const { | ||||
| if (key == _key) { | if (key == _key) { | ||||
| _items.emplace_back(value); | |||||
| _items.emplace_back(_tr(value)); | |||||
| return 1; | return 1; | ||||
| } | } | ||||
| return 0; | return 0; |
| Version: 0.0.0 | Version: 0.0.0 | ||||
| Depends: neo-buffer 0.1.0 | Depends: neo-buffer 0.1.0 | ||||
| Depends: range-v3 0.9.1 |
| Remote-Package: neo-buffer 0.1.0; git url=https://github.com/vector-of-bool/neo-buffer.git ref=develop | |||||
| Remote-Package: neo-buffer 0.1.0; git url=https://github.com/vector-of-bool/neo-buffer.git ref=develop | |||||
| Remote-Package: range-v3 0.9.1; git url=https://github.com/ericniebler/range-v3.git ref=0.9.1 auto=Niebler/range-v3 |