Pārlūkot izejas kodu

Give each bootstrap phase its own subdirectory

default_compile_flags
vector-of-bool pirms 5 gadiem
vecāks
revīzija
db281dd1f3
1 mainītis faili ar 14 papildinājumiem un 12 dzēšanām
  1. +14
    -12
      tools/bootstrap.py

+ 14
- 12
tools/bootstrap.py Parādīt failu

@@ -14,7 +14,7 @@ BOOTSTRAP_PHASES = [
HERE = Path(__file__).parent.absolute()
PROJECT_ROOT = HERE.parent
BUILD_DIR = PROJECT_ROOT / '_build'
BOOTSTRAP_DIR = BUILD_DIR / '_bootstrap'
BOOTSTRAP_BASE_DIR = BUILD_DIR / '_bootstrap'
PREBUILT_DIR = PROJECT_ROOT / '_prebuilt'

EXE_SUFFIX = '.exe' if os.name == 'nt' else ''
@@ -29,21 +29,23 @@ def _run_quiet(args) -> None:
raise subprocess.CalledProcessError(res.returncode, cmd)


def _clone_bootstrap_phase(ph: str) -> None:
def _clone_bootstrap_phase(ph: str) -> Path:
print(f'Cloning: {ph}')
if BOOTSTRAP_DIR.exists():
shutil.rmtree(BOOTSTRAP_DIR)
bts_dir = BOOTSTRAP_BASE_DIR / ph
if bts_dir.exists():
shutil.rmtree(bts_dir)
_run_quiet([
'git',
'clone',
'--depth=1',
f'--branch={ph}',
f'file://{PROJECT_ROOT}',
BOOTSTRAP_DIR,
bts_dir,
])
return bts_dir


def _build_bootstrap_phase(ph: str, args: argparse.Namespace) -> None:
def _build_bootstrap_phase(ph: str, bts_dir: Path, args: argparse.Namespace) -> None:
print(f'Running build: {ph} (Please wait a moment...)')
env = os.environ.copy()
env['DDS_BOOTSTRAP_PREV_EXE'] = str(PREBUILT_DIR / 'dds')
@@ -51,17 +53,17 @@ def _build_bootstrap_phase(ph: str, args: argparse.Namespace) -> None:
[
sys.executable,
'-u',
str(BOOTSTRAP_DIR / 'tools/build.py'),
str(bts_dir / 'tools/build.py'),
f'--cxx={args.cxx}',
],
env=env,
)


def _pull_executable() -> Path:
def _pull_executable(bts_dir: Path) -> Path:
prebuild_dir = (PROJECT_ROOT / '_prebuilt')
prebuild_dir.mkdir(exist_ok=True)
generated = list(BOOTSTRAP_DIR.glob(f'_build/dds{EXE_SUFFIX}'))
generated = list(bts_dir.glob(f'_build/dds{EXE_SUFFIX}'))
assert len(generated) == 1, repr(generated)
exe, = generated
dest = prebuild_dir / exe.name
@@ -70,9 +72,9 @@ def _pull_executable() -> Path:


def _run_boot_phase(phase: str, args: argparse.Namespace) -> Path:
_clone_bootstrap_phase(phase)
_build_bootstrap_phase(phase, args)
return _pull_executable()
bts_dir = _clone_bootstrap_phase(phase)
_build_bootstrap_phase(phase, bts_dir, args)
return _pull_executable(bts_dir)


def main(argv: Sequence[str]) -> int:

Notiek ielāde…
Atcelt
Saglabāt