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.

self_build.py 1.5KB

5 yıl önce
5 yıl önce
5 yıl önce
5 yıl önce
5 yıl önce
5 yıl önce
5 yıl önce
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env python3
  2. import argparse
  3. from pathlib import Path
  4. from typing import List, NamedTuple, Iterable
  5. import shutil
  6. import subprocess
  7. import sys
  8. from dds_ci import cli, proc
  9. ROOT = Path(__file__).parent.parent.absolute()
  10. def self_build(exe: Path,
  11. *,
  12. toolchain: str,
  13. lmi_path: Path = None,
  14. cat_path: Path = Path('_build/catalog.db'),
  15. cat_json_path: Path = Path('catalog.json'),
  16. dds_flags: proc.CommandLine = ()):
  17. # Copy the exe to another location, as windows refuses to let a binary be
  18. # replaced while it is executing
  19. new_exe = ROOT / '_dds.bootstrap-test.exe'
  20. shutil.copy2(exe, new_exe)
  21. try:
  22. proc.check_run(
  23. new_exe,
  24. 'catalog',
  25. 'import',
  26. f'--catalog={cat_path}',
  27. f'--json={cat_json_path}',
  28. )
  29. proc.check_run(
  30. new_exe,
  31. 'build',
  32. f'--catalog={cat_path}',
  33. f'--repo-dir={ROOT}/_build/ci-repo',
  34. dds_flags,
  35. ('--toolchain', toolchain),
  36. ('-I', lmi_path) if lmi_path else (),
  37. )
  38. finally:
  39. new_exe.unlink()
  40. def main(argv: List[str]) -> int:
  41. parser = argparse.ArgumentParser()
  42. cli.add_tc_arg(parser)
  43. cli.add_dds_exe_arg(parser)
  44. args = parser.parse_args(argv)
  45. self_build(Path(args.exe), toolchain=args.toolchain, dds_flags=['--full'])
  46. return 0
  47. if __name__ == "__main__":
  48. sys.exit(main(sys.argv[1:]))