Improvements to automate.py:
- Allow specification of the depot_tools directory via a "depot-tools" flag (issue #592). - Add ninja build support via a "ninja-build" flag (issue #922). - Allow relative paths for download directories (issue #942). - Add the ability to print commands without executing them via a "dry-run" flag. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1194 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
e98c1c41a8
commit
006ac136a8
|
@ -23,9 +23,10 @@ def run(command_line, working_dir, depot_tools_dir=None):
|
||||||
|
|
||||||
sys.stdout.write('-------- Running "'+command_line+'" in "'+\
|
sys.stdout.write('-------- Running "'+command_line+'" in "'+\
|
||||||
working_dir+'"...'+"\n")
|
working_dir+'"...'+"\n")
|
||||||
args = shlex.split(command_line.replace('\\', '\\\\'))
|
if not options.dryrun:
|
||||||
return subprocess.check_call(args, cwd=working_dir, env=env,
|
args = shlex.split(command_line.replace('\\', '\\\\'))
|
||||||
shell=(sys.platform == 'win32'))
|
return subprocess.check_call(args, cwd=working_dir, env=env,
|
||||||
|
shell=(sys.platform == 'win32'))
|
||||||
|
|
||||||
def check_url(url):
|
def check_url(url):
|
||||||
""" Check the URL and raise an exception if invalid. """
|
""" Check the URL and raise an exception if invalid. """
|
||||||
|
@ -91,6 +92,8 @@ parser.add_option('--revision', dest='revision', type="int",
|
||||||
help='CEF source revision')
|
help='CEF source revision')
|
||||||
parser.add_option('--url', dest='url',
|
parser.add_option('--url', dest='url',
|
||||||
help='CEF source URL')
|
help='CEF source URL')
|
||||||
|
parser.add_option('--depot-tools', dest='depottools', metavar='DIR',
|
||||||
|
help='download directory for depot_tools', default='')
|
||||||
parser.add_option('--force-config',
|
parser.add_option('--force-config',
|
||||||
action='store_true', dest='forceconfig', default=False,
|
action='store_true', dest='forceconfig', default=False,
|
||||||
help='force Chromium configuration')
|
help='force Chromium configuration')
|
||||||
|
@ -118,6 +121,12 @@ parser.add_option('--no-release-build',
|
||||||
parser.add_option('--no-distrib',
|
parser.add_option('--no-distrib',
|
||||||
action='store_true', dest='nodistrib', default=False,
|
action='store_true', dest='nodistrib', default=False,
|
||||||
help="don't create the CEF binary distribution")
|
help="don't create the CEF binary distribution")
|
||||||
|
parser.add_option('--ninja-build',
|
||||||
|
action='store_true', dest='ninjabuild', default=False,
|
||||||
|
help="build using ninja")
|
||||||
|
parser.add_option('--dry-run',
|
||||||
|
action='store_true', dest='dryrun', default=False,
|
||||||
|
help="output commands without executing them")
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
# the downloaddir option is required
|
# the downloaddir option is required
|
||||||
|
@ -176,7 +185,7 @@ except Exception, e:
|
||||||
compat_url+"\n")
|
compat_url+"\n")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
download_dir = options.downloaddir
|
download_dir = os.path.abspath(options.downloaddir)
|
||||||
if not os.path.exists(download_dir):
|
if not os.path.exists(download_dir):
|
||||||
# create the download directory
|
# create the download directory
|
||||||
os.makedirs(download_dir)
|
os.makedirs(download_dir)
|
||||||
|
@ -197,7 +206,10 @@ else:
|
||||||
script_ext = '.sh'
|
script_ext = '.sh'
|
||||||
|
|
||||||
# check if the "depot_tools" directory exists
|
# check if the "depot_tools" directory exists
|
||||||
depot_tools_dir = os.path.join(download_dir, 'depot_tools')
|
if options.depottools != '':
|
||||||
|
depot_tools_dir = os.path.abspath(options.depottools)
|
||||||
|
else:
|
||||||
|
depot_tools_dir = os.path.join(download_dir, 'depot_tools')
|
||||||
if not os.path.exists(depot_tools_dir):
|
if not os.path.exists(depot_tools_dir):
|
||||||
# checkout depot_tools
|
# checkout depot_tools
|
||||||
run('svn checkout '+depot_tools_url+' '+depot_tools_dir, download_dir)
|
run('svn checkout '+depot_tools_url+' '+depot_tools_dir, download_dir)
|
||||||
|
@ -291,55 +303,60 @@ if release_url_changed or chromium_url_changed or options.forceconfig:
|
||||||
# run gclient config to create the .gclient file
|
# run gclient config to create the .gclient file
|
||||||
run('gclient config '+url, chromium_dir, depot_tools_dir)
|
run('gclient config '+url, chromium_dir, depot_tools_dir)
|
||||||
|
|
||||||
path = os.path.join(chromium_dir, '.gclient')
|
if not options.dryrun:
|
||||||
if not os.path.exists(path):
|
path = os.path.join(chromium_dir, '.gclient')
|
||||||
sys.stderr.write(".gclient file was not created\n")
|
if not os.path.exists(path):
|
||||||
raise Exception('.gclient file was not created')
|
sys.stderr.write(".gclient file was not created\n")
|
||||||
|
raise Exception('.gclient file was not created')
|
||||||
|
|
||||||
# read the resulting .gclient file
|
# read the resulting .gclient file
|
||||||
fp = open(path, 'r')
|
fp = open(path, 'r')
|
||||||
data = fp.read()
|
data = fp.read()
|
||||||
fp.close()
|
fp.close()
|
||||||
|
|
||||||
custom_deps = \
|
custom_deps = \
|
||||||
"\n "+'"src/third_party/WebKit/LayoutTests": None,'+\
|
"\n "+'"src/third_party/WebKit/LayoutTests": None,'+\
|
||||||
"\n "+'"src/chrome_frame/tools/test/reference_build/chrome": None,'+\
|
"\n "+'"src/chrome_frame/tools/test/reference_build/chrome": None,'+\
|
||||||
"\n "+'"src/chrome/tools/test/reference_build/chrome_mac": None,'+\
|
"\n "+'"src/chrome/tools/test/reference_build/chrome_mac": None,'+\
|
||||||
"\n "+'"src/chrome/tools/test/reference_build/chrome_win": None,'+\
|
"\n "+'"src/chrome/tools/test/reference_build/chrome_win": None,'+\
|
||||||
"\n "+'"src/chrome/tools/test/reference_build/chrome_linux": None,'
|
"\n "+'"src/chrome/tools/test/reference_build/chrome_linux": None,'
|
||||||
|
|
||||||
if not release_url is None:
|
if not release_url is None:
|
||||||
# TODO: Read the DEPS file and exclude all non-src directories.
|
# TODO: Read the DEPS file and exclude all non-src directories.
|
||||||
custom_deps += \
|
custom_deps += \
|
||||||
"\n "+'"chromeos": None,'+\
|
"\n "+'"chromeos": None,'+\
|
||||||
"\n "+'"depot_tools": None,'
|
"\n "+'"depot_tools": None,'
|
||||||
|
|
||||||
# populate "custom_deps" section
|
# populate "custom_deps" section
|
||||||
data = data.replace('"custom_deps" : {', '"custom_deps" : {'+custom_deps)
|
data = data.replace('"custom_deps" : {', '"custom_deps" : {'+custom_deps)
|
||||||
|
|
||||||
# write the new .gclient file
|
# write the new .gclient file
|
||||||
fp = open(path, 'w')
|
fp = open(path, 'w')
|
||||||
fp.write(data)
|
fp.write(data)
|
||||||
fp.close()
|
fp.close()
|
||||||
|
|
||||||
if options.forceclean:
|
if options.forceclean:
|
||||||
if os.path.exists(chromium_src_dir):
|
if os.path.exists(chromium_src_dir):
|
||||||
# revert all Chromium changes and delete all unversioned files
|
# revert all Chromium changes and delete all unversioned files
|
||||||
run('gclient revert -n', chromium_dir, depot_tools_dir)
|
run('gclient revert -n', chromium_dir, depot_tools_dir)
|
||||||
|
|
||||||
# remove the build output directories
|
if not options.dryrun:
|
||||||
output_dirs = []
|
# remove the build output directories
|
||||||
if platform == 'windows':
|
output_dirs = []
|
||||||
output_dirs.append(os.path.join(chromium_src_dir, 'build\\Debug'))
|
if platform == 'windows':
|
||||||
output_dirs.append(os.path.join(chromium_src_dir, 'build\\Release'))
|
output_dirs.append(os.path.join(chromium_src_dir, 'build\\Debug'))
|
||||||
elif platform == 'macosx':
|
output_dirs.append(os.path.join(chromium_src_dir, 'build\\Release'))
|
||||||
output_dirs.append(os.path.join(chromium_src_dir, 'xcodebuild'))
|
elif platform == 'macosx':
|
||||||
elif platform == 'linux':
|
output_dirs.append(os.path.join(chromium_src_dir, 'xcodebuild'))
|
||||||
output_dirs.append(os.path.join(chromium_src_dir, 'out'))
|
elif platform == 'linux':
|
||||||
|
output_dirs.append(os.path.join(chromium_src_dir, 'out'))
|
||||||
|
|
||||||
for output_dir in output_dirs:
|
if options.ninjabuild:
|
||||||
if os.path.exists(output_dir):
|
output_dirs.append(os.path.join(chromium_src_dir, 'out'))
|
||||||
shutil.rmtree(output_dir, onerror=onerror)
|
|
||||||
|
for output_dir in output_dirs:
|
||||||
|
if os.path.exists(output_dir):
|
||||||
|
shutil.rmtree(output_dir, onerror=onerror)
|
||||||
|
|
||||||
# force update, build and distrib steps
|
# force update, build and distrib steps
|
||||||
options.forceupdate = True
|
options.forceupdate = True
|
||||||
|
@ -356,7 +373,7 @@ elif release_url_changed or options.forceupdate:
|
||||||
run('gclient sync --jobs 8 --force', chromium_dir, depot_tools_dir)
|
run('gclient sync --jobs 8 --force', chromium_dir, depot_tools_dir)
|
||||||
|
|
||||||
if not os.path.exists(cef_src_dir) or cef_url_changed:
|
if not os.path.exists(cef_src_dir) or cef_url_changed:
|
||||||
if cef_url_changed and os.path.exists(cef_src_dir):
|
if not options.dryrun and cef_url_changed and os.path.exists(cef_src_dir):
|
||||||
# delete the cef directory (it will be re-downloaded)
|
# delete the cef directory (it will be re-downloaded)
|
||||||
shutil.rmtree(cef_src_dir)
|
shutil.rmtree(cef_src_dir)
|
||||||
|
|
||||||
|
@ -368,22 +385,37 @@ elif cef_rev_changed or options.forceupdate:
|
||||||
|
|
||||||
if any_changed or options.forceupdate:
|
if any_changed or options.forceupdate:
|
||||||
# create CEF projects
|
# create CEF projects
|
||||||
|
if options.ninjabuild:
|
||||||
|
os.environ['GYP_GENERATORS'] = 'ninja'
|
||||||
path = os.path.join(cef_src_dir, 'cef_create_projects'+script_ext)
|
path = os.path.join(cef_src_dir, 'cef_create_projects'+script_ext)
|
||||||
run(path, cef_src_dir, depot_tools_dir)
|
run(path, cef_src_dir, depot_tools_dir)
|
||||||
|
|
||||||
if any_changed or options.forcebuild:
|
if any_changed or options.forcebuild:
|
||||||
path = os.path.join(cef_tools_dir, 'build_projects'+script_ext)
|
if options.ninjabuild:
|
||||||
|
command = 'ninja -C '
|
||||||
|
target = ' cefclient'
|
||||||
|
if not options.nodebugbuild:
|
||||||
|
# make CEF Debug build
|
||||||
|
run(command + os.path.join('out', 'Debug') + target, chromium_src_dir, depot_tools_dir)
|
||||||
|
|
||||||
if not options.nodebugbuild:
|
if not options.noreleasebuild:
|
||||||
# make CEF Debug build
|
# make CEF Release build
|
||||||
run(path+' Debug', cef_tools_dir, depot_tools_dir)
|
run(command + os.path.join('out', 'Release') + target, chromium_src_dir, depot_tools_dir)
|
||||||
|
else:
|
||||||
|
path = os.path.join(cef_tools_dir, 'build_projects'+script_ext)
|
||||||
|
|
||||||
if not options.noreleasebuild:
|
if not options.nodebugbuild:
|
||||||
# make CEF Release build
|
# make CEF Debug build
|
||||||
run(path+' Release', cef_tools_dir, depot_tools_dir)
|
run(path+' Debug', cef_tools_dir, depot_tools_dir)
|
||||||
|
|
||||||
|
if not options.noreleasebuild:
|
||||||
|
# make CEF Release build
|
||||||
|
run(path+' Release', cef_tools_dir, depot_tools_dir)
|
||||||
|
|
||||||
if any_changed or options.forcedistrib:
|
if any_changed or options.forcedistrib:
|
||||||
if not options.nodistrib:
|
if not options.nodistrib:
|
||||||
# make CEF binary distribution
|
# make CEF binary distribution
|
||||||
path = os.path.join(cef_tools_dir, 'make_distrib'+script_ext)
|
path = os.path.join(cef_tools_dir, 'make_distrib'+script_ext)
|
||||||
|
if options.ninjabuild:
|
||||||
|
path = path + ' --ninja-build'
|
||||||
run(path, cef_tools_dir, depot_tools_dir)
|
run(path, cef_tools_dir, depot_tools_dir)
|
||||||
|
|
Loading…
Reference in New Issue