Skip to content

Commit db11f8a

Browse files
committed
Move bootstrap.pl to Python.
This also moves env var control back into the local build, so we don't have to restart buildbot to change that.
1 parent cf8547c commit db11f8a

File tree

3 files changed

+115
-90
lines changed

3 files changed

+115
-90
lines changed

support/buildbot/bootstrap.pl

Lines changed: 0 additions & 90 deletions
This file was deleted.

support/buildbot/bootstrap.py

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# vim: set sw=4 sts=4 ts=4 sw=99 et:
2+
from contextlib import contextmanager
3+
import argparse
4+
import json
5+
import os
6+
import platform
7+
import shutil
8+
import subprocess
9+
10+
@contextmanager
11+
def Chdir(path):
12+
old = os.getcwd()
13+
os.chdir(path)
14+
print('> cd {} # {}'.format(path, os.getcwd()))
15+
try:
16+
yield
17+
finally:
18+
os.chdir(old)
19+
20+
def run_shell(argv, env = None):
21+
if type(argv) is str:
22+
print('> {}'.format(argv))
23+
shell = True
24+
else:
25+
print('> {}'.format(' '.join(argv)))
26+
shell = False
27+
try:
28+
output = subprocess.check_output(argv, stderr = subprocess.STDOUT, env = env, shell = shell)
29+
except subprocess.CalledProcessError as cpe:
30+
if not shell:
31+
print(cpe.output.decode('utf-8', 'ignore'))
32+
raise
33+
print(output.decode('utf-8', 'ignore'))
34+
35+
def output_needs_cleaning():
36+
if not os.path.isdir('OUTPUT'):
37+
return False
38+
amb2_dir = os.path.join('OUTPUT', '.ambuild2')
39+
if not os.path.isdir(os.path.join(amb2_dir, 'graph')):
40+
return True
41+
if not os.path.isdir(os.path.join(amb2_dir, 'vars')):
42+
return True
43+
return False
44+
45+
def main():
46+
parser = argparse.ArgumentParser()
47+
parser.add_argument('--config', type = str, required = True,
48+
help = 'Buildbot slave name')
49+
parser.add_argument('--hl2sdk-root', type = str, required = True,
50+
help = 'hl2sdk collection')
51+
parser.add_argument('--python-cmd', type = str, required = True,
52+
default = 'python3',
53+
help = 'Python command')
54+
args = parser.parse_args()
55+
56+
run_shell("git submodule update --init --recursive")
57+
58+
source = os.getcwd()
59+
60+
with open(os.path.join('support', 'buildbot', 'buildconfig.json'), 'rt') as fp:
61+
config_root = json.load(fp)
62+
63+
config = config_root.get(args.config, {})
64+
65+
# Set build properties.
66+
build_env = os.environ.copy()
67+
for env_var in ['CC', 'CXX']:
68+
if env_var not in config:
69+
continue
70+
build_env[env_var] = config[env_var]
71+
72+
if platform.system() == 'Windows':
73+
hl2sdk_root = '/Volumes/hgshare'
74+
python_cmd = "C:\\Python38\\Python.exe"
75+
elif platform.system() == 'Linux':
76+
hl2sdk_root = '/hgshare'
77+
python_cmd = "python3"
78+
elif platform.system() == 'Windows':
79+
hl2sdk_root = 'H:\\'
80+
python_cmd = "python3"
81+
82+
config_argv = [
83+
args.python_cmd,
84+
os.path.join(source, 'configure.py'),
85+
'--enable-optimize',
86+
'--breakpad-dump',
87+
'--no-color',
88+
'--symbol-files',
89+
'--targets=x86,x86_64',
90+
'--sdks=all',
91+
'--out=OUTPUT',
92+
'--hl2sdk-root={}'.format(args.hl2sdk_root),
93+
]
94+
95+
print("Attempting to reconfigure...")
96+
97+
with Chdir('..'):
98+
if output_needs_cleaning():
99+
shutil.rmtree('OUTPUT')
100+
if not os.path.isdir('OUTPUT'):
101+
os.makedirs('OUTPUT')
102+
run_shell(config_argv, env = build_env)
103+
104+
if __name__ == '__main__':
105+
main()

support/buildbot/buildconfig.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"debian8": {
3+
"CC": "clang-3.8",
4+
"CXX": "clang-3.8"
5+
},
6+
"debian11": {
7+
"CC": "clang-13",
8+
"CXX": "clang++-13"
9+
}
10+
}

0 commit comments

Comments
 (0)