選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

gen-catalog-json.py 29KB

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