Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

976 lines
30KB

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