michael@0: #!/usr/bin/env python michael@0: # Copyright (c) 2012 The Chromium Authors. All rights reserved. michael@0: # Use of this source code is governed by a BSD-style license that can be michael@0: # found in the LICENSE file. michael@0: michael@0: """Shim to run nacl toolchain download script only if there is a nacl dir.""" michael@0: michael@0: import os michael@0: import sys michael@0: michael@0: michael@0: def Main(args): michael@0: # Exit early if disable_nacl=1. michael@0: if 'disable_nacl=1' in os.environ.get('GYP_DEFINES', ''): michael@0: return 0 michael@0: script_dir = os.path.dirname(os.path.abspath(__file__)) michael@0: src_dir = os.path.dirname(script_dir) michael@0: nacl_dir = os.path.join(src_dir, 'native_client') michael@0: nacl_build_dir = os.path.join(nacl_dir, 'build') michael@0: download_script = os.path.join(nacl_build_dir, 'download_toolchains.py') michael@0: if not os.path.exists(download_script): michael@0: print "Can't find '%s'" % download_script michael@0: print 'Presumably you are intentionally building without NativeClient.' michael@0: print 'Skipping NativeClient toolchain download.' michael@0: sys.exit(0) michael@0: sys.path.insert(0, nacl_build_dir) michael@0: import download_toolchains michael@0: michael@0: # TODO (robertm): Finish getting PNaCl ready for prime time. michael@0: # BUG: michael@0: # We remove this --optional-pnacl argument, and instead replace it with michael@0: # --no-pnacl for most cases. However, if the bot name is the pnacl_sdk michael@0: # bot then we will go ahead and download it. This prevents increasing the michael@0: # gclient sync time for developers, or standard Chrome bots. michael@0: if '--optional-pnacl' in args: michael@0: args.remove('--optional-pnacl') michael@0: # By default we don't use PNaCl toolchain yet, unless on ARM, where michael@0: # there is no other toolchain to build untrusted code at the moment. michael@0: # So analyze if we're building for ARM, or on SDK buildbot. michael@0: # TODO(olonho): we need to invent more reliable way to get build michael@0: # configuration info, to know if we're building for ARM. michael@0: use_pnacl = False michael@0: if 'target_arch=arm' in os.environ.get('GYP_DEFINES', ''): michael@0: use_pnacl = True michael@0: buildbot_name = os.environ.get('BUILDBOT_BUILDERNAME', '') michael@0: if buildbot_name.find('pnacl') >= 0 and buildbot_name.find('sdk') >= 0: michael@0: use_pnacl = True michael@0: if use_pnacl: michael@0: print '\n*** DOWNLOADING PNACL TOOLCHAIN ***\n' michael@0: else: michael@0: args.append('--no-pnacl') michael@0: michael@0: # Append the name of the file to use as a version and hash source. michael@0: # NOTE: While not recommended, it is possible to redirect this file to michael@0: # a chrome location to avoid branching NaCl if just a toolchain needs michael@0: # to be bumped. michael@0: args.append(os.path.join(nacl_dir,'TOOL_REVISIONS')) michael@0: michael@0: download_toolchains.main(args) michael@0: return 0 michael@0: michael@0: michael@0: if __name__ == '__main__': michael@0: sys.exit(Main(sys.argv[1:]))