You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gen-catalog-json.py 29KB

пре 3 година
пре 4 година
пре 4 година
пре 4 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915
  1. import argparse
  2. import gzip
  3. import os
  4. import json
  5. import json5
  6. import itertools
  7. import base64
  8. from urllib import request, parse as url_parse
  9. from typing import NamedTuple, Tuple, List, Sequence, Union, Optional, Mapping, Iterable
  10. import re
  11. from pathlib import Path
  12. import sys
  13. import textwrap
  14. import requests
  15. from threading import local
  16. from concurrent.futures import ThreadPoolExecutor
  17. class CopyMoveTransform(NamedTuple):
  18. frm: str
  19. to: str
  20. strip_components: int = 0
  21. include: Sequence[str] = []
  22. exclude: Sequence[str] = []
  23. def to_dict(self):
  24. return {
  25. 'from': self.frm,
  26. 'to': self.to,
  27. 'include': self.include,
  28. 'exclude': self.exclude,
  29. 'strip-components': self.strip_components,
  30. }
  31. class OneEdit(NamedTuple):
  32. kind: str
  33. line: int
  34. content: Optional[str] = None
  35. def to_dict(self):
  36. d = {
  37. 'kind': self.kind,
  38. 'line': self.line,
  39. }
  40. if self.content:
  41. d['content'] = self.content
  42. return d
  43. class EditTransform(NamedTuple):
  44. path: str
  45. edits: Sequence[OneEdit] = []
  46. def to_dict(self):
  47. return {
  48. 'path': self.path,
  49. 'edits': [e.to_dict() for e in self.edits],
  50. }
  51. class WriteTransform(NamedTuple):
  52. path: str
  53. content: str
  54. def to_dict(self):
  55. return {
  56. 'path': self.path,
  57. 'content': self.content,
  58. }
  59. class RemoveTransform(NamedTuple):
  60. path: str
  61. only_matching: Sequence[str] = ()
  62. def to_dict(self):
  63. return {
  64. 'path': self.path,
  65. 'only-matching': self.only_matching,
  66. }
  67. class FSTransform(NamedTuple):
  68. copy: Optional[CopyMoveTransform] = None
  69. move: Optional[CopyMoveTransform] = None
  70. remove: Optional[RemoveTransform] = None
  71. write: Optional[WriteTransform] = None
  72. edit: Optional[EditTransform] = None
  73. def to_dict(self):
  74. d = {}
  75. if self.copy:
  76. d['copy'] = self.copy.to_dict()
  77. if self.move:
  78. d['move'] = self.move.to_dict()
  79. if self.remove:
  80. d['remove'] = self.remove.to_dict()
  81. if self.write:
  82. d['write'] = self.write.to_dict()
  83. if self.edit:
  84. d['edit'] = self.edit.to_dict()
  85. return d
  86. class Git(NamedTuple):
  87. url: str
  88. ref: str
  89. def to_dict(self) -> dict:
  90. d = {
  91. 'url': self.url,
  92. 'ref': self.ref,
  93. }
  94. return d
  95. RemoteInfo = Union[Git]
  96. class ForeignInfo(NamedTuple):
  97. remote: RemoteInfo
  98. auto_lib: Optional[str] = None
  99. transforms: Sequence[FSTransform] = []
  100. def to_dict(self) -> dict:
  101. d = {
  102. 'transform': [tr.to_dict() for tr in self.transforms],
  103. }
  104. if isinstance(self.remote, Git):
  105. d['git'] = self.remote.to_dict()
  106. if self.auto_lib:
  107. d['auto-lib'] = self.auto_lib
  108. return d
  109. class Version(NamedTuple):
  110. version: str
  111. remote: ForeignInfo
  112. depends: Sequence[str] = []
  113. description: str = '(No description provided)'
  114. def to_dict(self) -> dict:
  115. ret: dict = {
  116. 'description': self.description,
  117. 'depends': list(self.depends),
  118. 'remote': self.remote.to_dict(),
  119. }
  120. return ret
  121. class VersionSet(NamedTuple):
  122. version: str
  123. depends: Sequence[str]
  124. class Package(NamedTuple):
  125. name: str
  126. versions: List[Version]
  127. HTTP_POOL = ThreadPoolExecutor(10)
  128. HTTP_SESSION = requests.Session()
  129. def github_http_get(url: str):
  130. url_dat = url_parse.urlparse(url)
  131. req = request.Request(url)
  132. req.add_header('Accept-Encoding', 'application/json')
  133. req.add_header('Authorization', f'token {os.environ["GITHUB_API_TOKEN"]}')
  134. if url_dat.hostname != 'api.github.com':
  135. raise RuntimeError(f'Request is outside of api.github.com [{url}]')
  136. print(f'Request {url}')
  137. resp = HTTP_SESSION.get(url, headers=req.headers)
  138. # resp = request.urlopen(req)
  139. resp.raise_for_status()
  140. # if resp.status != 200:
  141. # raise RuntimeError(f'Request to [{url}] failed [{resp.status} {resp.reason}]')
  142. return json5.loads(resp.text)
  143. def _get_github_tree_file_content(url: str) -> bytes:
  144. json_body = github_http_get(url)
  145. content_b64 = json_body['content'].encode()
  146. assert json_body['encoding'] == 'base64', json_body
  147. content = base64.decodebytes(content_b64)
  148. return content
  149. def _version_for_github_tag(pkg_name: str, desc: str, clone_url: str, tag) -> Version:
  150. print(f'Loading tag {tag["name"]}')
  151. commit = github_http_get(tag['commit']['url'])
  152. tree = github_http_get(commit['commit']['tree']['url'])
  153. tree_content = {t['path']: t for t in tree['tree']}
  154. cands = ['package.json', 'package.jsonc', 'package.json5']
  155. for cand in cands:
  156. if cand in tree_content:
  157. package_json_fname = cand
  158. break
  159. else:
  160. raise RuntimeError(f'No package JSON5 file in tag {tag["name"]} for {pkg_name} (One of {tree_content.keys()})')
  161. package_json = json5.loads(_get_github_tree_file_content(tree_content[package_json_fname]['url']))
  162. version = package_json['version']
  163. if pkg_name != package_json['name']:
  164. raise RuntimeError(f'package name in repo "{package_json["name"]}" '
  165. f'does not match expected name "{pkg_name}"')
  166. depends = package_json.get('depends')
  167. pairs: Iterable[str]
  168. if isinstance(depends, dict):
  169. pairs = ((k + v) for k, v in depends.items())
  170. elif isinstance(depends, list):
  171. pairs = depends
  172. elif depends is None:
  173. pairs = []
  174. else:
  175. raise RuntimeError(f'Unknown "depends" object from json file: {depends!r}')
  176. remote = Git(url=clone_url, ref=tag['name'])
  177. return Version(version, description=desc, depends=list(pairs), remote=ForeignInfo(remote))
  178. def github_package(name: str, repo: str, want_tags: Iterable[str]) -> Package:
  179. print(f'Downloading repo from {repo}')
  180. repo_data = github_http_get(f'https://api.github.com/repos/{repo}')
  181. desc = repo_data['description']
  182. avail_tags = github_http_get(repo_data['tags_url'])
  183. missing_tags = set(want_tags) - set(t['name'] for t in avail_tags)
  184. if missing_tags:
  185. raise RuntimeError('One or more wanted tags do not exist in '
  186. f'the repository "{repo}" (Missing: {missing_tags})')
  187. tag_items = (t for t in avail_tags if t['name'] in want_tags)
  188. versions = HTTP_POOL.map(lambda tag: _version_for_github_tag(name, desc, repo_data['clone_url'], tag), tag_items)
  189. return Package(name, list(versions))
  190. def simple_packages(name: str,
  191. description: str,
  192. git_url: str,
  193. versions: Sequence[VersionSet],
  194. auto_lib: Optional[str] = None,
  195. *,
  196. tag_fmt: str = '{}') -> Package:
  197. return Package(name, [
  198. Version(
  199. ver.version,
  200. description=description,
  201. remote=ForeignInfo(remote=Git(git_url, tag_fmt.format(ver.version)), auto_lib=auto_lib),
  202. depends=ver.depends) for ver in versions
  203. ])
  204. def many_versions(name: str,
  205. versions: Sequence[str],
  206. *,
  207. tag_fmt: str = '{}',
  208. git_url: str,
  209. auto_lib: str = None,
  210. transforms: Sequence[FSTransform] = (),
  211. description='(No description was provided)') -> Package:
  212. return Package(name, [
  213. Version(
  214. ver,
  215. description='\n'.join(textwrap.wrap(description)),
  216. remote=ForeignInfo(
  217. remote=Git(url=git_url, ref=tag_fmt.format(ver)), auto_lib=auto_lib, transforms=transforms))
  218. for ver in versions
  219. ])
  220. # yapf: disable
  221. PACKAGES = [
  222. github_package('neo-buffer', 'vector-of-bool/neo-buffer', ['0.2.1', '0.3.0', '0.4.0', '0.4.1', '0.4.2']),
  223. github_package('neo-compress', 'vector-of-bool/neo-compress', ['0.1.0', '0.1.1', '0.2.0']),
  224. github_package('neo-url', 'vector-of-bool/neo-url', ['0.1.0', '0.1.1', '0.1.2', '0.2.0', '0.2.1', '0.2.2']),
  225. github_package('neo-sqlite3', 'vector-of-bool/neo-sqlite3', ['0.2.3', '0.3.0', '0.4.0', '0.4.1']),
  226. github_package('neo-fun', 'vector-of-bool/neo-fun', [
  227. '0.1.1',
  228. '0.2.0',
  229. '0.2.1',
  230. '0.3.0',
  231. '0.3.1',
  232. '0.3.2',
  233. '0.4.0',
  234. '0.4.1',
  235. '0.4.2',
  236. '0.5.0',
  237. '0.5.1',
  238. '0.5.2',
  239. '0.5.3',
  240. '0.5.4',
  241. '0.5.5',
  242. '0.6.0',
  243. ]),
  244. github_package('neo-io', 'vector-of-bool/neo-io', ['0.1.0', '0.1.1']),
  245. github_package('neo-http', 'vector-of-bool/neo-http', ['0.1.0']),
  246. github_package('neo-concepts', 'vector-of-bool/neo-concepts', (
  247. '0.2.2',
  248. '0.3.0',
  249. '0.3.1',
  250. '0.3.2',
  251. '0.4.0',
  252. )),
  253. github_package('semver', 'vector-of-bool/semver', ['0.2.2']),
  254. github_package('pubgrub', 'vector-of-bool/pubgrub', ['0.2.1']),
  255. github_package('vob-json5', 'vector-of-bool/json5', ['0.1.5']),
  256. github_package('vob-semester', 'vector-of-bool/semester', ['0.1.0', '0.1.1', '0.2.0', '0.2.1', '0.2.2']),
  257. many_versions(
  258. 'magic_enum',
  259. (
  260. '0.5.0',
  261. '0.6.0',
  262. '0.6.1',
  263. '0.6.2',
  264. '0.6.3',
  265. '0.6.4',
  266. '0.6.5',
  267. '0.6.6',
  268. ),
  269. description='Static reflection for enums',
  270. tag_fmt='v{}',
  271. git_url='https://github.com/Neargye/magic_enum.git',
  272. auto_lib='neargye/magic_enum',
  273. ),
  274. many_versions(
  275. 'nameof',
  276. [
  277. '0.8.3',
  278. '0.9.0',
  279. '0.9.1',
  280. '0.9.2',
  281. '0.9.3',
  282. '0.9.4',
  283. ],
  284. description='Nameof operator for modern C++',
  285. tag_fmt='v{}',
  286. git_url='https://github.com/Neargye/nameof.git',
  287. auto_lib='neargye/nameof',
  288. ),
  289. many_versions(
  290. 'range-v3',
  291. (
  292. '0.5.0',
  293. '0.9.0',
  294. '0.9.1',
  295. '0.10.0',
  296. '0.11.0',
  297. ),
  298. git_url='https://github.com/ericniebler/range-v3.git',
  299. auto_lib='range-v3/range-v3',
  300. description='Range library for C++14/17/20, basis for C++20\'s std::ranges',
  301. ),
  302. many_versions(
  303. 'nlohmann-json',
  304. (
  305. # '3.0.0',
  306. # '3.0.1',
  307. # '3.1.0',
  308. # '3.1.1',
  309. # '3.1.2',
  310. # '3.2.0',
  311. # '3.3.0',
  312. # '3.4.0',
  313. # '3.5.0',
  314. # '3.6.0',
  315. # '3.6.1',
  316. # '3.7.0',
  317. '3.7.1', # Only this version has the dds forked branch
  318. # '3.7.2',
  319. # '3.7.3',
  320. ),
  321. git_url='https://github.com/vector-of-bool/json.git',
  322. tag_fmt='dds/{}',
  323. description='JSON for Modern C++',
  324. ),
  325. Package('ms-wil', [
  326. Version(
  327. '2020.3.16',
  328. description='The Windows Implementation Library',
  329. remote=ForeignInfo(Git('https://github.com/vector-of-bool/wil.git', 'dds/2020.03.16')))
  330. ]),
  331. Package('p-ranav.argparse', [
  332. Version(
  333. '2.1.0',
  334. description='Argument Parser for Modern C++',
  335. remote=ForeignInfo(Git('https://github.com/p-ranav/argparse.git', 'v2.1'), auto_lib='p-ranav/argparse'))
  336. ]),
  337. many_versions(
  338. 'ctre',
  339. (
  340. '2.8.1',
  341. '2.8.2',
  342. '2.8.3',
  343. '2.8.4',
  344. ),
  345. git_url='https://github.com/hanickadot/compile-time-regular-expressions.git',
  346. tag_fmt='v{}',
  347. auto_lib='hanickadot/ctre',
  348. description='A compile-time PCRE (almost) compatible regular expression matcher',
  349. ),
  350. Package(
  351. 'spdlog',
  352. [
  353. Version(
  354. ver,
  355. description='Fast C++ logging library',
  356. depends=['fmt+6.0.0'],
  357. remote=ForeignInfo(
  358. Git(url='https://github.com/gabime/spdlog.git', ref=f'v{ver}'),
  359. transforms=[
  360. FSTransform(
  361. write=WriteTransform(
  362. path='package.json',
  363. content=json.dumps({
  364. 'name': 'spdlog',
  365. 'namespace': 'spdlog',
  366. 'version': ver,
  367. 'depends': ['fmt+6.0.0'],
  368. }))),
  369. FSTransform(
  370. write=WriteTransform(
  371. path='library.json', content=json.dumps({
  372. 'name': 'spdlog',
  373. 'uses': ['fmt/fmt']
  374. }))),
  375. FSTransform(
  376. # It's all just template instantiations.
  377. remove=RemoveTransform(path='src/'),
  378. # Tell spdlog to use the external fmt library
  379. edit=EditTransform(
  380. path='include/spdlog/tweakme.h',
  381. edits=[
  382. OneEdit(
  383. kind='insert',
  384. content='#define SPDLOG_FMT_EXTERNAL 1',
  385. line=13,
  386. ),
  387. ])),
  388. ],
  389. ),
  390. ) for ver in (
  391. '1.4.0',
  392. '1.4.1',
  393. '1.4.2',
  394. '1.5.0',
  395. '1.6.0',
  396. '1.6.1',
  397. '1.7.0',
  398. )
  399. ]),
  400. many_versions(
  401. 'fmt',
  402. (
  403. '6.0.0',
  404. '6.1.0',
  405. '6.1.1',
  406. '6.1.2',
  407. '6.2.0',
  408. '6.2.1',
  409. '7.0.0',
  410. '7.0.1',
  411. '7.0.2',
  412. '7.0.3',
  413. ),
  414. git_url='https://github.com/fmtlib/fmt.git',
  415. auto_lib='fmt/fmt',
  416. description='A modern formatting library : https://fmt.dev/',
  417. ),
  418. Package('catch2', [
  419. Version(
  420. '2.12.4',
  421. description='A modern C++ unit testing library',
  422. remote=ForeignInfo(
  423. Git('https://github.com/catchorg/Catch2.git', 'v2.12.4'),
  424. auto_lib='catch2/catch2',
  425. transforms=[
  426. FSTransform(move=CopyMoveTransform(frm='include', to='include/catch2')),
  427. FSTransform(
  428. copy=CopyMoveTransform(frm='include', to='src'),
  429. write=WriteTransform(
  430. path='include/catch2/catch_with_main.hpp',
  431. content='''
  432. #pragma once
  433. #define CATCH_CONFIG_MAIN
  434. #include "./catch.hpp"
  435. namespace Catch {
  436. CATCH_REGISTER_REPORTER("console", ConsoleReporter)
  437. }
  438. ''')),
  439. ]))
  440. ]),
  441. Package('asio', [
  442. Version(
  443. ver,
  444. description='Asio asynchronous I/O C++ library',
  445. remote=ForeignInfo(
  446. Git('https://github.com/chriskohlhoff/asio.git', f'asio-{ver.replace(".", "-")}'),
  447. auto_lib='asio/asio',
  448. transforms=[
  449. FSTransform(
  450. move=CopyMoveTransform(
  451. frm='asio/src',
  452. to='src/',
  453. ),
  454. remove=RemoveTransform(
  455. path='src/',
  456. only_matching=[
  457. 'doc/**',
  458. 'examples/**',
  459. 'tests/**',
  460. 'tools/**',
  461. ],
  462. ),
  463. ),
  464. FSTransform(
  465. move=CopyMoveTransform(
  466. frm='asio/include/',
  467. to='include/',
  468. ),
  469. edit=EditTransform(
  470. path='include/asio/detail/config.hpp',
  471. edits=[
  472. OneEdit(line=13, kind='insert', content='#define ASIO_STANDALONE 1'),
  473. OneEdit(line=14, kind='insert', content='#define ASIO_SEPARATE_COMPILATION 1')
  474. ]),
  475. ),
  476. ]),
  477. ) for ver in [
  478. '1.12.0',
  479. '1.12.1',
  480. '1.12.2',
  481. '1.13.0',
  482. '1.14.0',
  483. '1.14.1',
  484. '1.16.0',
  485. '1.16.1',
  486. ]
  487. ]),
  488. Package(
  489. 'abseil',
  490. [
  491. Version(
  492. ver,
  493. description='Abseil Common Libraries',
  494. remote=ForeignInfo(
  495. Git('https://github.com/abseil/abseil-cpp.git', tag),
  496. auto_lib='abseil/abseil',
  497. transforms=[
  498. FSTransform(
  499. move=CopyMoveTransform(
  500. frm='absl',
  501. to='src/absl/',
  502. ),
  503. remove=RemoveTransform(
  504. path='src/',
  505. only_matching=[
  506. '**/*_test.c*',
  507. '**/*_testing.c*',
  508. '**/*_benchmark.c*',
  509. '**/benchmarks.c*',
  510. '**/*_test_common.c*',
  511. '**/mocking_*.c*',
  512. # Misc files that should be removed:
  513. '**/test_util.cc',
  514. '**/mutex_nonprod.cc',
  515. '**/named_generator.cc',
  516. '**/print_hash_of.cc',
  517. '**/*_gentables.cc',
  518. ]),
  519. )
  520. ]),
  521. ) for ver, tag in [
  522. ('2018.6.0', '20180600'),
  523. ('2019.8.8', '20190808'),
  524. ('2020.2.25', '20200225.2'),
  525. ]
  526. ]),
  527. Package('zlib', [
  528. Version(
  529. ver,
  530. description='A massively spiffy yet delicately unobtrusive compression library',
  531. remote=ForeignInfo(
  532. Git('https://github.com/madler/zlib.git', tag or f'v{ver}'),
  533. auto_lib='zlib/zlib',
  534. transforms=[
  535. FSTransform(move=CopyMoveTransform(
  536. frm='.',
  537. to='src/',
  538. include=[
  539. '*.c',
  540. '*.h',
  541. ],
  542. )),
  543. FSTransform(move=CopyMoveTransform(
  544. frm='src/',
  545. to='include/',
  546. include=['zlib.h', 'zconf.h'],
  547. )),
  548. ]),
  549. ) for ver, tag in [
  550. ('1.2.11', None),
  551. ('1.2.10', None),
  552. ('1.2.9', None),
  553. ('1.2.8', None),
  554. ('1.2.7', 'v1.2.7.3'),
  555. ('1.2.6', 'v1.2.6.1'),
  556. ('1.2.5', 'v1.2.5.3'),
  557. ('1.2.4', 'v1.2.4.5'),
  558. ('1.2.3', 'v1.2.3.8'),
  559. ('1.2.2', 'v1.2.2.4'),
  560. ('1.2.1', 'v1.2.1.2'),
  561. ('1.2.0', 'v1.2.0.8'),
  562. ]
  563. ]),
  564. Package('sol2', [
  565. Version(
  566. ver,
  567. description='A C++ <-> Lua API wrapper with advanced features and top notch performance',
  568. depends=['lua+0.0.0'],
  569. remote=ForeignInfo(
  570. Git('https://github.com/ThePhD/sol2.git', f'v{ver}'),
  571. transforms=[
  572. FSTransform(
  573. write=WriteTransform(
  574. path='package.json',
  575. content=json.dumps(
  576. {
  577. 'name': 'sol2',
  578. 'namespace': 'sol2',
  579. 'version': ver,
  580. 'depends': [f'lua+0.0.0'],
  581. },
  582. indent=2,
  583. )),
  584. move=(None if ver.startswith('3.') else CopyMoveTransform(
  585. frm='sol',
  586. to='src/sol',
  587. )),
  588. ),
  589. FSTransform(
  590. write=WriteTransform(
  591. path='library.json',
  592. content=json.dumps(
  593. {
  594. 'name': 'sol2',
  595. 'uses': ['lua/lua'],
  596. },
  597. indent=2,
  598. ))),
  599. ]),
  600. ) for ver in [
  601. '3.2.1',
  602. '3.2.0',
  603. '3.0.3',
  604. '3.0.2',
  605. '2.20.6',
  606. '2.20.5',
  607. '2.20.4',
  608. '2.20.3',
  609. '2.20.2',
  610. '2.20.1',
  611. '2.20.0',
  612. ]
  613. ]),
  614. Package('lua', [
  615. Version(
  616. ver,
  617. description=
  618. 'Lua is a powerful and fast programming language that is easy to learn and use and to embed into your application.',
  619. remote=ForeignInfo(
  620. Git('https://github.com/lua/lua.git', f'v{ver}'),
  621. auto_lib='lua/lua',
  622. transforms=[FSTransform(move=CopyMoveTransform(
  623. frm='.',
  624. to='src/',
  625. include=['*.c', '*.h'],
  626. ))]),
  627. ) for ver in [
  628. '5.4.0',
  629. '5.3.5',
  630. '5.3.4',
  631. '5.3.3',
  632. '5.3.2',
  633. '5.3.1',
  634. '5.3.0',
  635. '5.2.3',
  636. '5.2.2',
  637. '5.2.1',
  638. '5.2.0',
  639. '5.1.1',
  640. ]
  641. ]),
  642. Package('pegtl', [
  643. Version(
  644. ver,
  645. description='Parsing Expression Grammar Template Library',
  646. remote=ForeignInfo(
  647. Git('https://github.com/taocpp/PEGTL.git', ver),
  648. auto_lib='tao/pegtl',
  649. transforms=[FSTransform(remove=RemoveTransform(path='src/'))],
  650. )) for ver in [
  651. '2.8.3',
  652. '2.8.2',
  653. '2.8.1',
  654. '2.8.0',
  655. '2.7.1',
  656. '2.7.0',
  657. '2.6.1',
  658. '2.6.0',
  659. ]
  660. ]),
  661. many_versions(
  662. 'boost.pfr', ['1.0.0', '1.0.1'], auto_lib='boost/pfr', git_url='https://github.com/apolukhin/magic_get.git'),
  663. many_versions(
  664. 'boost.leaf',
  665. [
  666. '0.1.0',
  667. '0.2.0',
  668. '0.2.1',
  669. '0.2.2',
  670. '0.2.3',
  671. '0.2.4',
  672. '0.2.5',
  673. '0.3.0',
  674. ],
  675. auto_lib='boost/leaf',
  676. git_url='https://github.com/zajo/leaf.git',
  677. ),
  678. many_versions(
  679. 'boost.mp11',
  680. ['1.70.0', '1.71.0', '1.72.0', '1.73.0'],
  681. tag_fmt='boost-{}',
  682. git_url='https://github.com/boostorg/mp11.git',
  683. auto_lib='boost/mp11',
  684. ),
  685. many_versions(
  686. 'libsodium', [
  687. '1.0.10',
  688. '1.0.11',
  689. '1.0.12',
  690. '1.0.13',
  691. '1.0.14',
  692. '1.0.15',
  693. '1.0.16',
  694. '1.0.17',
  695. '1.0.18',
  696. ],
  697. git_url='https://github.com/jedisct1/libsodium.git',
  698. auto_lib='sodium/sodium',
  699. description='Sodium is a new, easy-to-use software library '
  700. 'for encryption, decryption, signatures, password hashing and more.',
  701. transforms=[
  702. FSTransform(
  703. move=CopyMoveTransform(frm='src/libsodium/include', to='include/'),
  704. edit=EditTransform(
  705. path='include/sodium/export.h',
  706. edits=[OneEdit(line=8, kind='insert', content='#define SODIUM_STATIC 1')])),
  707. FSTransform(
  708. edit=EditTransform(
  709. path='include/sodium/private/common.h',
  710. edits=[
  711. OneEdit(
  712. kind='insert',
  713. line=1,
  714. content=Path(__file__).parent.joinpath('libsodium-config.h').read_text(),
  715. )
  716. ])),
  717. FSTransform(
  718. copy=CopyMoveTransform(
  719. frm='builds/msvc/version.h',
  720. to='include/sodium/version.h',
  721. ),
  722. move=CopyMoveTransform(
  723. frm='src/libsodium',
  724. to='src/',
  725. ),
  726. remove=RemoveTransform(path='src/libsodium'),
  727. ),
  728. FSTransform(copy=CopyMoveTransform(frm='include', to='src/', strip_components=1)),
  729. ]),
  730. many_versions(
  731. 'tomlpp',
  732. [
  733. '1.0.0',
  734. '1.1.0',
  735. '1.2.0',
  736. '1.2.3',
  737. '1.2.4',
  738. '1.2.5',
  739. '1.3.0',
  740. # '1.3.2', # Wrong tag name in upstream
  741. '1.3.3',
  742. '2.0.0',
  743. ],
  744. tag_fmt='v{}',
  745. git_url='https://github.com/marzer/tomlplusplus.git',
  746. auto_lib='tomlpp/tomlpp',
  747. description='Header-only TOML config file parser and serializer for modern C++'),
  748. Package('inja', [
  749. *(Version(
  750. ver,
  751. description='A Template Engine for Modern C++',
  752. remote=ForeignInfo(Git('https://github.com/pantor/inja.git', f'v{ver}'), auto_lib='inja/inja'))
  753. for ver in ('1.0.0', '2.0.0', '2.0.1')),
  754. *(Version(
  755. ver,
  756. description='A Template Engine for Modern C++',
  757. depends=['nlohmann-json+0.0.0'],
  758. remote=ForeignInfo(
  759. Git('https://github.com/pantor/inja.git', f'v{ver}'),
  760. transforms=[
  761. FSTransform(
  762. write=WriteTransform(
  763. path='package.json',
  764. content=json.dumps({
  765. 'name': 'inja',
  766. 'namespace': 'inja',
  767. 'version': ver,
  768. 'depends': [
  769. 'nlohmann-json+0.0.0',
  770. ]
  771. }))),
  772. FSTransform(
  773. write=WriteTransform(
  774. path='library.json', content=json.dumps({
  775. 'name': 'inja',
  776. 'uses': ['nlohmann/json']
  777. }))),
  778. ],
  779. auto_lib='inja/inja',
  780. )) for ver in ('2.1.0', '2.2.0')),
  781. ]),
  782. many_versions(
  783. 'cereal',
  784. [
  785. '0.9.0',
  786. '0.9.1',
  787. '1.0.0',
  788. '1.1.0',
  789. '1.1.1',
  790. '1.1.2',
  791. '1.2.0',
  792. '1.2.1',
  793. '1.2.2',
  794. '1.3.0',
  795. ],
  796. auto_lib='cereal/cereal',
  797. git_url='https://github.com/USCiLab/cereal.git',
  798. tag_fmt='v{}',
  799. description='A C++11 library for serialization',
  800. ),
  801. many_versions(
  802. 'pybind11',
  803. [
  804. '2.0.0',
  805. '2.0.1',
  806. '2.1.0',
  807. '2.1.1',
  808. '2.2.0',
  809. '2.2.1',
  810. '2.2.2',
  811. '2.2.3',
  812. '2.2.4',
  813. '2.3.0',
  814. '2.4.0',
  815. '2.4.1',
  816. '2.4.2',
  817. '2.4.3',
  818. '2.5.0',
  819. ],
  820. git_url='https://github.com/pybind/pybind11.git',
  821. description='Seamless operability between C++11 and Python',
  822. auto_lib='pybind/pybind11',
  823. tag_fmt='v{}',
  824. ),
  825. Package('pcg-cpp', [
  826. Version(
  827. '0.98.1',
  828. description='PCG Randum Number Generation, C++ Edition',
  829. remote=ForeignInfo(Git(url='https://github.com/imneme/pcg-cpp.git', ref='v0.98.1'), auto_lib='pcg/pcg-cpp'))
  830. ]),
  831. many_versions(
  832. 'hinnant-date',
  833. ['2.4.1', '3.0.0'],
  834. description='A date and time library based on the C++11/14/17 <chrono> header',
  835. auto_lib='hinnant/date',
  836. git_url='https://github.com/HowardHinnant/date.git',
  837. tag_fmt='v{}',
  838. transforms=[FSTransform(remove=RemoveTransform(path='src/'))],
  839. ),
  840. ]
  841. # yapf: enable
  842. if __name__ == "__main__":
  843. parser = argparse.ArgumentParser()
  844. args = parser.parse_args()
  845. data = {
  846. 'version': 1,
  847. 'packages': {pkg.name: {ver.version: ver.to_dict()
  848. for ver in pkg.versions}
  849. for pkg in PACKAGES}
  850. }
  851. Path('catalog.json').write_text(json.dumps(data, indent=2, sort_keys=True))