Browse Source

We can create and import sdists as gzip-compressed tar files

default_compile_flags
vector-of-bool 4 years ago
parent
commit
4c2040a310
11 changed files with 348 additions and 4096 deletions
  1. +103
    -420
      catalog.json
  2. +5
    -0
      library.jsonc
  3. +15
    -14
      package.jsonc
  4. +61
    -9
      src/dds.main.cpp
  5. +0
    -5
      src/dds/catalog/get.hpp
  6. +19
    -3557
      src/dds/catalog/init_catalog.cpp
  7. +32
    -0
      src/dds/source/dist.cpp
  8. +11
    -1
      src/dds/source/dist.hpp
  9. +6
    -6
      tests/dds.py
  10. +16
    -8
      tests/sdist/sdist_test.py
  11. +80
    -76
      tools/gen-catalog-json.py

+ 103
- 420
catalog.json View File

@@ -941,6 +941,26 @@
"transform": [],
"url": "https://github.com/fmtlib/fmt.git"
}
},
"7.0.2": {
"depends": [],
"description": "A modern formatting library : https://fmt.dev/",
"git": {
"auto-lib": "fmt/fmt",
"ref": "7.0.2",
"transform": [],
"url": "https://github.com/fmtlib/fmt.git"
}
},
"7.0.3": {
"depends": [],
"description": "A modern formatting library : https://fmt.dev/",
"git": {
"auto-lib": "fmt/fmt",
"ref": "7.0.3",
"transform": [],
"url": "https://github.com/fmtlib/fmt.git"
}
}
},
"hinnant-date": {
@@ -2133,6 +2153,71 @@
}
}
},
"neo-buffer": {
"0.2.1": {
"depends": [
"neo-concepts^0.2.2",
"neo-fun^0.1.1"
],
"description": "Buffer and byte algorithms/types based on those of Asio",
"git": {
"ref": "0.2.1",
"transform": [],
"url": "https://github.com/vector-of-bool/neo-buffer.git"
}
},
"0.3.0": {
"depends": [
"neo-concepts^0.3.2",
"neo-fun^0.4.0"
],
"description": "Buffer and byte algorithms/types based on those of Asio",
"git": {
"ref": "0.3.0",
"transform": [],
"url": "https://github.com/vector-of-bool/neo-buffer.git"
}
},
"0.4.0": {
"depends": [
"neo-concepts^0.4.0",
"neo-fun^0.4.1"
],
"description": "Buffer and byte algorithms/types based on those of Asio",
"git": {
"ref": "0.4.0",
"transform": [],
"url": "https://github.com/vector-of-bool/neo-buffer.git"
}
},
"0.4.1": {
"depends": [
"neo-concepts^0.4.0",
"neo-fun^0.4.1"
],
"description": "Buffer and byte algorithms/types based on those of Asio",
"git": {
"ref": "0.4.1",
"transform": [],
"url": "https://github.com/vector-of-bool/neo-buffer.git"
}
}
},
"neo-compress": {
"0.1.0": {
"depends": [
"neo-buffer^0.4.1",
"neo-fun^0.4.0",
"zlib^1.2.9"
],
"description": "Compression, archiving, etc. for C++20",
"git": {
"ref": "0.1.0",
"transform": [],
"url": "https://github.com/vector-of-bool/neo-compress.git"
}
}
},
"neo-concepts": {
"0.2.2": {
"depends": [],
@@ -2169,6 +2254,15 @@
"transform": [],
"url": "https://github.com/vector-of-bool/neo-concepts.git"
}
},
"0.4.0": {
"depends": [],
"description": "A (mostly) backport of C++20 concepts library, with some additions.",
"git": {
"ref": "0.4.0",
"transform": [],
"url": "https://github.com/vector-of-bool/neo-concepts.git"
}
}
},
"neo-fun": {
@@ -2234,6 +2328,15 @@
"transform": [],
"url": "https://github.com/vector-of-bool/neo-fun.git"
}
},
"0.4.1": {
"depends": [],
"description": "Some library components that didn't quite fit anywhere else...",
"git": {
"ref": "0.4.1",
"transform": [],
"url": "https://github.com/vector-of-bool/neo-fun.git"
}
}
},
"neo-sqlite3": {
@@ -3394,426 +3497,6 @@
}
},
"zlib": {
"1.0.1": {
"depends": [],
"description": "A massively spiffy yet delicately unobtrusive compression library",
"git": {
"auto-lib": "zlib/zlib",
"ref": "v1.0.1",
"transform": [
{
"move": {
"exclude": [],
"from": ".",
"include": [
"*.c",
"*.h"
],
"strip-components": 0,
"to": "src/"
}
},
{
"move": {
"exclude": [],
"from": "src/",
"include": [
"zlib.h",
"zconf.h"
],
"strip-components": 0,
"to": "include/"
}
}
],
"url": "https://github.com/madler/zlib.git"
}
},
"1.0.2": {
"depends": [],
"description": "A massively spiffy yet delicately unobtrusive compression library",
"git": {
"auto-lib": "zlib/zlib",
"ref": "v1.0.2",
"transform": [
{
"move": {
"exclude": [],
"from": ".",
"include": [
"*.c",
"*.h"
],
"strip-components": 0,
"to": "src/"
}
},
{
"move": {
"exclude": [],
"from": "src/",
"include": [
"zlib.h",
"zconf.h"
],
"strip-components": 0,
"to": "include/"
}
}
],
"url": "https://github.com/madler/zlib.git"
}
},
"1.0.4": {
"depends": [],
"description": "A massively spiffy yet delicately unobtrusive compression library",
"git": {
"auto-lib": "zlib/zlib",
"ref": "v1.0.4",
"transform": [
{
"move": {
"exclude": [],
"from": ".",
"include": [
"*.c",
"*.h"
],
"strip-components": 0,
"to": "src/"
}
},
{
"move": {
"exclude": [],
"from": "src/",
"include": [
"zlib.h",
"zconf.h"
],
"strip-components": 0,
"to": "include/"
}
}
],
"url": "https://github.com/madler/zlib.git"
}
},
"1.0.5": {
"depends": [],
"description": "A massively spiffy yet delicately unobtrusive compression library",
"git": {
"auto-lib": "zlib/zlib",
"ref": "v1.0.5",
"transform": [
{
"move": {
"exclude": [],
"from": ".",
"include": [
"*.c",
"*.h"
],
"strip-components": 0,
"to": "src/"
}
},
{
"move": {
"exclude": [],
"from": "src/",
"include": [
"zlib.h",
"zconf.h"
],
"strip-components": 0,
"to": "include/"
}
}
],
"url": "https://github.com/madler/zlib.git"
}
},
"1.0.7": {
"depends": [],
"description": "A massively spiffy yet delicately unobtrusive compression library",
"git": {
"auto-lib": "zlib/zlib",
"ref": "v1.0.7",
"transform": [
{
"move": {
"exclude": [],
"from": ".",
"include": [
"*.c",
"*.h"
],
"strip-components": 0,
"to": "src/"
}
},
{
"move": {
"exclude": [],
"from": "src/",
"include": [
"zlib.h",
"zconf.h"
],
"strip-components": 0,
"to": "include/"
}
}
],
"url": "https://github.com/madler/zlib.git"
}
},
"1.0.8": {
"depends": [],
"description": "A massively spiffy yet delicately unobtrusive compression library",
"git": {
"auto-lib": "zlib/zlib",
"ref": "v1.0.8",
"transform": [
{
"move": {
"exclude": [],
"from": ".",
"include": [
"*.c",
"*.h"
],
"strip-components": 0,
"to": "src/"
}
},
{
"move": {
"exclude": [],
"from": "src/",
"include": [
"zlib.h",
"zconf.h"
],
"strip-components": 0,
"to": "include/"
}
}
],
"url": "https://github.com/madler/zlib.git"
}
},
"1.0.9": {
"depends": [],
"description": "A massively spiffy yet delicately unobtrusive compression library",
"git": {
"auto-lib": "zlib/zlib",
"ref": "v1.0.9",
"transform": [
{
"move": {
"exclude": [],
"from": ".",
"include": [
"*.c",
"*.h"
],
"strip-components": 0,
"to": "src/"
}
},
{
"move": {
"exclude": [],
"from": "src/",
"include": [
"zlib.h",
"zconf.h"
],
"strip-components": 0,
"to": "include/"
}
}
],
"url": "https://github.com/madler/zlib.git"
}
},
"1.1.0": {
"depends": [],
"description": "A massively spiffy yet delicately unobtrusive compression library",
"git": {
"auto-lib": "zlib/zlib",
"ref": "v1.1.0",
"transform": [
{
"move": {
"exclude": [],
"from": ".",
"include": [
"*.c",
"*.h"
],
"strip-components": 0,
"to": "src/"
}
},
{
"move": {
"exclude": [],
"from": "src/",
"include": [
"zlib.h",
"zconf.h"
],
"strip-components": 0,
"to": "include/"
}
}
],
"url": "https://github.com/madler/zlib.git"
}
},
"1.1.1": {
"depends": [],
"description": "A massively spiffy yet delicately unobtrusive compression library",
"git": {
"auto-lib": "zlib/zlib",
"ref": "v1.1.1",
"transform": [
{
"move": {
"exclude": [],
"from": ".",
"include": [
"*.c",
"*.h"
],
"strip-components": 0,
"to": "src/"
}
},
{
"move": {
"exclude": [],
"from": "src/",
"include": [
"zlib.h",
"zconf.h"
],
"strip-components": 0,
"to": "include/"
}
}
],
"url": "https://github.com/madler/zlib.git"
}
},
"1.1.2": {
"depends": [],
"description": "A massively spiffy yet delicately unobtrusive compression library",
"git": {
"auto-lib": "zlib/zlib",
"ref": "v1.1.2",
"transform": [
{
"move": {
"exclude": [],
"from": ".",
"include": [
"*.c",
"*.h"
],
"strip-components": 0,
"to": "src/"
}
},
{
"move": {
"exclude": [],
"from": "src/",
"include": [
"zlib.h",
"zconf.h"
],
"strip-components": 0,
"to": "include/"
}
}
],
"url": "https://github.com/madler/zlib.git"
}
},
"1.1.3": {
"depends": [],
"description": "A massively spiffy yet delicately unobtrusive compression library",
"git": {
"auto-lib": "zlib/zlib",
"ref": "v1.1.3",
"transform": [
{
"move": {
"exclude": [],
"from": ".",
"include": [
"*.c",
"*.h"
],
"strip-components": 0,
"to": "src/"
}
},
{
"move": {
"exclude": [],
"from": "src/",
"include": [
"zlib.h",
"zconf.h"
],
"strip-components": 0,
"to": "include/"
}
}
],
"url": "https://github.com/madler/zlib.git"
}
},
"1.1.4": {
"depends": [],
"description": "A massively spiffy yet delicately unobtrusive compression library",
"git": {
"auto-lib": "zlib/zlib",
"ref": "v1.1.4",
"transform": [
{
"move": {
"exclude": [],
"from": ".",
"include": [
"*.c",
"*.h"
],
"strip-components": 0,
"to": "src/"
}
},
{
"move": {
"exclude": [],
"from": "src/",
"include": [
"zlib.h",
"zconf.h"
],
"strip-components": 0,
"to": "include/"
}
}
],
"url": "https://github.com/madler/zlib.git"
}
},
"1.2.0": {
"depends": [],
"description": "A massively spiffy yet delicately unobtrusive compression library",

+ 5
- 0
library.jsonc View File

@@ -13,5 +13,10 @@
"vob/json5",
"vob/semester",
"hanickadot/ctre",
// "neo/io",
// Explicit zlib link is required due to linker input order bug.
// Can be removed after alpha.5
"zlib/zlib",
"neo/compress"
]
}

+ 15
- 14
package.jsonc View File

@@ -3,19 +3,20 @@
"name": "dds",
"version": "0.1.0-alpha.4",
"namespace": "dds",
"depends": {
"spdlog": "1.7.0",
"ms-wil": "2020.3.16",
"range-v3": "0.11.0",
"nlohmann-json": "3.7.1",
"neo-sqlite3": "0.2.3",
"neo-fun": "0.3.2",
"semver": "0.2.2",
"pubgrub": "0.2.1",
"vob-json5": "0.1.5",
"vob-semester": "0.2.1",
"ctre": "2.8.1",
"fmt": "^7.0.0"
},
"depends": [
"spdlog@1.7.0",
"ms-wil@2020.3.16",
"range-v3@0.11.0",
"nlohmann-json@3.7.1",
"neo-sqlite3@0.2.3",
"neo-fun^0.3.2",
"neo-compress^0.1.0",
"semver@0.2.2",
"pubgrub@0.2.1",
"vob-json5@0.1.5",
"vob-semester@0.2.1",
"ctre@2.8.1",
"fmt^7.0.3"
],
"test_driver": "Catch-Main"
}

+ 61
- 9
src/dds.main.cpp View File

@@ -450,6 +450,47 @@ struct cli_repo {
}
} ls{*this};

struct {
cli_repo& parent;
args::Command cmd{parent.repo_group,
"import",
"Import a source distribution archive file into the repository"};
common_flags _common{cmd};

args::PositionalList<dds::fs::path>
sdist_paths{cmd, "sdist-path", "Path to one or more source distribution archive"};

args::Flag force{cmd,
"replace-if-exists",
"Replace an existing package in the repository",
{"replace"}};

args::Flag import_stdin{cmd,
"import-stdin",
"Import a source distribution tarball from stdin",
{"stdin"}};

int run() {
auto import_sdists = [&](dds::repository repo) {
auto if_exists_action
= force.Get() ? dds::if_exists::replace : dds::if_exists::throw_exc;
for (auto& tgz_path : sdist_paths.Get()) {
auto tmp_sd = dds::expand_sdist_targz(tgz_path);
repo.add_sdist(tmp_sd.sdist, if_exists_action);
}
if (import_stdin) {
auto tmp_sd = dds::expand_sdist_from_istream(std::cin, "<stdin>");
repo.add_sdist(tmp_sd.sdist, if_exists_action);
}
return 0;
};
return dds::repository::with_repository(parent.where.Get(),
dds::repo_flags::write_lock
| dds::repo_flags::create_if_absent,
import_sdists);
}
} import_{*this};

struct {
cli_repo& parent;
args::Command cmd{parent.repo_group, "init", "Initialize a directory as a repository"};
@@ -471,6 +512,8 @@ struct cli_repo {
return ls.run();
} else if (init.cmd) {
return init.run();
} else if (import_.cmd) {
return import_.run();
} else {
assert(false);
std::terminate();
@@ -502,11 +545,7 @@ struct cli_sdist {

common_project_flags project{cmd};

path_flag out{cmd,
"out",
"The destination of the source distribution",
{"out"},
dds::fs::current_path() / "project.dsd"};
path_flag out{cmd, "out", "The destination of the source distribution", {"out"}};

args::Flag force{cmd,
"replace-if-exists",
@@ -515,10 +554,23 @@ struct cli_sdist {

int run() {
dds::sdist_params params;
params.project_dir = project.root.Get();
params.dest_path = out.Get();
params.force = force.Get();
dds::create_sdist(params);
params.project_dir = project.root.Get();
params.dest_path = out.Get();
params.force = force.Get();
params.include_apps = true;
params.include_tests = true;
auto pkg_man = dds::package_manifest::load_from_directory(project.root.Get());
if (!pkg_man) {
dds::throw_user_error<dds::errc::invalid_pkg_manifest>(
"Creating a source distribution requires a package manifest");
}
std::string default_filename = fmt::format("{}@{}.tar.gz",
pkg_man->pkg_id.name,
pkg_man->pkg_id.version.to_string());
auto default_filepath = dds::fs::current_path() / default_filename;
auto out_path = out.Matched() ? out.Get() : default_filepath;
dds::create_sdist_targz(out_path, params);
dds_log(info, "Generate source distribution at [{}]", out_path.string());
return 0;
}
} create{*this};

+ 0
- 5
src/dds/catalog/get.hpp View File

@@ -9,11 +9,6 @@ class repository;
class catalog;
struct package_info;

struct temporary_sdist {
temporary_dir tmpdir;
dds::sdist sdist;
};

temporary_sdist get_package_sdist(const package_info&);

void get_all(const std::vector<package_id>& pkgs, dds::repository& repo, const catalog& cat);

+ 19
- 3557
src/dds/catalog/init_catalog.cpp
File diff suppressed because it is too large
View File


+ 32
- 0
src/dds/source/dist.cpp View File

@@ -9,6 +9,7 @@
#include <libman/parse.hpp>

#include <neo/assert.hpp>
#include <neo/tar/util.hpp>
#include <range/v3/algorithm/sort.hpp>
#include <range/v3/range/conversion.hpp>
#include <range/v3/view/filter.hpp>
@@ -82,6 +83,21 @@ sdist dds::create_sdist(const sdist_params& params) {
return sdist::from_directory(dest);
}

void dds::create_sdist_targz(path_ref filepath, const sdist_params& params) {
if (fs::exists(filepath)) {
if (!params.force) {
throw_user_error<errc::sdist_exists>("Destination path '{}' already exists",
filepath.string());
}
}

auto tempdir = temporary_dir::create();
dds_log(debug, "Generating source distribution in {}", tempdir.path().string());
create_sdist_in_dir(tempdir.path(), params);
fs::create_directories(filepath.parent_path());
neo::compress_directory_targz(tempdir.path(), filepath);
}

sdist dds::create_sdist_in_dir(path_ref out, const sdist_params& params) {
auto libs = collect_libraries(params.project_dir);

@@ -113,3 +129,19 @@ sdist sdist::from_directory(path_ref where) {
where.string());
return sdist{pkg_man.value(), where};
}

temporary_sdist dds::expand_sdist_targz(path_ref targz_path) {
auto tempdir = temporary_dir::create();
dds_log(debug, "Expanding source ditsribution content into {}", tempdir.path().string());
fs::create_directories(tempdir.path());
neo::expand_directory_targz(tempdir.path(), targz_path);
return {tempdir, sdist::from_directory(tempdir.path())};
}

temporary_sdist dds::expand_sdist_from_istream(std::istream& is, std::string_view input_name) {
auto tempdir = temporary_dir::create();
dds_log(debug, "Expanding source ditsribution content into {}", tempdir.path().string());
fs::create_directories(tempdir.path());
neo::expand_directory_targz(tempdir.path(), is, input_name);
return {tempdir, sdist::from_directory(tempdir.path())};
}

+ 11
- 1
src/dds/source/dist.hpp View File

@@ -3,6 +3,7 @@
#include <tuple>

#include <dds/package/manifest.hpp>
#include <dds/temp.hpp>
#include <dds/util/fs.hpp>

namespace dds {
@@ -26,6 +27,11 @@ struct sdist {
static sdist from_directory(path_ref p);
};

struct temporary_sdist {
temporary_dir tmpdir;
struct sdist sdist;
};

inline constexpr struct sdist_compare_t {
bool operator()(const sdist& lhs, const sdist& rhs) const {
return lhs.manifest.pkg_id < rhs.manifest.pkg_id;
@@ -41,5 +47,9 @@ inline constexpr struct sdist_compare_t {

sdist create_sdist(const sdist_params&);
sdist create_sdist_in_dir(path_ref, const sdist_params&);
void create_sdist_targz(path_ref, const sdist_params&);

temporary_sdist expand_sdist_targz(path_ref targz);
temporary_sdist expand_sdist_from_istream(std::istream&, std::string_view input_name);

} // namespace dds
} // namespace dds

+ 6
- 6
tests/dds.py View File

@@ -104,12 +104,9 @@ class DDS:
)

def sdist_create(self) -> subprocess.CompletedProcess:
return self.run([
'sdist',
'create',
self.project_dir_arg,
f'--out={self.build_dir / "created-sdist.sds"}',
])
self.build_dir.mkdir(exist_ok=True, parents=True)
return self.run(['sdist', 'create', self.project_dir_arg],
cwd=self.build_dir)

def sdist_export(self) -> subprocess.CompletedProcess:
return self.run([
@@ -119,6 +116,9 @@ class DDS:
self.repo_dir_arg,
])

def repo_import(self, sdist: Path) -> subprocess.CompletedProcess:
return self.run(['repo', self.repo_dir_arg, 'import', sdist])

@property
def default_builtin_toolchain(self) -> str:
if os.name == 'posix':

+ 16
- 8
tests/sdist/sdist_test.py View File

@@ -1,16 +1,24 @@
from tests.dds import DDS, dds_fixture_conf_1


@dds_fixture_conf_1('create')
def test_create_sdist(dds: DDS):
dds.sdist_create()
sd_dir = dds.build_dir / 'created-sdist.sds'
assert sd_dir.is_dir()
foo_cpp = sd_dir / 'src/foo.cpp'
assert foo_cpp.is_file()
header_hpp = sd_dir / 'include/header.hpp'
assert header_hpp.is_file()
header_h = sd_dir / 'include/header.h'
assert header_h.is_file()
sd_dir = dds.build_dir / 'foo@1.2.3.tar.gz'
assert sd_dir.is_file()


@dds_fixture_conf_1('create')
def test_export_sdist(dds: DDS):
dds.sdist_export()
assert (dds.repo_dir / 'foo@1.2.3').is_dir()


@dds_fixture_conf_1('create')
def test_import_sdist_archive(dds: DDS):
repo_content_path = dds.repo_dir / 'foo@1.2.3'
assert not repo_content_path.is_dir()
dds.sdist_create()
assert not repo_content_path.is_dir()
dds.repo_import(dds.build_dir / 'foo@1.2.3.tar.gz')
assert repo_content_path.is_dir()

+ 80
- 76
tools/gen-catalog-json.py View File

@@ -1,4 +1,5 @@
import argparse
import gzip
import os
import json
import json5
@@ -272,18 +273,26 @@ def many_versions(name: str,

# yapf: disable
PACKAGES = [
github_package('neo-sqlite3', 'vector-of-bool/neo-sqlite3', ['0.2.3', '0.3.0']),
github_package('neo-fun', 'vector-of-bool/neo-fun', ['0.1.1', '0.2.0', '0.2.1', '0.3.0', '0.3.1', '0.3.2', '0.4.0']),
github_package('neo-buffer', 'vector-of-bool/neo-buffer',
['0.2.1', '0.3.0', '0.4.0', '0.4.1']),
github_package('neo-compress', 'vector-of-bool/neo-compress', ['0.1.0']),
github_package('neo-sqlite3', 'vector-of-bool/neo-sqlite3',
['0.2.3', '0.3.0']),
github_package('neo-fun', 'vector-of-bool/neo-fun', [
'0.1.1', '0.2.0', '0.2.1', '0.3.0', '0.3.1', '0.3.2', '0.4.0', '0.4.1'
]),
github_package('neo-concepts', 'vector-of-bool/neo-concepts', (
'0.2.2',
'0.3.0',
'0.3.1',
'0.3.2',
)),
'0.2.2',
'0.3.0',
'0.3.1',
'0.3.2',
'0.4.0',
)),
github_package('semver', 'vector-of-bool/semver', ['0.2.2']),
github_package('pubgrub', 'vector-of-bool/pubgrub', ['0.2.1']),
github_package('vob-json5', 'vector-of-bool/json5', ['0.1.5']),
github_package('vob-semester', 'vector-of-bool/semester', ['0.1.0', '0.1.1', '0.2.0', '0.2.1']),
github_package('vob-semester', 'vector-of-bool/semester',
['0.1.0', '0.1.1', '0.2.0', '0.2.1']),
many_versions(
'magic_enum',
(
@@ -438,6 +447,8 @@ PACKAGES = [
'6.2.1',
'7.0.0',
'7.0.1',
'7.0.2',
'7.0.3',
),
git_url='https://github.com/fmtlib/fmt.git',
auto_lib='fmt/fmt',
@@ -568,63 +579,47 @@ PACKAGES = [
('2020.2.25', '20200225.2'),
]
]),
Package(
'zlib',
[
Version(
ver,
description=
'A massively spiffy yet delicately unobtrusive compression library',
remote=Git(
'https://github.com/madler/zlib.git',
tag or f'v{ver}',
auto_lib='zlib/zlib',
transforms=[
FSTransform(
move=CopyMoveTransform(
frm='.',
to='src/',
include=[
'*.c',
'*.h',
],
)),
FSTransform(
move=CopyMoveTransform(
frm='src/',
to='include/',
include=['zlib.h', 'zconf.h'],
)),
]),
) for ver, tag in [
('1.2.11', None),
('1.2.10', None),
('1.2.9', None),
('1.2.8', None),
('1.2.7', 'v1.2.7.3'),
('1.2.6', 'v1.2.6.1'),
('1.2.5', 'v1.2.5.3'),
('1.2.4', 'v1.2.4.5'),
('1.2.3', 'v1.2.3.8'),
('1.2.2', 'v1.2.2.4'),
('1.2.1', 'v1.2.1.2'),
('1.2.0', 'v1.2.0.8'),
('1.1.4', None),
('1.1.3', None),
('1.1.2', None),
('1.1.1', None),
('1.1.0', None),
('1.0.9', None),
('1.0.8', None),
('1.0.7', None),
# ('1.0.6', None), # Does not exist
('1.0.5', None),
('1.0.4', None),
# ('1.0.3', None), # Does not exist
('1.0.2', None),
('1.0.1', None),
]
]),
Package('zlib', [
Version(
ver,
description=
'A massively spiffy yet delicately unobtrusive compression library',
remote=Git(
'https://github.com/madler/zlib.git',
tag or f'v{ver}',
auto_lib='zlib/zlib',
transforms=[
FSTransform(
move=CopyMoveTransform(
frm='.',
to='src/',
include=[
'*.c',
'*.h',
],
)),
FSTransform(
move=CopyMoveTransform(
frm='src/',
to='include/',
include=['zlib.h', 'zconf.h'],
)),
]),
) for ver, tag in [
('1.2.11', None),
('1.2.10', None),
('1.2.9', None),
('1.2.8', None),
('1.2.7', 'v1.2.7.3'),
('1.2.6', 'v1.2.6.1'),
('1.2.5', 'v1.2.5.3'),
('1.2.4', 'v1.2.4.5'),
('1.2.3', 'v1.2.3.8'),
('1.2.2', 'v1.2.2.4'),
('1.2.1', 'v1.2.1.2'),
('1.2.0', 'v1.2.0.8'),
]
]),
Package('sol2', [
Version(
ver,
@@ -954,31 +949,40 @@ if __name__ == "__main__":
#include <dds/catalog/init_catalog.hpp>
#include <dds/catalog/import.hpp>

#include <neo/gzip.hpp>
#include <neo/transform_io.hpp>
#include <neo/string_io.hpp>
#include <neo/inflate.hpp>

/**
* The following array of integers is generated and contains the JSON
* encoded initial catalog. MSVC can't handle string literals over
* The following array of integers is generated and contains gzip-compressed
* JSON encoded initial catalog. MSVC can't handle string literals over
* 64k large, so we have to resort to using a regular char array:
*/
static constexpr const char INIT_PACKAGES_CONTENT[] = {
static constexpr const unsigned char INIT_PACKAGES_CONTENT[] = {
@JSON@
};

static constexpr int INIT_PACKAGES_STR_LEN = @JSON_LEN@;

const std::vector<dds::package_info>&
dds::init_catalog_packages() noexcept {
using std::nullopt;
static auto pkgs = dds::parse_packages_json(
std::string_view(INIT_PACKAGES_CONTENT, INIT_PACKAGES_STR_LEN));
static auto pkgs = []{
using namespace neo;
string_dynbuf_io str_out;
buffer_copy(str_out,
buffer_transform_source{
buffers_consumer(as_buffer(INIT_PACKAGES_CONTENT)),
gzip_decompressor{inflate_decompressor{}}},
@JSON_LEN@);
return dds::parse_packages_json(str_out.read_area_view());
}();
return pkgs;
}
''')

json_small = json.dumps(data, sort_keys=True)
json_small_arr = ', '.join(str(ord(c)) for c in json_small)

json_small_arr = '\n'.join(textwrap.wrap(json_small_arr, width=120))
json_small_arr = textwrap.indent(json_small_arr, prefix=' ' * 4)
json_compr = gzip.compress(json_small.encode('utf-8'), compresslevel=9)
json_small_arr = ','.join(str(c) for c in json_compr)

cpp_content = cpp_template.replace('@JSON@', json_small_arr).replace(
'@JSON_LEN@', str(len(json_small)))

Loading…
Cancel
Save