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.

936 lines
28KB

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