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.

56 lines
1.4KB

  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. dds_flags: proc.CommandLine = ()):
  16. # Copy the exe to another location, as windows refuses to let a binary be
  17. # replaced while it is executing
  18. new_exe = ROOT / '_dds.bootstrap-test.exe'
  19. shutil.copy2(exe, new_exe)
  20. try:
  21. proc.check_run(
  22. new_exe,
  23. 'catalog',
  24. 'import',
  25. f'--catalog={cat_path}',
  26. f'--json=catalog.json',
  27. )
  28. proc.check_run(
  29. new_exe,
  30. 'build',
  31. f'--catalog={cat_path}',
  32. f'--repo-dir=_build/ci-repo',
  33. dds_flags,
  34. ('--toolchain', toolchain),
  35. ('-I', lmi_path) if lmi_path else (),
  36. )
  37. finally:
  38. new_exe.unlink()
  39. def main(argv: List[str]) -> int:
  40. parser = argparse.ArgumentParser()
  41. cli.add_tc_arg(parser)
  42. cli.add_dds_exe_arg(parser)
  43. args = parser.parse_args(argv)
  44. self_build(Path(args.exe), toolchain=args.toolchain, dds_flags=['--full'])
  45. return 0
  46. if __name__ == "__main__":
  47. sys.exit(main(sys.argv[1:]))