summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authormcgrathr <mcgrathr@chromium.org>2015-10-26 15:07:51 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-26 22:08:26 +0000
commitb729cfa517895b9ea99c98a8b23f1a811772ba5b (patch)
tree3dfef5d171cd24997100ccaf1fc54207229a7fd9 /build
parent999ebc60a57bed3db7730a7d7ec97b41ec01c9eb (diff)
downloadchromium_src-b729cfa517895b9ea99c98a8b23f1a811772ba5b.zip
chromium_src-b729cfa517895b9ea99c98a8b23f1a811772ba5b.tar.gz
chromium_src-b729cfa517895b9ea99c98a8b23f1a811772ba5b.tar.bz2
Move find_depot_tools.py to build/
build/vs_toolchain.py requires find_depot_tools.py, but it's not available to a project that gets build/ via DEPS and does not also get all of tools/ via DEPS. The native_client repo needs to use build/vs_toolchain.py, but it does not copy chromium/src/tools/ and it should not have to duplicate find_depot_tools.py just to use build/vs_toolchain.py. The native_client repo also needs a standalone script to print out the depot_tools directory location, and find_depot_tools.py can serve that purpose too with some trivial additions. BUG= 512869 R=ben@chromium.org, dbeam@chromium.org, dpranke@chromium.org, jbudorick@chromium.org, klundberg@chromium.org, phajdan.jr@chromium.org, sky@chromium.org, tbreisacher@chromium.org Review URL: https://codereview.chromium.org/1418513007 Cr-Commit-Position: refs/heads/master@{#356141}
Diffstat (limited to 'build')
-rwxr-xr-xbuild/download_gold_plugin.py3
-rwxr-xr-xbuild/download_sdk_extras.py3
-rwxr-xr-xbuild/find_depot_tools.py60
-rwxr-xr-xbuild/vs_toolchain.py1
4 files changed, 62 insertions, 5 deletions
diff --git a/build/download_gold_plugin.py b/build/download_gold_plugin.py
index e45430b..d4fb48b 100755
--- a/build/download_gold_plugin.py
+++ b/build/download_gold_plugin.py
@@ -5,6 +5,7 @@
"""Script to download LLVM gold plugin from google storage."""
+import find_depot_tools
import json
import os
import shutil
@@ -14,9 +15,7 @@ import zipfile
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
CHROME_SRC = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir))
-sys.path.insert(0, os.path.join(CHROME_SRC, 'tools'))
-import find_depot_tools
DEPOT_PATH = find_depot_tools.add_depot_tools_to_path()
GSUTIL_PATH = os.path.join(DEPOT_PATH, 'gsutil.py')
diff --git a/build/download_sdk_extras.py b/build/download_sdk_extras.py
index aa1402a..7c3a678 100755
--- a/build/download_sdk_extras.py
+++ b/build/download_sdk_extras.py
@@ -13,6 +13,7 @@ script will not do anything for developers.
TODO(navabi): Move this script (crbug.com/459819).
"""
+import find_depot_tools
import json
import os
import shutil
@@ -23,10 +24,8 @@ import zipfile
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
CHROME_SRC = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir))
sys.path.insert(0, os.path.join(SCRIPT_DIR, 'android'))
-sys.path.insert(1, os.path.join(CHROME_SRC, 'tools'))
from pylib import constants
-import find_depot_tools
DEPOT_PATH = find_depot_tools.add_depot_tools_to_path()
GSUTIL_PATH = os.path.join(DEPOT_PATH, 'gsutil.py')
diff --git a/build/find_depot_tools.py b/build/find_depot_tools.py
new file mode 100755
index 0000000..1c34fea
--- /dev/null
+++ b/build/find_depot_tools.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+# Copyright (c) 2011 The Chromium 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/vs_toolchain.py b/build/vs_toolchain.py
index 0c6757e..648c7e6 100755
--- a/build/vs_toolchain.py
+++ b/build/vs_toolchain.py
@@ -14,7 +14,6 @@ import sys
script_dir = os.path.dirname(os.path.realpath(__file__))
chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir))
SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-sys.path.insert(1, os.path.join(chrome_src, 'tools'))
sys.path.insert(0, os.path.join(chrome_src, 'tools', 'gyp', 'pylib'))
json_data_file = os.path.join(script_dir, 'win_toolchain.json')