2013-01-11 09:23:08 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
# Copyright 2013 Ben Vanik. All Rights Reserved.
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = 'ben.vanik@gmail.com (Ben Vanik)'
|
|
|
|
|
|
|
|
|
|
|
|
import os
|
2013-10-18 06:35:54 +00:00
|
|
|
import re
|
2013-01-11 09:23:08 +00:00
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
# Add self to the root search path.
|
|
|
|
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
|
|
|
|
|
2013-01-30 07:04:19 +00:00
|
|
|
# Augment path to include our fancy things.
|
|
|
|
os.environ['PATH'] += os.pathsep + os.pathsep.join([
|
|
|
|
os.path.abspath('third_party/ninja/'),
|
|
|
|
os.path.abspath('third_party/gyp/')
|
|
|
|
])
|
|
|
|
|
2013-01-11 09:23:08 +00:00
|
|
|
# Check python version.
|
2014-01-14 06:05:10 +00:00
|
|
|
if not sys.version_info[:2] == (2, 7):
|
2013-10-18 04:41:14 +00:00
|
|
|
print('ERROR: python 2.7 required')
|
|
|
|
print('(unfortunately gyp doesn\'t work with 3!)')
|
2013-01-11 09:23:08 +00:00
|
|
|
sys.exit(1)
|
|
|
|
return
|
|
|
|
|
2013-10-18 06:35:54 +00:00
|
|
|
# Grab Visual Studio version and execute shell to set up environment.
|
|
|
|
if sys.platform == 'win32':
|
|
|
|
vs_version = import_vs_environment()
|
2015-05-02 13:17:34 +00:00
|
|
|
if vs_version != 2015:
|
|
|
|
print('ERROR: Visual Studio 2015 not found!')
|
|
|
|
print('Ensure you have the VS140COMNTOOLS environment variable!')
|
2013-10-18 06:35:54 +00:00
|
|
|
sys.exit(1)
|
|
|
|
return
|
|
|
|
|
2013-01-11 09:23:08 +00:00
|
|
|
# Grab all commands.
|
|
|
|
commands = discover_commands()
|
|
|
|
|
|
|
|
# Parse command name and dispatch.
|
|
|
|
try:
|
|
|
|
if len(sys.argv) < 2:
|
|
|
|
raise ValueError('No command given')
|
|
|
|
command_name = sys.argv[1]
|
2013-10-18 04:41:14 +00:00
|
|
|
if not command_name in commands:
|
2013-01-11 09:23:08 +00:00
|
|
|
raise ValueError('Command "%s" not found' % (command_name))
|
|
|
|
|
|
|
|
command = commands[command_name]
|
|
|
|
return_code = run_command(command=command,
|
|
|
|
args=sys.argv[2:],
|
|
|
|
cwd=os.getcwd())
|
|
|
|
except ValueError:
|
2013-10-18 04:41:14 +00:00
|
|
|
print(usage(commands))
|
2013-01-11 09:23:08 +00:00
|
|
|
return_code = 1
|
|
|
|
except Exception as e:
|
|
|
|
#print e
|
|
|
|
raise
|
|
|
|
return_code = 1
|
|
|
|
sys.exit(return_code)
|
|
|
|
|
|
|
|
|
2013-10-18 06:35:54 +00:00
|
|
|
def import_vs_environment():
|
|
|
|
"""Finds the installed Visual Studio version and imports
|
|
|
|
interesting environment variables into os.environ.
|
|
|
|
|
|
|
|
Returns:
|
2015-05-02 13:17:34 +00:00
|
|
|
A version such as 2015 or None if no VS is found.
|
2013-10-18 06:35:54 +00:00
|
|
|
"""
|
|
|
|
version = 0
|
|
|
|
tools_path = ''
|
2015-02-12 04:49:05 +00:00
|
|
|
if 'VS150COMNTOOLS' in os.environ:
|
|
|
|
version = 2015
|
|
|
|
tools_path = os.environ['VS150COMNTOOLS']
|
|
|
|
elif 'VS140COMNTOOLS' in os.environ:
|
|
|
|
# TODO(benvanik): remove preview tools.
|
2014-12-20 01:09:39 +00:00
|
|
|
version = 2015
|
|
|
|
tools_path = os.environ['VS140COMNTOOLS']
|
2013-10-18 06:35:54 +00:00
|
|
|
if version == 0:
|
|
|
|
return None
|
|
|
|
tools_path = os.path.join(tools_path, '..\\..\\vc\\vcvarsall.bat')
|
|
|
|
|
|
|
|
args = [tools_path, '&&', 'set']
|
|
|
|
popen = subprocess.Popen(
|
|
|
|
args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
|
|
|
variables, _ = popen.communicate()
|
|
|
|
envvars_to_save = (
|
|
|
|
'devenvdir',
|
|
|
|
'include',
|
|
|
|
'lib',
|
|
|
|
'libpath',
|
|
|
|
'path',
|
|
|
|
'pathext',
|
|
|
|
'systemroot',
|
|
|
|
'temp',
|
|
|
|
'tmp',
|
|
|
|
'windowssdkdir',
|
|
|
|
)
|
|
|
|
for line in variables.splitlines():
|
|
|
|
for envvar in envvars_to_save:
|
|
|
|
if re.match(envvar + '=', line.lower()):
|
|
|
|
var, setting = line.split('=', 1)
|
|
|
|
if envvar == 'path':
|
|
|
|
setting = os.path.dirname(sys.executable) + os.pathsep + setting
|
|
|
|
os.environ[var.upper()] = setting
|
|
|
|
break
|
|
|
|
|
|
|
|
os.environ['VSVERSION'] = str(version)
|
|
|
|
return version
|
|
|
|
|
|
|
|
|
2013-01-11 09:23:08 +00:00
|
|
|
def discover_commands():
|
|
|
|
"""Looks for all commands and returns a dictionary of them.
|
|
|
|
In the future commands could be discovered on disk.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
A dictionary containing name-to-Command mappings.
|
|
|
|
"""
|
|
|
|
commands = {
|
|
|
|
'setup': SetupCommand(),
|
|
|
|
'pull': PullCommand(),
|
|
|
|
'gyp': GypCommand(),
|
|
|
|
'build': BuildCommand(),
|
2013-01-27 10:51:53 +00:00
|
|
|
'test': TestCommand(),
|
2013-01-11 09:23:08 +00:00
|
|
|
'clean': CleanCommand(),
|
|
|
|
'nuke': NukeCommand(),
|
2015-02-21 22:45:23 +00:00
|
|
|
'format': FormatCommand(),
|
2013-01-11 09:23:08 +00:00
|
|
|
}
|
|
|
|
return commands
|
|
|
|
|
|
|
|
|
|
|
|
def usage(commands):
|
|
|
|
"""Gets usage info that can be displayed to the user.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
commands: A command dictionary from discover_commands.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
A string containing usage info and a command listing.
|
|
|
|
"""
|
|
|
|
s = 'xenia-build.py command [--help]\n'
|
|
|
|
s += '\n'
|
|
|
|
s += 'Commands:\n'
|
2013-10-18 04:41:14 +00:00
|
|
|
command_names = sorted(commands.keys())
|
2013-01-11 09:23:08 +00:00
|
|
|
for command_name in command_names:
|
|
|
|
s += ' %s\n' % (command_name)
|
|
|
|
command_help = commands[command_name].help_short
|
|
|
|
if command_help:
|
|
|
|
s += ' %s\n' % (command_help)
|
|
|
|
return s
|
|
|
|
|
|
|
|
|
|
|
|
def run_command(command, args, cwd):
|
|
|
|
"""Runs a command with the given context.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
command: Command to run.
|
|
|
|
args: Arguments, with the app and command name stripped.
|
|
|
|
cwd: Current working directory.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
0 if the command succeeded and non-zero otherwise.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
ValueError: The command could not be found or was not specified.
|
|
|
|
"""
|
|
|
|
# TODO(benvanik): parse arguments/etc.
|
|
|
|
return command.execute(args, cwd)
|
|
|
|
|
|
|
|
|
|
|
|
def has_bin(bin):
|
|
|
|
"""Checks whether the given binary is present.
|
|
|
|
"""
|
2013-01-30 07:04:19 +00:00
|
|
|
for path in os.environ["PATH"].split(os.pathsep):
|
|
|
|
path = path.strip('"')
|
|
|
|
exe_file = os.path.join(path, bin)
|
|
|
|
if os.path.isfile(exe_file) and os.access(exe_file, os.X_OK):
|
|
|
|
return True
|
|
|
|
exe_file = exe_file + '.exe'
|
|
|
|
if os.path.isfile(exe_file) and os.access(exe_file, os.X_OK):
|
|
|
|
return True
|
|
|
|
return None
|
2013-01-11 09:23:08 +00:00
|
|
|
|
|
|
|
|
2013-01-13 07:25:41 +00:00
|
|
|
def shell_call(command, throw_on_error=True):
|
2013-01-11 09:23:08 +00:00
|
|
|
"""Executes a shell command.
|
2013-01-13 07:25:41 +00:00
|
|
|
|
|
|
|
Args:
|
|
|
|
command: Command to execute.
|
|
|
|
throw_on_error: Whether to throw an error or return the status code.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
If throw_on_error is False the status code of the call will be returned.
|
2013-01-11 09:23:08 +00:00
|
|
|
"""
|
2013-01-13 07:25:41 +00:00
|
|
|
if throw_on_error:
|
|
|
|
subprocess.check_call(command, shell=True)
|
|
|
|
return 0
|
|
|
|
else:
|
|
|
|
return subprocess.call(command, shell=True)
|
2013-01-11 09:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Command(object):
|
|
|
|
"""Base type for commands.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, name, help_short=None, help_long=None, *args, **kwargs):
|
|
|
|
"""Initializes a command.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: The name of the command exposed to the management script.
|
|
|
|
help_short: Help text printed alongside the command when queried.
|
|
|
|
help_long: Extended help text when viewing command help.
|
|
|
|
"""
|
|
|
|
self.name = name
|
|
|
|
self.help_short = help_short
|
|
|
|
self.help_long = help_long
|
|
|
|
|
|
|
|
def execute(self, args, cwd):
|
|
|
|
"""Executes the command.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
args: Arguments list.
|
|
|
|
cwd: Current working directory.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
Return code of the command.
|
|
|
|
"""
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
|
|
def post_update_deps(config):
|
|
|
|
"""Runs common tasks that should be executed after any deps are changed.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
config: 'debug' or 'release'.
|
|
|
|
"""
|
2013-05-19 16:29:22 +00:00
|
|
|
pass
|
2013-01-11 09:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SetupCommand(Command):
|
|
|
|
"""'setup' command."""
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(SetupCommand, self).__init__(
|
|
|
|
name='setup',
|
|
|
|
help_short='Setup the build environment.',
|
|
|
|
*args, **kwargs)
|
|
|
|
|
|
|
|
def execute(self, args, cwd):
|
2013-10-18 04:41:14 +00:00
|
|
|
print('Setting up the build environment...')
|
|
|
|
print('')
|
2013-01-11 09:23:08 +00:00
|
|
|
|
|
|
|
# Setup submodules.
|
2013-10-18 04:41:14 +00:00
|
|
|
print('- git submodule init / update...')
|
2013-01-11 09:23:08 +00:00
|
|
|
shell_call('git submodule init')
|
|
|
|
shell_call('git submodule update')
|
2013-10-18 04:41:14 +00:00
|
|
|
print('')
|
2013-01-11 09:23:08 +00:00
|
|
|
|
|
|
|
# Disable core.filemode on Windows to prevent weird file mode diffs in git.
|
|
|
|
# TODO(benvanik): check cygwin test - may be wrong when using Windows python
|
|
|
|
if os.path.exists('/Cygwin.bat'):
|
2013-10-18 04:41:14 +00:00
|
|
|
print('- setting filemode off on cygwin...')
|
2013-01-11 09:23:08 +00:00
|
|
|
shell_call('git config core.filemode false')
|
|
|
|
shell_call('git submodule foreach git config core.filemode false')
|
2013-10-18 04:41:14 +00:00
|
|
|
print('')
|
2013-01-11 09:23:08 +00:00
|
|
|
|
|
|
|
# Run the ninja bootstrap to build it, if it's missing.
|
2015-02-12 04:26:31 +00:00
|
|
|
if (not '--no-ninja' in args and
|
|
|
|
not os.path.exists('third_party/ninja/ninja') and
|
2013-01-30 07:04:19 +00:00
|
|
|
not os.path.exists('third_party/ninja/ninja.exe')):
|
2013-10-18 04:41:14 +00:00
|
|
|
print('- preparing ninja...')
|
2014-12-20 01:34:47 +00:00
|
|
|
os.chdir('third_party/ninja')
|
2013-01-30 07:04:19 +00:00
|
|
|
# Windows needs --x64 to force building the 64-bit ninja.
|
|
|
|
extra_args = ''
|
2013-10-25 04:30:29 +00:00
|
|
|
#if sys.platform == 'win32':
|
|
|
|
# extra_args = '--x64'
|
2014-12-20 01:36:31 +00:00
|
|
|
shell_call('python configure.py --bootstrap ' + extra_args)
|
2014-12-20 01:31:43 +00:00
|
|
|
os.chdir(cwd)
|
2013-10-18 04:41:14 +00:00
|
|
|
print('')
|
2013-01-11 09:23:08 +00:00
|
|
|
|
2014-09-10 03:15:49 +00:00
|
|
|
# binutils (with vmx128).
|
|
|
|
print('- Building binutils...')
|
|
|
|
if sys.platform == 'win32':
|
|
|
|
# TODO(benvanik): cygwin or vagrant
|
|
|
|
print('WARNING: binutils build not supported yet')
|
|
|
|
else:
|
|
|
|
shell_call('third_party/binutils/build.sh')
|
|
|
|
print('')
|
|
|
|
|
2013-01-11 09:23:08 +00:00
|
|
|
post_update_deps('debug')
|
|
|
|
post_update_deps('release')
|
|
|
|
|
2013-10-18 04:41:14 +00:00
|
|
|
print('- running gyp...')
|
2013-01-11 09:23:08 +00:00
|
|
|
run_all_gyps()
|
2013-10-18 04:41:14 +00:00
|
|
|
print('')
|
2013-01-11 09:23:08 +00:00
|
|
|
|
2013-10-18 04:41:14 +00:00
|
|
|
print('Success!')
|
2013-01-11 09:23:08 +00:00
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
class PullCommand(Command):
|
|
|
|
"""'pull' command."""
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(PullCommand, self).__init__(
|
|
|
|
name='pull',
|
|
|
|
help_short='Pulls the repo and all dependencies.',
|
|
|
|
*args, **kwargs)
|
|
|
|
|
|
|
|
def execute(self, args, cwd):
|
2013-10-18 04:41:14 +00:00
|
|
|
print('Pulling...')
|
|
|
|
print('')
|
2013-01-11 09:23:08 +00:00
|
|
|
|
2013-10-18 04:41:14 +00:00
|
|
|
print('- pulling self...')
|
2013-01-11 09:23:08 +00:00
|
|
|
shell_call('git pull')
|
2013-10-18 04:41:14 +00:00
|
|
|
print('')
|
2013-01-11 09:23:08 +00:00
|
|
|
|
2013-10-18 04:41:14 +00:00
|
|
|
print('- pulling dependencies...')
|
2013-01-11 09:23:08 +00:00
|
|
|
shell_call('git submodule update')
|
2013-10-18 04:41:14 +00:00
|
|
|
print('')
|
2013-01-11 09:23:08 +00:00
|
|
|
|
|
|
|
post_update_deps('debug')
|
|
|
|
post_update_deps('release')
|
|
|
|
|
2013-10-18 04:41:14 +00:00
|
|
|
print('- running gyp...')
|
2013-01-11 09:23:08 +00:00
|
|
|
run_all_gyps()
|
2013-10-18 04:41:14 +00:00
|
|
|
print('')
|
2013-01-11 09:23:08 +00:00
|
|
|
|
2013-10-18 04:41:14 +00:00
|
|
|
print('Success!')
|
2013-01-11 09:23:08 +00:00
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
def run_gyp(format):
|
|
|
|
"""Runs gyp on the main project with the given format.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
format: gyp -f value.
|
|
|
|
"""
|
|
|
|
shell_call(' '.join([
|
2013-01-30 07:04:19 +00:00
|
|
|
'gyp',
|
2013-01-11 09:23:08 +00:00
|
|
|
'-f %s' % (format),
|
|
|
|
# Removes the out/ from ninja builds.
|
|
|
|
'-G output_dir=.',
|
|
|
|
'--depth=.',
|
2013-10-18 06:35:54 +00:00
|
|
|
'--toplevel-dir=.',
|
2013-01-11 09:23:08 +00:00
|
|
|
'--generator-output=build/xenia/',
|
2013-10-18 06:35:54 +00:00
|
|
|
# Set the VS version.
|
2014-12-20 01:09:39 +00:00
|
|
|
'-G msvs_version=%s' % (os.environ.get('VSVERSION', 2015)),
|
2013-10-18 06:35:54 +00:00
|
|
|
#'-D windows_sdk_dir=%s' % (os.environ['WINDOWSSDKDIR']),
|
|
|
|
'-D windows_sdk_dir="C:\\Program Files (x86)\\Windows Kits\\8.1"',
|
2013-01-11 09:23:08 +00:00
|
|
|
'xenia.gyp',
|
|
|
|
]))
|
|
|
|
|
|
|
|
|
|
|
|
def run_all_gyps():
|
|
|
|
"""Runs all gyp configurations.
|
|
|
|
"""
|
|
|
|
run_gyp('ninja')
|
2013-01-30 09:35:08 +00:00
|
|
|
if sys.platform == 'darwin':
|
|
|
|
run_gyp('xcode')
|
|
|
|
elif sys.platform == 'win32':
|
|
|
|
run_gyp('msvs')
|
2013-01-11 09:23:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
class GypCommand(Command):
|
|
|
|
"""'gyp' command."""
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(GypCommand, self).__init__(
|
|
|
|
name='gyp',
|
|
|
|
help_short='Runs gyp to update all projects.',
|
|
|
|
*args, **kwargs)
|
|
|
|
|
|
|
|
def execute(self, args, cwd):
|
2013-10-18 04:41:14 +00:00
|
|
|
print('Running gyp...')
|
|
|
|
print('')
|
2013-01-11 09:23:08 +00:00
|
|
|
|
|
|
|
# Update GYP.
|
|
|
|
run_all_gyps()
|
|
|
|
|
2013-10-18 04:41:14 +00:00
|
|
|
print('Success!')
|
2013-01-11 09:23:08 +00:00
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
class BuildCommand(Command):
|
|
|
|
"""'build' command."""
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(BuildCommand, self).__init__(
|
|
|
|
name='build',
|
|
|
|
help_short='Builds the project.',
|
|
|
|
*args, **kwargs)
|
|
|
|
|
|
|
|
def execute(self, args, cwd):
|
|
|
|
# TODO(benvanik): add arguments:
|
|
|
|
# --force
|
|
|
|
debug = '--debug' in args
|
2014-07-18 02:49:58 +00:00
|
|
|
config = 'Debug' if debug else 'Release'
|
2014-09-10 03:15:49 +00:00
|
|
|
target = ''
|
|
|
|
for arg in args:
|
|
|
|
if not arg.startswith('--'):
|
|
|
|
target = arg
|
2013-01-11 09:23:08 +00:00
|
|
|
|
2013-10-18 04:41:14 +00:00
|
|
|
print('Building %s...' % (config))
|
|
|
|
print('')
|
2013-01-11 09:23:08 +00:00
|
|
|
|
2013-10-18 04:41:14 +00:00
|
|
|
print('- running gyp for ninja...')
|
2013-01-11 09:23:08 +00:00
|
|
|
run_gyp('ninja')
|
2013-10-18 04:41:14 +00:00
|
|
|
print('')
|
2013-01-11 09:23:08 +00:00
|
|
|
|
2014-09-10 03:15:49 +00:00
|
|
|
if not target:
|
|
|
|
print('- building all:%s...' % (config))
|
|
|
|
result = shell_call('ninja -C build/xenia/%s' % (config),
|
|
|
|
throw_on_error=False)
|
|
|
|
else:
|
|
|
|
print('- building %s:%s...' % (target, config))
|
|
|
|
result = shell_call('ninja -C build/xenia/%s %s' % (config, target),
|
|
|
|
throw_on_error=False)
|
2013-10-18 04:41:14 +00:00
|
|
|
print('')
|
2013-01-13 07:25:41 +00:00
|
|
|
if result != 0:
|
|
|
|
return result
|
2013-01-11 09:23:08 +00:00
|
|
|
|
2013-10-18 04:41:14 +00:00
|
|
|
print('Success!')
|
2013-01-13 23:48:18 +00:00
|
|
|
return 0
|
|
|
|
|
|
|
|
|
2013-01-27 10:51:53 +00:00
|
|
|
class TestCommand(Command):
|
|
|
|
"""'test' command."""
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(TestCommand, self).__init__(
|
|
|
|
name='test',
|
|
|
|
help_short='Runs all tests.',
|
|
|
|
*args, **kwargs)
|
|
|
|
|
|
|
|
def execute(self, args, cwd):
|
2013-10-18 04:41:14 +00:00
|
|
|
print('Testing...')
|
|
|
|
print('')
|
2013-01-27 10:51:53 +00:00
|
|
|
|
2015-03-24 14:46:18 +00:00
|
|
|
# Run base CPU tests.
|
|
|
|
print('Launching xe-cpu-hir-test runner...')
|
|
|
|
result = shell_call('"build/xenia/Debug/xe-cpu-hir-test"')
|
2013-10-18 04:41:14 +00:00
|
|
|
print('')
|
2013-01-27 10:51:53 +00:00
|
|
|
if result != 0:
|
|
|
|
return result
|
|
|
|
|
2014-09-10 03:25:38 +00:00
|
|
|
# First run make and update all of the test files.
|
|
|
|
if sys.platform == 'win32':
|
|
|
|
# TODO(benvanik): use cygwin/vagrant/whatever
|
|
|
|
print('WARNING: test files not updated!');
|
|
|
|
else:
|
|
|
|
print('Updating test files...')
|
2015-03-24 14:46:18 +00:00
|
|
|
result = shell_call('./src/xenia/cpu/frontend/ppc/test/update.sh')
|
2014-09-10 03:25:38 +00:00
|
|
|
print('')
|
|
|
|
if result != 0:
|
|
|
|
return result
|
|
|
|
|
2013-01-27 10:51:53 +00:00
|
|
|
# Start the test runner.
|
2015-03-24 14:46:18 +00:00
|
|
|
print('Launching xe-cpu-ppc-test runner...')
|
|
|
|
result = shell_call('"build/xenia/Debug/xe-cpu-ppc-test"')
|
2013-10-18 04:41:14 +00:00
|
|
|
print('')
|
2014-09-10 03:25:38 +00:00
|
|
|
if result != 0:
|
|
|
|
return result
|
2013-01-27 10:51:53 +00:00
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
2013-01-11 09:23:08 +00:00
|
|
|
class CleanCommand(Command):
|
|
|
|
"""'clean' command."""
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(CleanCommand, self).__init__(
|
|
|
|
name='clean',
|
|
|
|
help_short='Removes intermediate files and build output.',
|
|
|
|
*args, **kwargs)
|
|
|
|
|
|
|
|
def execute(self, args, cwd):
|
2013-10-18 04:41:14 +00:00
|
|
|
print('Cleaning build artifacts...')
|
|
|
|
print('')
|
2013-01-11 09:23:08 +00:00
|
|
|
|
2013-10-18 04:41:14 +00:00
|
|
|
print('- removing build/xenia/...')
|
2013-01-11 09:23:08 +00:00
|
|
|
if os.path.isdir('build/xenia/'):
|
|
|
|
shutil.rmtree('build/xenia/')
|
2013-10-18 04:41:14 +00:00
|
|
|
print('')
|
2013-01-11 09:23:08 +00:00
|
|
|
|
2013-10-18 04:41:14 +00:00
|
|
|
print('Success!')
|
2013-01-11 09:23:08 +00:00
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
class NukeCommand(Command):
|
|
|
|
"""'nuke' command."""
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(NukeCommand, self).__init__(
|
|
|
|
name='nuke',
|
|
|
|
help_short='Removes all build/ output.',
|
|
|
|
*args, **kwargs)
|
|
|
|
|
|
|
|
def execute(self, args, cwd):
|
2013-10-18 04:41:14 +00:00
|
|
|
print('Cleaning build artifacts...')
|
|
|
|
print('')
|
2013-01-11 09:23:08 +00:00
|
|
|
|
2013-10-18 04:41:14 +00:00
|
|
|
print('- removing build/...')
|
2013-01-11 09:23:08 +00:00
|
|
|
if os.path.isdir('build/'):
|
|
|
|
shutil.rmtree('build/')
|
2013-10-18 04:41:14 +00:00
|
|
|
print('')
|
2013-01-11 09:23:08 +00:00
|
|
|
|
2013-10-18 04:41:14 +00:00
|
|
|
print('Success!')
|
2013-01-11 09:23:08 +00:00
|
|
|
return 0
|
|
|
|
|
|
|
|
|
2015-02-21 22:45:23 +00:00
|
|
|
class FormatCommand(Command):
|
|
|
|
"""'format' command."""
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(FormatCommand, self).__init__(
|
|
|
|
name='format',
|
|
|
|
help_short='Reformats staged code with clang-format.',
|
|
|
|
*args, **kwargs)
|
|
|
|
|
|
|
|
def execute(self, args, cwd):
|
|
|
|
print('Formatting staged code...')
|
|
|
|
print('')
|
|
|
|
|
|
|
|
binary = 'clang-format'
|
|
|
|
win32_binary = 'C:\\Program Files (x86)\\LLVM\\bin\\clang-format.exe'
|
|
|
|
if os.path.exists(win32_binary):
|
|
|
|
binary = win32_binary
|
|
|
|
|
|
|
|
if not has_bin(binary):
|
|
|
|
print 'ERROR: clang-format is not on PATH'
|
|
|
|
print 'LLVM is available from http://llvm.org/releases/download.html'
|
|
|
|
print 'See docs/style_guide.md for instructions on how to get it'
|
|
|
|
return 1
|
|
|
|
|
|
|
|
shell_call(' '.join([
|
|
|
|
'python third_party/clang-format/git-clang-format',
|
|
|
|
'--binary="%s"' % (binary),
|
|
|
|
'--commit=HEAD',
|
|
|
|
]))
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
2013-01-11 09:23:08 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|