2016-03-16 18:58:29 +01:00
|
|
|
#!/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.
|
|
|
|
|
2020-05-11 21:53:51 +02:00
|
|
|
from __future__ import print_function
|
2016-03-16 18:58:29 +01:00
|
|
|
import os, shutil, subprocess, sys
|
|
|
|
|
|
|
|
OUT_DIR = os.environ.get('OUT_DIR') or 'test'
|
|
|
|
SRC_DIR = os.environ.get('SRC_DIR') or 'src'
|
2017-04-10 21:31:19 +02:00
|
|
|
UPSTREAM = os.environ.get('UPSTREAM') or 'git@github.com:tc39/test262.git'
|
|
|
|
MAINTAINER = os.environ.get('MAINTAINER') or 'test262@ecma-international.org'
|
2016-03-16 18:58:29 +01:00
|
|
|
|
|
|
|
def shell(*args):
|
2020-05-11 21:53:51 +02:00
|
|
|
sp = subprocess.Popen(list(args), stdout=subprocess.PIPE, universal_newlines=True)
|
2016-03-16 18:58:29 +01:00
|
|
|
cmd_str = ' '.join(args)
|
|
|
|
|
2020-05-11 21:53:51 +02:00
|
|
|
print('> ' + cmd_str)
|
2016-03-16 18:58:29 +01:00
|
|
|
|
|
|
|
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():
|
2020-05-11 21:53:51 +02:00
|
|
|
print('Running target: ' + orig.__name__)
|
2016-03-16 18:58:29 +01:00
|
|
|
|
|
|
|
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',
|
2024-10-15 21:38:01 +02:00
|
|
|
'--parents',
|
2016-03-16 18:58:29 +01:00
|
|
|
'--out', OUT_DIR,
|
|
|
|
SRC_DIR)
|
|
|
|
|
|
|
|
@target()
|
|
|
|
def clean():
|
|
|
|
shell(sys.executable, 'tools/generation/generator.py', 'clean', OUT_DIR)
|
|
|
|
|
2017-04-10 21:31:19 +02:00
|
|
|
@target('clean', 'build')
|
|
|
|
def deploy():
|
|
|
|
shell('git', 'add', '--all', OUT_DIR)
|
|
|
|
shell('git', 'commit', '--message', '"Re-build from source"')
|
2020-07-15 20:53:19 +02:00
|
|
|
shell('git', 'push', UPSTREAM, 'main')
|
2017-04-10 21:31:19 +02:00
|
|
|
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')
|
|
|
|
|
2016-03-16 18:58:29 +01:00
|
|
|
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]()
|