forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update import_util.py to work from chrome/chrome_cleaner/internal
This prepares for a pending commit to the internal chrome_cleaner repo which will delete the internal copy of import_util.py: * Add separate GetChromiumRootDirectory and GetInternalRootDirectory functions to clarify the ambiguous term "root directory" when called from the internal repo mounted at //chrome/chrome_cleaner/internal. * Move all the functions that depend on being called from inside the chromium source tree to a separate import_paths.py script. (All the current callers of these functions happen to be in //chrome/chrome_cleaner/internal.) * Delete code to find a local copy of find_depot_tools. It's no longer supported to run this script without calling gclient sync, which will update depot_tools. R=proberge Bug: 1004848 Change-Id: I829851f332975c950f1dcde59735ee96f34f295e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2451810 Reviewed-by: proberge <proberge@chromium.org> Commit-Queue: proberge <proberge@chromium.org> Auto-Submit: Joe Mason <joenotcharles@chromium.org> Cr-Commit-Position: refs/heads/master@{#814390}
- Loading branch information
1 parent
415c28c
commit 1673a55
Showing
2 changed files
with
54 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright 2020 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. | ||
"""Paths for python proto modules and depot_tools. | ||
This script must be used from inside a chromium checkout because it depends on | ||
paths relative to the root of the checkout. | ||
""" | ||
|
||
import import_util | ||
import os | ||
import sys | ||
|
||
|
||
# Expect this script to be located in <root_dir>/chrome/chrome_cleaner/tools. | ||
_CURRENT_DIRECTORY = os.path.dirname(os.path.abspath(__file__)) | ||
_ROOT_DIRECTORY = os.path.normpath(os.path.join(_CURRENT_DIRECTORY, os.pardir, | ||
os.pardir, os.pardir)) | ||
assert(_CURRENT_DIRECTORY == os.path.join(_ROOT_DIRECTORY, 'chrome', | ||
'chrome_cleaner', 'tools')) | ||
|
||
|
||
def GetBuildDirectory(build_configuration): | ||
"""Returns the path to the build directory relative to this file. | ||
Args: | ||
build_configuration: name of the build configuration whose directory | ||
should be looked up, e.g. 'Debug' or 'Release'. | ||
""" | ||
return os.path.join(_ROOT_DIRECTORY, 'out', build_configuration) | ||
|
||
|
||
def GetChromiumRootDirectory(): | ||
"""Returns the path to root directory of the chromium checkout.""" | ||
return _ROOT_DIRECTORY | ||
|
||
|
||
def GetInternalRootDirectory(): | ||
"""Returns the path to //chrome/chrome_cleaner/internal.""" | ||
return os.path.join(_ROOT_DIRECTORY, 'chrome', 'chrome_cleaner', 'internal') | ||
|
||
|
||
def AddDepotToolsToPath(): | ||
"""Locates a depot_tools checkout and adds it to the Python import path. | ||
Returns: | ||
The path to depot_tools. | ||
""" | ||
|
||
# Try to import find_depot_tools from the build subdir. | ||
import_util.AddImportPath(os.path.join(_ROOT_DIRECTORY, 'build')) | ||
import find_depot_tools | ||
return find_depot_tools.add_depot_tools_to_path() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters