Browse Source

Add an "initial catalog" with several popular and useful libraries

default_compile_flags
vector-of-bool 4 years ago
parent
commit
b305b60e94
8 changed files with 11586 additions and 676 deletions
  1. +3384
    -243
      catalog.json
  2. +3384
    -243
      catalog.old.json
  3. +1
    -1
      package.jsonc
  4. +111
    -86
      src/dds/catalog/catalog.cpp
  5. +0
    -3
      src/dds/catalog/catalog.hpp
  6. +3988
    -0
      src/dds/catalog/init_catalog.cpp
  7. +11
    -0
      src/dds/catalog/init_catalog.hpp
  8. +707
    -100
      tools/gen-catalog-json.py

+ 3384
- 243
catalog.json
File diff suppressed because it is too large
View File


+ 3384
- 243
catalog.old.json
File diff suppressed because it is too large
View File


+ 1
- 1
package.jsonc View File

"pubgrub": "0.2.1", "pubgrub": "0.2.1",
"vob-json5": "0.1.5", "vob-json5": "0.1.5",
"vob-semester": "0.2.1", "vob-semester": "0.2.1",
"ctre": "2.7.0",
"ctre": "2.8.1",
}, },
"test_driver": "Catch-Main" "test_driver": "Catch-Main"
} }

+ 111
- 86
src/dds/catalog/catalog.cpp View File



#include "./import.hpp" #include "./import.hpp"


#include <dds/catalog/init_catalog.hpp>
#include <dds/dym.hpp> #include <dds/dym.hpp>
#include <dds/error/errors.hpp> #include <dds/error/errors.hpp>
#include <dds/solve/solve.hpp> #include <dds/solve/solve.hpp>
)"); )");
} }


std::string transforms_to_json(const std::vector<fs_transformation>& trs) {
std::string acc = "[";
for (auto it = trs.begin(); it != trs.end(); ++it) {
acc += it->as_json();
if (std::next(it) != trs.end()) {
acc += ", ";
}
}
return acc + "]";
}

void store_with_remote(const neo::sqlite3::statement_cache&,
const package_info& pkg,
std::monostate) {
neo_assert_always(
invariant,
false,
"There was an attempt to insert a package listing into the database where that package "
"listing does not have a remote listing. If you see this message, it is a dds bug.",
pkg.ident.to_string());
}

void store_with_remote(neo::sqlite3::statement_cache& stmts,
const package_info& pkg,
const git_remote_listing& git) {
auto lm_usage = git.auto_lib.value_or(lm::usage{});
sqlite3::exec( //
stmts,
R"(
INSERT OR REPLACE INTO dds_cat_pkgs (
name,
version,
git_url,
git_ref,
lm_name,
lm_namespace,
description,
repo_transform
) VALUES (
?1,
?2,
?3,
?4,
CASE WHEN ?5 = '' THEN NULL ELSE ?5 END,
CASE WHEN ?6 = '' THEN NULL ELSE ?6 END,
?7,
?8
)
)"_sql,
std::forward_as_tuple( //
pkg.ident.name,
pkg.ident.version.to_string(),
git.url,
git.ref,
lm_usage.name,
lm_usage.namespace_,
pkg.description,
transforms_to_json(git.transforms)));
}

void do_store_pkg(neo::sqlite3::database& db,
neo::sqlite3::statement_cache& st_cache,
const package_info& pkg) {
std::visit([&](auto&& remote) { store_with_remote(st_cache, pkg, remote); }, pkg.remote);
auto db_pkg_id = db.last_insert_rowid();
auto& new_dep_st = st_cache(R"(
INSERT INTO dds_cat_pkg_deps (
pkg_id,
dep_name,
low,
high
) VALUES (
?,
?,
?,
?
)
)"_sql);
for (const auto& dep : pkg.deps) {
new_dep_st.reset();
assert(dep.versions.num_intervals() == 1);
auto iv_1 = *dep.versions.iter_intervals().begin();
sqlite3::exec(new_dep_st,
std::forward_as_tuple(db_pkg_id,
dep.name,
iv_1.low.to_string(),
iv_1.high.to_string()));
}
}

void store_init_packages(sqlite3::database& db, sqlite3::statement_cache& st_cache) {
for (auto& pkg : init_catalog_packages()) {
do_store_pkg(db, st_cache, pkg);
}
}

void ensure_migrated(sqlite3::database& db) { void ensure_migrated(sqlite3::database& db) {
sqlite3::transaction_guard tr{db}; sqlite3::transaction_guard tr{db};
db.exec(R"( db.exec(R"(
constexpr int current_database_version = 2; constexpr int current_database_version = 2;


int version = version_; int version = version_;

// If this is the first time we're working here, import the initial
// catalog with some useful tidbits.
bool import_init_packages = version == 0;

if (version > current_database_version) { if (version > current_database_version) {
throw_external_error<errc::catalog_too_new>(); throw_external_error<errc::catalog_too_new>();
} }
} }
meta["version"] = 2; meta["version"] = 2;
exec(db, "UPDATE dds_cat_meta SET meta=?", std::forward_as_tuple(meta.dump())); exec(db, "UPDATE dds_cat_meta SET meta=?", std::forward_as_tuple(meta.dump()));

if (import_init_packages) {
spdlog::info(
"A new catalog database case been created, and has been populated with some initial "
"contents.");
neo::sqlite3::statement_cache stmts{db};
store_init_packages(db, stmts);
}
} }


void check_json(bool b, std::string_view what) { void check_json(bool b, std::string_view what) {
catalog::catalog(sqlite3::database db) catalog::catalog(sqlite3::database db)
: _db(std::move(db)) {} : _db(std::move(db)) {}


void catalog::_store_pkg(const package_info& pkg, std::monostate) {
neo_assert_always(
invariant,
false,
"There was an attempt to insert a package listing into the database where that package "
"listing does not have a remote listing. If you see this message, it is a dds bug.",
pkg.ident.to_string());
}

namespace {

std::string transforms_to_json(const std::vector<fs_transformation>& trs) {
std::string acc = "[";
for (auto it = trs.begin(); it != trs.end(); ++it) {
acc += it->as_json();
if (std::next(it) != trs.end()) {
acc += ", ";
}
}
return acc + "]";
}

} // namespace

void catalog::_store_pkg(const package_info& pkg, const git_remote_listing& git) {
auto lm_usage = git.auto_lib.value_or(lm::usage{});
sqlite3::exec( //
_stmt_cache,
R"(
INSERT OR REPLACE INTO dds_cat_pkgs (
name,
version,
git_url,
git_ref,
lm_name,
lm_namespace,
description,
repo_transform
) VALUES (
?1,
?2,
?3,
?4,
CASE WHEN ?5 = '' THEN NULL ELSE ?5 END,
CASE WHEN ?6 = '' THEN NULL ELSE ?6 END,
?7,
?8
)
)"_sql,
std::forward_as_tuple( //
pkg.ident.name,
pkg.ident.version.to_string(),
git.url,
git.ref,
lm_usage.name,
lm_usage.namespace_,
pkg.description,
transforms_to_json(git.transforms)));
}

void catalog::store(const package_info& pkg) { void catalog::store(const package_info& pkg) {
sqlite3::transaction_guard tr{_db}; sqlite3::transaction_guard tr{_db};


std::visit([&](auto&& remote) { _store_pkg(pkg, remote); }, pkg.remote);

auto db_pkg_id = _db.last_insert_rowid();
auto& new_dep_st = _stmt_cache(R"(
INSERT INTO dds_cat_pkg_deps (
pkg_id,
dep_name,
low,
high
) VALUES (
?,
?,
?,
?
)
)"_sql);
for (const auto& dep : pkg.deps) {
new_dep_st.reset();
assert(dep.versions.num_intervals() == 1);
auto iv_1 = *dep.versions.iter_intervals().begin();
sqlite3::exec(new_dep_st,
std::forward_as_tuple(db_pkg_id,
dep.name,
iv_1.low.to_string(),
iv_1.high.to_string()));
}
do_store_pkg(_db, _stmt_cache, pkg);
} }


std::optional<package_info> catalog::get(const package_id& pk_id) const noexcept { std::optional<package_info> catalog::get(const package_id& pk_id) const noexcept {

+ 0
- 3
src/dds/catalog/catalog.hpp View File

explicit catalog(neo::sqlite3::database db); explicit catalog(neo::sqlite3::database db);
catalog(const catalog&) = delete; catalog(const catalog&) = delete;


void _store_pkg(const package_info&, const git_remote_listing&);
void _store_pkg(const package_info&, std::monostate);

public: public:
catalog(catalog&&) = default; catalog(catalog&&) = default;
catalog& operator=(catalog&&) = default; catalog& operator=(catalog&&) = default;

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


+ 11
- 0
src/dds/catalog/init_catalog.hpp View File

#pragma once

#include "./package_info.hpp"

#include <vector>

namespace dds {

const std::vector<package_info>& init_catalog_packages() noexcept;

} // namespace dds

+ 707
- 100
tools/gen-catalog-json.py View File

import argparse import argparse
import json import json
import itertools
from typing import NamedTuple, Tuple, List, Sequence, Union, Optional, Mapping from typing import NamedTuple, Tuple, List, Sequence, Union, Optional, Mapping
from pathlib import Path
import sys import sys
import textwrap import textwrap




class CopyMoveTransform(NamedTuple):
frm: str
to: str
strip_components: int = 0
include: Sequence[str] = []
exclude: Sequence[str] = []

def to_dict(self):
return {
'from': self.frm,
'to': self.to,
'include': self.include,
'exclude': self.exclude,
'strip-components': self.strip_components,
}


class OneEdit(NamedTuple):
kind: str
line: int
content: Optional[str] = None

def to_dict(self):
d = {
'kind': self.kind,
'line': self.line,
}
if self.content:
d['content'] = self.content
return d


class EditTransform(NamedTuple):
path: str
edits: Sequence[OneEdit] = []

def to_dict(self):
return {
'path': self.path,
'edits': [e.to_dict() for e in self.edits],
}


class WriteTransform(NamedTuple):
path: str
content: str

def to_dict(self):
return {
'path': self.path,
'content': self.content,
}


class RemoveTransform(NamedTuple):
path: str
only_matching: Sequence[str] = ()

def to_dict(self):
return {
'path': self.path,
'only-matching': self.only_matching,
}


class FSTransform(NamedTuple):
copy: Optional[CopyMoveTransform] = None
move: Optional[CopyMoveTransform] = None
remove: Optional[RemoveTransform] = None
write: Optional[WriteTransform] = None
edit: Optional[EditTransform] = None

def to_dict(self):
d = {}
if self.copy:
d['copy'] = self.copy.to_dict()
if self.move:
d['move'] = self.move.to_dict()
if self.remove:
d['remove'] = self.remove.to_dict()
if self.write:
d['write'] = self.write.to_dict()
if self.edit:
d['edit'] = self.edit.to_dict()
return d


class Git(NamedTuple): class Git(NamedTuple):
url: str url: str
ref: str ref: str
auto_lib: Optional[str] = None auto_lib: Optional[str] = None
transforms: Sequence[FSTransform] = []


def to_dict(self) -> dict: def to_dict(self) -> dict:
d = { d = {
'url': self.url, 'url': self.url,
'ref': self.ref, 'ref': self.ref,
'transform': [f.to_dict() for f in self.transforms],
} }
if self.auto_lib: if self.auto_lib:
d['auto-lib'] = self.auto_lib d['auto-lib'] = self.auto_lib
return ret return ret




class VersionSet(NamedTuple):
version: str
depends: Sequence[Tuple[str, str]]


class Package(NamedTuple): class Package(NamedTuple):
name: str name: str
versions: List[Version] versions: List[Version]




def simple_packages(name: str,
description: str,
git_url: str,
versions: Sequence[VersionSet],
auto_lib: Optional[str] = None,
*,
tag_fmt: str = '{}') -> Package:
return Package(name, [
Version(
ver.version,
description=description,
remote=Git(
git_url, tag_fmt.format(ver.version), auto_lib=auto_lib),
depends={dep_name: dep_rng
for dep_name, dep_rng in ver.depends}) for ver in versions
])


def many_versions(name: str, def many_versions(name: str,
versions: Sequence[str], versions: Sequence[str],
*, *,
tag_fmt: str = '{}', tag_fmt: str = '{}',
git_url: str, git_url: str,
auto_lib: str = None, auto_lib: str = None,
transforms: Sequence[FSTransform] = (),
description='(No description was provided)') -> Package: description='(No description was provided)') -> Package:
return Package(name, [ return Package(name, [
Version( Version(
ver, ver,
description='\n'.join(textwrap.wrap(description)), description='\n'.join(textwrap.wrap(description)),
remote=Git( remote=Git(
url=git_url, ref=tag_fmt.format(ver), auto_lib=auto_lib))
for ver in versions
url=git_url,
ref=tag_fmt.format(ver),
auto_lib=auto_lib,
transforms=transforms)) for ver in versions
]) ])




PACKAGES = [ PACKAGES = [
many_versions(
'magic_enum',
(
'0.5.0',
'0.6.0',
'0.6.1',
'0.6.2',
'0.6.3',
'0.6.4',
'0.6.5',
'0.6.6',
),
description='Static reflection for enums',
tag_fmt='v{}',
git_url='https://github.com/Neargye/magic_enum.git',
auto_lib='neargye/magic_enum',
),
many_versions(
'nameof',
[
'0.8.3',
'0.9.0',
'0.9.1',
'0.9.2',
'0.9.3',
'0.9.4',
],
description='Nameof operator for modern C++',
tag_fmt='v{}',
git_url='https://github.com/Neargye/nameof.git',
auto_lib='neargye/nameof',
),
many_versions( many_versions(
'range-v3', 'range-v3',
( (
many_versions( many_versions(
'nlohmann-json', 'nlohmann-json',
( (
'3.0.0',
'3.0.1',
'3.1.0',
'3.1.1',
'3.1.2',
'3.2.0',
'3.3.0',
'3.4.0',
'3.5.0',
'3.6.0',
'3.6.1',
'3.7.0',
'3.7.1',
'3.7.2',
'3.7.3',
# '3.0.0',
# '3.0.1',
# '3.1.0',
# '3.1.1',
# '3.1.2',
# '3.2.0',
# '3.3.0',
# '3.4.0',
# '3.5.0',
# '3.6.0',
# '3.6.1',
# '3.7.0',
'3.7.1', # Only this version has the dds forked branch
# '3.7.2',
# '3.7.3',
), ),
git_url='https://github.com/vector-of-bool/json.git', git_url='https://github.com/vector-of-bool/json.git',
tag_fmt='dds/{}', tag_fmt='dds/{}',
'0.2.1', '0.2.1',
'0.2.2', '0.2.2',
'0.2.3', '0.2.3',
'0.3.0',
), ),
description='A modern and low-level C++ SQLite API', description='A modern and low-level C++ SQLite API',
git_url='https://github.com/vector-of-bool/neo-sqlite3.git', git_url='https://github.com/vector-of-bool/neo-sqlite3.git',
description='A C++ implementation of a JSON5 parser', description='A C++ implementation of a JSON5 parser',
git_url='https://github.com/vector-of-bool/json5.git', git_url='https://github.com/vector-of-bool/json5.git',
), ),
Package('vob-semester', [
Version(
'0.1.0',
description='A C++ library to process recursive dynamic data',
remote=Git('https://github.com/vector-of-bool/semester.git',
'0.1.0'),
depends={
'neo-fun': '^0.1.0',
'neo-concepts': '^0.2.1',
}),
Version(
'0.1.1',
description='A C++ library to process recursive dynamic data',
remote=Git('https://github.com/vector-of-bool/semester.git',
'0.1.1'),
depends={
'neo-fun': '^0.1.1',
'neo-concepts': '^0.2.2',
}),
Version(
'0.2.0',
description='A C++ library to process recursive dynamic data',
remote=Git('https://github.com/vector-of-bool/semester.git',
'0.2.0'),
depends={
'neo-fun': '^0.3.2',
'neo-concepts': '^0.3.2',
}),
Version(
'0.2.1',
description='A C++ library to process recursive dynamic data',
remote=Git('https://github.com/vector-of-bool/semester.git',
'0.2.1'),
depends={
'neo-fun': '^0.3.2',
'neo-concepts': '^0.3.2',
}),
]),
Package('ctre', [
Version(
'2.7.0',
description=
'A compile-time PCRE (almost) compatible regular expression matcher',
remote=Git(
'https://github.com/hanickadot/compile-time-regular-expressions.git',
'v2.7',
auto_lib='hanickadot/ctre',
))
]),
simple_packages(
'vob-semester',
description='A C++ library to process recursive dynamic data',
git_url='https://github.com/vector-of-bool/semester.git',
versions=[
VersionSet('0.1.0', [
('neo-fun', '^0.1.0'),
('neo-concepts', '^0.2.1'),
]),
VersionSet('0.1.1', [
('neo-fun', '^0.1.1'),
('neo-concepts', '^0.2.2'),
]),
VersionSet('0.2.0', [
('neo-fun', '^0.3.2'),
('neo-concepts', '^0.3.2'),
]),
VersionSet('0.2.1', [
('neo-fun', '^0.3.2'),
('neo-concepts', '^0.3.2'),
]),
],
),
many_versions(
'ctre',
(
'2.8.1',
'2.8.2',
'2.8.3',
'2.8.4',
),
git_url=
'https://github.com/hanickadot/compile-time-regular-expressions.git',
tag_fmt='v{}',
auto_lib='hanickadot/ctre',
description=
'A compile-time PCRE (almost) compatible regular expression matcher',
),
many_versions( many_versions(
'spdlog', 'spdlog',
( (
'0.9.0',
'0.10.0',
'0.11.0',
'0.12.0',
'0.13.0',
'0.14.0',
'0.16.0',
'0.16.1',
'0.16.2',
'0.17.0',
'1.0.0', '1.0.0',
'1.1.0', '1.1.0',
'1.2.0', '1.2.0',
many_versions( many_versions(
'fmt', 'fmt',
( (
'0.8.0',
'0.9.0',
'0.10.0',
'0.12.0',
'1.0.0',
'1.1.0',
'2.0.0',
'2.0.1',
'2.1.0',
'2.1.1',
'3.0.0',
'3.0.1',
'3.0.2',
'4.0.0',
'4.1.0',
'5.0.0',
'5.1.0',
'5.2.0',
'5.2.1',
'5.3.0',
'6.0.0', '6.0.0',
'6.1.0', '6.1.0',
'6.1.1', '6.1.1',
'6.1.2', '6.1.2',
'6.2.0',
'6.2.1',
'7.0.0',
'7.0.1',
), ),
git_url='https://github.com/fmtlib/fmt.git', git_url='https://github.com/fmtlib/fmt.git',
auto_lib='fmt/fmt', auto_lib='fmt/fmt',
description='A modern formatting library : https://fmt.dev/', description='A modern formatting library : https://fmt.dev/',
), ),
Package('catch2', [
Version(
'2.12.4',
description='A modern C++ unit testing library',
remote=Git(
'https://github.com/catchorg/Catch2.git',
'v2.12.4',
auto_lib='catch2/catch2',
transforms=[
FSTransform(
move=CopyMoveTransform(
frm='include', to='include/catch2')),
FSTransform(
copy=CopyMoveTransform(frm='include', to='src'),
write=WriteTransform(
path='include/catch2/catch_with_main.hpp',
content='''
#pragma once

#define CATCH_CONFIG_MAIN
#include "./catch.hpp"

namespace Catch {

CATCH_REGISTER_REPORTER("console", ConsoleReporter)

}
''')),
]))
]),
Package('asio', [
Version(
ver,
description='Asio asynchronous I/O C++ library',
remote=Git(
'https://github.com/chriskohlhoff/asio.git',
f'asio-{ver.replace(".", "-")}',
auto_lib='asio/asio',
transforms=[
FSTransform(
move=CopyMoveTransform(
frm='asio/src',
to='src/',
),
remove=RemoveTransform(
path='src/',
only_matching=[
'doc/**',
'examples/**',
'tests/**',
'tools/**',
],
),
),
FSTransform(
move=CopyMoveTransform(
frm='asio/include/',
to='include/',
),
edit=EditTransform(
path='include/asio/detail/config.hpp',
edits=[
OneEdit(
line=13,
kind='insert',
content='#define ASIO_STANDALONE 1'),
OneEdit(
line=14,
kind='insert',
content=
'#define ASIO_SEPARATE_COMPILATION 1')
]),
),
]),
) for ver in [
'1.12.0',
'1.12.1',
'1.12.2',
'1.13.0',
'1.14.0',
'1.14.1',
'1.16.0',
'1.16.1',
]
]),
Package(
'abseil',
[
Version(
ver,
description='Abseil Common Libraries',
remote=Git(
'https://github.com/abseil/abseil-cpp.git',
tag,
auto_lib='abseil/abseil',
transforms=[
FSTransform(
move=CopyMoveTransform(
frm='absl',
to='src/absl/',
),
remove=RemoveTransform(
path='src/',
only_matching=[
'**/*_test.c*',
'**/*_testing.c*',
'**/*_benchmark.c*',
'**/benchmarks.c*',
'**/*_test_common.c*',
'**/mocking_*.c*',
# Misc files that should be removed:
'**/test_util.cc',
'**/mutex_nonprod.cc',
'**/named_generator.cc',
'**/print_hash_of.cc',
'**/*_gentables.cc',
]),
)
]),
) for ver, tag in [
('2018.6.0', '20180600'),
('2019.8.8', '20190808'),
('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('sol2', [
Version(
ver,
description=
'A C++ <-> Lua API wrapper with advanced features and top notch performance',
depends={'lua': '+0.0.0'},
remote=Git(
'https://github.com/ThePhD/sol2.git',
f'v{ver}',
transforms=[
FSTransform(
write=WriteTransform(
path='package.json',
content=json.dumps(
{
'name': 'sol2',
'namespace': 'sol2',
'version': ver,
'depends': [f'lua+0.0.0'],
},
indent=2,
)),
move=(None
if ver.startswith('3.') else CopyMoveTransform(
frm='sol',
to='src/sol',
)),
),
FSTransform(
write=WriteTransform(
path='library.json',
content=json.dumps(
{
'name': 'sol2',
'uses': ['lua/lua'],
},
indent=2,
))),
]),
) for ver in [
'3.2.1',
'3.2.0',
'3.0.3',
'3.0.2',
'2.20.6',
'2.20.5',
'2.20.4',
'2.20.3',
'2.20.2',
'2.20.1',
'2.20.0',
]
]),
Package('lua', [
Version(
ver,
description=
'Lua is a powerful and fast programming language that is easy to learn and use and to embed into your application.',
remote=Git(
'https://github.com/lua/lua.git',
f'v{ver}',
auto_lib='lua/lua',
transforms=[
FSTransform(
move=CopyMoveTransform(
frm='.',
to='src/',
include=['*.c', '*.h'],
))
]),
) for ver in [
'5.4.0',
'5.3.5',
'5.3.4',
'5.3.3',
'5.3.2',
'5.3.1',
'5.3.0',
'5.2.3',
'5.2.2',
'5.2.1',
'5.2.0',
'5.1.1',
]
]),
Package('pegtl', [
Version(
ver,
description='Parsing Expression Grammar Template Library',
remote=Git(
'https://github.com/taocpp/PEGTL.git',
ver,
auto_lib='tao/pegtl',
transforms=[FSTransform(remove=RemoveTransform(path='src/'))],
)) for ver in [
'2.8.3',
'2.8.2',
'2.8.1',
'2.8.0',
'2.7.1',
'2.7.0',
'2.6.1',
'2.6.0',
]
]),
many_versions(
'boost.pfr', ['1.0.0', '1.0.1'],
auto_lib='boost/pfr',
git_url='https://github.com/apolukhin/magic_get.git'),
many_versions(
'boost.leaf',
[
'0.1.0',
'0.2.0',
'0.2.1',
'0.2.2',
'0.2.3',
'0.2.4',
'0.2.5',
'0.3.0',
],
auto_lib='boost/leaf',
git_url='https://github.com/zajo/leaf.git',
),
many_versions(
'boost.mp11',
['1.70.0', '1.71.0', '1.72.0', '1.73.0'],
tag_fmt='boost-{}',
git_url='https://github.com/boostorg/mp11.git',
auto_lib='boost/mp11',
),
many_versions(
'libsodium', [
'1.0.10',
'1.0.11',
'1.0.12',
'1.0.13',
'1.0.14',
'1.0.15',
'1.0.16',
'1.0.17',
'1.0.18',
],
git_url='https://github.com/jedisct1/libsodium.git',
auto_lib='sodium/sodium',
description='Sodium is a new, easy-to-use software library '
'for encryption, decryption, signatures, password hashing and more.',
transforms=[
FSTransform(
move=CopyMoveTransform(
frm='src/libsodium/include', to='include/'),
edit=EditTransform(
path='include/sodium/export.h',
edits=[
OneEdit(
line=8,
kind='insert',
content='#define SODIUM_STATIC 1')
])),
FSTransform(
copy=CopyMoveTransform(
frm='builds/msvc/version.h',
to='include/sodium/version.h',
),
move=CopyMoveTransform(
frm='src/libsodium',
to='src/',
),
remove=RemoveTransform(path='src/libsodium'),
),
FSTransform(
copy=CopyMoveTransform(
frm='include', to='src/', strip_components=1)),
]),
many_versions(
'tomlpp',
[
'1.0.0',
'1.1.0',
'1.2.0',
'1.2.3',
'1.2.4',
'1.2.5',
'1.3.0',
# '1.3.2', # Wrong tag name in upstream
'1.3.3',
],
tag_fmt='v{}',
git_url='https://github.com/marzer/tomlplusplus.git',
auto_lib='tomlpp/tomlpp',
description=
'Header-only TOML config file parser and serializer for modern C++'),
Package('inja', [
*(Version(
ver,
description='A Template Engine for Modern C++',
remote=Git(
'https://github.com/pantor/inja.git',
f'v{ver}',
auto_lib='inja/inja')) for ver in ('1.0.0', '2.0.0', '2.0.1')),
*(Version(
ver,
description='A Template Engine for Modern C++',
depends={'nlohmann-json': '+0.0.0'},
remote=Git(
'https://github.com/pantor/inja.git',
f'v{ver}',
transforms=[
FSTransform(
write=WriteTransform(
path='package.json',
content=json.dumps({
'name':
'inja',
'namespace':
'inja',
'version':
ver,
'depends': [
'nlohmann-json+0.0.0',
]
}))),
FSTransform(
write=WriteTransform(
path='library.json',
content=json.dumps({
'name': 'inja',
'uses': ['nlohmann/json']
}))),
],
)) for ver in ('2.1.0', '2.2.0')),
]),
many_versions(
'cereal',
[
'0.9.0',
'0.9.1',
'1.0.0',
'1.1.0',
'1.1.1',
'1.1.2',
'1.2.0',
'1.2.1',
'1.2.2',
'1.3.0',
],
auto_lib='cereal/cereal',
git_url='https://github.com/USCiLab/cereal.git',
tag_fmt='v{}',
description='A C++11 library for serialization',
),
many_versions(
'pybind11',
[
'2.0.0',
'2.0.1',
'2.1.0',
'2.1.1',
'2.2.0',
'2.2.1',
'2.2.2',
'2.2.3',
'2.2.4',
'2.3.0',
'2.4.0',
'2.4.1',
'2.4.2',
'2.4.3',
'2.5.0',
],
git_url='https://github.com/pybind/pybind11.git',
description='Seamless operability between C++11 and Python',
auto_lib='pybind/pybind11',
tag_fmt='v{}',
),
Package('pcg-cpp', [
Version(
'0.98.1',
description='PCG Randum Number Generation, C++ Edition',
remote=Git(
url='https://github.com/imneme/pcg-cpp.git',
ref='v0.98.1',
auto_lib='pcg/pcg-cpp'))
]),
] ]


if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--new', action='store_true')
args = parser.parse_args() args = parser.parse_args()


data = {
data_old = {
'version': 1,
'packages': {
pkg.name:
{ver.version: ver.to_dict(new=False)
for ver in pkg.versions}
for pkg in PACKAGES
}
}
data_new = {
'version': 1, 'version': 1,
'packages': { 'packages': {
pkg.name: pkg.name:
{ver.version: ver.to_dict(new=args.new)
{ver.version: ver.to_dict(new=True)
for ver in pkg.versions} for ver in pkg.versions}
for pkg in PACKAGES for pkg in PACKAGES
} }
} }
Path('catalog.old.json').write_text(
json.dumps(data_old, indent=2, sort_keys=True))
new_json_str = json.dumps(data_new, indent=2, sort_keys=True)
Path('catalog.json').write_text(new_json_str)

cpp_template = textwrap.dedent(r'''
#include <dds/catalog/package_info.hpp>
#include <dds/catalog/init_catalog.hpp>
#include <dds/catalog/import.hpp>

static constexpr std::string_view INIT_PACKAGES_CONTENT= R"json(@JSON@)json";

const std::vector<dds::package_info>&
dds::init_catalog_packages() noexcept {
using std::nullopt;
static auto pkgs = dds::parse_packages_json(INIT_PACKAGES_CONTENT);
return pkgs;
}
''')


print(json.dumps(data, indent=2, sort_keys=True))
cpp_content = cpp_template.replace('@JSON@', new_json_str)
Path('src/dds/catalog/init_catalog.cpp').write_text(cpp_content)

Loading…
Cancel
Save