Files
sdk/tools/clean_output_directory.py
T
ricow@google.com 71ff9c1549 Fix dart editor buildbot scripts to support clobbering.
Additionally, default to deleting both debug and release mode output directories when nothing has been specified on the command line using the --mode option.
Review URL: https://chromiumcodereview.appspot.com//10829351

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10789 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-16 05:55:09 +00:00

66 lines
1.9 KiB
Python
Executable File

#!/usr/bin/env python
#
# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
#
import optparse
import shutil
import sys
import utils
HOST_OS = utils.GuessOS()
def BuildOptions():
result = optparse.OptionParser()
result.add_option("-m", "--mode",
help='Build variants (comma-separated).',
metavar='[all,debug,release]',
default='all')
result.add_option("--arch",
help='Target architectures (comma-separated).',
metavar='[all,ia32,x64,simarm,arm]',
default=utils.GuessArchitecture())
return result
def ProcessOptions(options):
if options.arch == 'all':
options.arch = 'ia32,x64'
if options.mode == 'all':
options.mode = 'release,debug'
options.mode = options.mode.split(',')
options.arch = options.arch.split(',')
for mode in options.mode:
if not mode in ['debug', 'release']:
print "Unknown mode %s" % mode
return False
for arch in options.arch:
if not arch in ['ia32', 'x64', 'simarm', 'arm']:
print "Unknown arch %s" % arch
return False
return True
def Main():
parser = BuildOptions()
(options, args) = parser.parse_args()
if not ProcessOptions(options):
parser.print_help()
return 1
# Delete the output for the targets for each requested configuration.
for mode in options.mode:
for arch in options.arch:
build_root = utils.GetBuildRoot(HOST_OS, mode=mode, arch=arch)
print "Deleting %s" % (build_root)
shutil.rmtree(build_root, ignore_errors=True)
# On windows we have additional object files within the runtime library.
if HOST_OS == 'win32':
runtime_root = 'runtime/' + build_root
print "Deleting %s" % (runtime_root)
shutil.rmtree(runtime_root, ignore_errors=True)
return 0
if __name__ == '__main__':
sys.exit(Main())