forked from tc39/test262
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.py
executable file
·86 lines (70 loc) · 2.57 KB
/
make.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python
# Copyright (C) 2016 the V8 project authors. All rights reserved.
# This code is governed by the BSD license found in the LICENSE file.
from __future__ import print_function
import os, shutil, subprocess, sys
OUT_DIR = os.environ.get('OUT_DIR') or 'test'
SRC_DIR = os.environ.get('SRC_DIR') or 'src'
UPSTREAM = os.environ.get('UPSTREAM') or '[email protected]:tc39/test262.git'
MAINTAINER = os.environ.get('MAINTAINER') or '[email protected]'
def shell(*args):
sp = subprocess.Popen(list(args), stdout=subprocess.PIPE, universal_newlines=True)
cmd_str = ' '.join(args)
print('> ' + cmd_str)
for line in iter(sp.stdout.readline, ''):
sys.stdout.write(line)
sp.communicate()
if sp.returncode == 1:
raise Exception('Command failed: ' + cmd_str)
targets = dict()
def target(*deps):
def other(orig):
def wrapped():
print('Running target: ' + orig.__name__)
for dep in deps:
targets[dep]()
return orig()
wrapped.__name__ = orig.__name__
targets[orig.__name__] = wrapped
return wrapped
return other
@target()
def build():
shell(sys.executable, 'tools/generation/generator.py',
'create',
'--out', OUT_DIR,
SRC_DIR)
@target()
def clean():
shell(sys.executable, 'tools/generation/generator.py', 'clean', OUT_DIR)
@target('clean', 'build')
def deploy():
shell('git', 'add', '--all', OUT_DIR)
shell('git', 'commit', '--message', '"Re-build from source"')
shell('git', 'push', UPSTREAM, 'master')
shell('git', 'checkout', '-')
# Generate a deploy key for use in a continuous integration system, allowing
# for automated deployment in response to merge events.
@target()
def github_deploy_key():
shell('ssh-keygen',
'-t', 'rsa',
'-b', '4096',
'-C', MAINTAINER,
'-f', 'github-deploy-key')
# Encrypt the deploy key so that it may be included in the repository (to be
# decrypted by the continuous integration server during automated deployment)
# This requires the "travis" Ruby gem
# Source: https://docs.travis-ci.com/user/encrypting-files/
@target('github_deploy_key')
def github_deploy_key_enc():
shell('travis', 'login')
shell('travis', 'encrypt-file', 'github-deploy-key')
if len(sys.argv) == 1:
targets['build']()
for target in sys.argv[1:]:
if not target in targets:
sys.stderr.write('No target named: "' + target + '".\n' +
'Available targets: ' + ', '.join(list(targets)) + '\n')
sys.exit(1)
targets[target]()