From 5593bb8573c1deb1c649083d51963348adf972da Mon Sep 17 00:00:00 2001 From: weili Date: Fri, 29 Apr 2016 20:14:55 -0700 Subject: Use utilities from build directory instead of own copies GYP and GN builds share some common utilities. GYP has three utilities in its own directory which are also synced in build directory now. We will use utilities from build directory instead of keeping our own copies. Compared to our own copies, utilities in build directory are either same or newer. find_depot_tools.py is identical; vs_toolchain.py and find_sdk.py have some minor updates. Review-Url: https://codereview.chromium.org/1933843002 --- build_gyp/find_depot_tools.py | 60 ------- build_gyp/gyp_pdfium | 2 + build_gyp/mac_find_sdk.py | 93 ----------- build_gyp/standalone.gypi | 2 +- build_gyp/vs_toolchain.py | 378 ------------------------------------------ 5 files changed, 3 insertions(+), 532 deletions(-) delete mode 100644 build_gyp/find_depot_tools.py delete mode 100644 build_gyp/mac_find_sdk.py delete mode 100644 build_gyp/vs_toolchain.py (limited to 'build_gyp') diff --git a/build_gyp/find_depot_tools.py b/build_gyp/find_depot_tools.py deleted file mode 100644 index 6ec83b3d5c..0000000000 --- a/build_gyp/find_depot_tools.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python -# Copyright 2016 PDFium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -"""Small utility function to find depot_tools and add it to the python path. - -Will throw an ImportError exception if depot_tools can't be found since it -imports breakpad. - -This can also be used as a standalone script to print out the depot_tools -directory location. -""" - -import os -import sys - - -def IsRealDepotTools(path): - return os.path.isfile(os.path.join(path, 'gclient.py')) - - -def add_depot_tools_to_path(): - """Search for depot_tools and add it to sys.path.""" - # First look if depot_tools is already in PYTHONPATH. - for i in sys.path: - if i.rstrip(os.sep).endswith('depot_tools') and IsRealDepotTools(i): - return i - # Then look if depot_tools is in PATH, common case. - for i in os.environ['PATH'].split(os.pathsep): - if IsRealDepotTools(i): - sys.path.append(i.rstrip(os.sep)) - return i - # Rare case, it's not even in PATH, look upward up to root. - root_dir = os.path.dirname(os.path.abspath(__file__)) - previous_dir = os.path.abspath(__file__) - while root_dir and root_dir != previous_dir: - i = os.path.join(root_dir, 'depot_tools') - if IsRealDepotTools(i): - sys.path.append(i) - return i - previous_dir = root_dir - root_dir = os.path.dirname(root_dir) - print >> sys.stderr, 'Failed to find depot_tools' - return None - -DEPOT_TOOLS_PATH = add_depot_tools_to_path() - -# pylint: disable=W0611 -import breakpad - - -def main(): - if DEPOT_TOOLS_PATH is None: - return 1 - print DEPOT_TOOLS_PATH - return 0 - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/build_gyp/gyp_pdfium b/build_gyp/gyp_pdfium index 23b1c719c2..6a2540391c 100755 --- a/build_gyp/gyp_pdfium +++ b/build_gyp/gyp_pdfium @@ -17,7 +17,9 @@ output_rel_dir = 'out' sys.path.insert(0, os.path.join(pdfium_root, 'tools', 'gyp', 'pylib')) import gyp + # vs_toolchain needs to be after gyp path setting since it also uses gyp. +sys.path.insert(0, os.path.join(pdfium_root, 'build')) import vs_toolchain def run_gyp(args): diff --git a/build_gyp/mac_find_sdk.py b/build_gyp/mac_find_sdk.py deleted file mode 100644 index 230c2fd52e..0000000000 --- a/build_gyp/mac_find_sdk.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env python -# Copyright 2016 PDFium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Prints the lowest locally available SDK version greater than or equal to a -given minimum sdk version to standard output. - -Usage: - python mac_find_sdk.py 10.6 # Ignores SDKs < 10.6 -""" - -import os -import re -import subprocess -import sys - - -from optparse import OptionParser - - -def parse_version(version_str): - """'10.6' => [10, 6]""" - return map(int, re.findall(r'(\d+)', version_str)) - - -def main(): - parser = OptionParser() - parser.add_option("--verify", - action="store_true", dest="verify", default=False, - help="return the sdk argument and warn if it doesn't exist") - parser.add_option("--sdk_path", - action="store", type="string", dest="sdk_path", default="", - help="user-specified SDK path; bypasses verification") - parser.add_option("--print_sdk_path", - action="store_true", dest="print_sdk_path", default=False, - help="Additionaly print the path the SDK (appears first).") - options, args = parser.parse_args() - if len(args) != 1: - parser.error('Please specify a minimum SDK version') - min_sdk_version = args[0] - - job = subprocess.Popen(['xcode-select', '-print-path'], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - out, err = job.communicate() - if job.returncode != 0: - print >> sys.stderr, out - print >> sys.stderr, err - raise Exception(('Error %d running xcode-select, you might have to run ' - '|sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer| ' - 'if you are using Xcode 4.') % job.returncode) - # The Developer folder moved in Xcode 4.3. - xcode43_sdk_path = os.path.join( - out.rstrip(), 'Platforms/MacOSX.platform/Developer/SDKs') - if os.path.isdir(xcode43_sdk_path): - sdk_dir = xcode43_sdk_path - else: - sdk_dir = os.path.join(out.rstrip(), 'SDKs') - sdks = [re.findall('^MacOSX(10\.\d+)\.sdk$', s) for s in os.listdir(sdk_dir)] - sdks = [s[0] for s in sdks if s] # [['10.5'], ['10.6']] => ['10.5', '10.6'] - sdks = [s for s in sdks # ['10.5', '10.6'] => ['10.6'] - if parse_version(s) >= parse_version(min_sdk_version)] - if not sdks: - raise Exception('No %s+ SDK found' % min_sdk_version) - best_sdk = sorted(sdks, key=parse_version)[0] - - if options.verify and best_sdk != min_sdk_version and not options.sdk_path: - print >> sys.stderr, '' - print >> sys.stderr, ' vvvvvvv' - print >> sys.stderr, '' - print >> sys.stderr, \ - 'This build requires the %s SDK, but it was not found on your system.' \ - % min_sdk_version - print >> sys.stderr, \ - 'Either install it, or explicitly set mac_sdk in your GYP_DEFINES.' - print >> sys.stderr, '' - print >> sys.stderr, ' ^^^^^^^' - print >> sys.stderr, '' - return min_sdk_version - - if options.print_sdk_path: - print subprocess.check_output(['xcodebuild', '-version', '-sdk', - 'macosx' + best_sdk, 'Path']).strip() - - return best_sdk - - -if __name__ == '__main__': - if sys.platform != 'darwin': - raise Exception("This script only runs on Mac") - print main() - sys.exit(0) diff --git a/build_gyp/standalone.gypi b/build_gyp/standalone.gypi index f7cad6622a..67ed204409 100644 --- a/build_gyp/standalone.gypi +++ b/build_gyp/standalone.gypi @@ -453,7 +453,7 @@ ], # target_conditions 'variables': { 'mac_sdk_min': '10.10', - 'mac_sdk%': '>sys.stderr, 'Unknown parameter "%s"' % force - return 1 - if force == '--force' or os.path.exists(json_data_file): - force = True - - depot_tools_win_toolchain = \ - bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) - if ((sys.platform in ('win32', 'cygwin') or force) and - depot_tools_win_toolchain): - import find_depot_tools - depot_tools_path = find_depot_tools.add_depot_tools_to_path() - # Necessary so that get_toolchain_if_necessary.py will put the VS toolkit - # in the correct directory. - os.environ['GYP_MSVS_VERSION'] = GetVisualStudioVersion() - get_toolchain_args = [ - sys.executable, - os.path.join(depot_tools_path, - 'win_toolchain', - 'get_toolchain_if_necessary.py'), - '--output-json', json_data_file, - ] + _GetDesiredVsToolchainHashes() - if force: - get_toolchain_args.append('--force') - subprocess.check_call(get_toolchain_args) - - return 0 - - -def NormalizePath(path): - while path.endswith("\\"): - path = path[:-1] - return path - - -def GetToolchainDir(): - """Gets location information about the current toolchain (must have been - previously updated by 'update'). This is used for the GN build.""" - runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs() - - # If WINDOWSSDKDIR is not set, search the default SDK path and set it. - if not 'WINDOWSSDKDIR' in os.environ: - default_sdk_path = 'C:\\Program Files (x86)\\Windows Kits\\10' - if os.path.isdir(default_sdk_path): - os.environ['WINDOWSSDKDIR'] = default_sdk_path - - print '''vs_path = "%s" -sdk_path = "%s" -vs_version = "%s" -wdk_dir = "%s" -runtime_dirs = "%s" -''' % ( - NormalizePath(os.environ['GYP_MSVS_OVERRIDE_PATH']), - NormalizePath(os.environ['WINDOWSSDKDIR']), - GetVisualStudioVersion(), - NormalizePath(os.environ.get('WDK_DIR', '')), - os.path.pathsep.join(runtime_dll_dirs or ['None'])) - - -def main(): - commands = { - 'update': Update, - 'get_toolchain_dir': GetToolchainDir, - 'copy_dlls': CopyDlls, - } - if len(sys.argv) < 2 or sys.argv[1] not in commands: - print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) - return 1 - return commands[sys.argv[1]](*sys.argv[2:]) - - -if __name__ == '__main__': - sys.exit(main()) -- cgit v1.2.3