blob: c850d244e883f58fad7cc7d8332beb11fa64b34c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import os
import sys
import json
import base64
import subprocess
if __name__ == '__main__':
p = sys.argv.index('--')
ctx = base64.b64decode(sys.argv[p + 1].encode()).decode()
kv = {}
for x in sys.argv[1:p]:
k, v = x.split('=')
ctx = ctx.replace(f'$({k})', v)
kv[k] = v
cmd = json.loads(ctx)
args = cmd['cmd_args']
cwd = cmd.get('cwd', kv['B'])
env = dict(**os.environ)
env['ARCADIA_ROOT_DISTBUILD'] = kv['S']
env.update(cmd['env'])
out = subprocess.check_output(args, env=env, cwd=cwd)
if stdout := cmd.get('stdout'):
with open(stdout, 'wb') as f:
f.write(out)
|