您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

self_build.py 1.4KB

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