Index: build/android/pylib/constants/__init__.py |
diff --git a/build/android/pylib/constants/__init__.py b/build/android/pylib/constants/__init__.py |
index 1a48723d584e308175ccf2a05cf504246d9b89b7..5e29a55f02f71956d77c053d8a971f1391767ec6 100644 |
--- a/build/android/pylib/constants/__init__.py |
+++ b/build/android/pylib/constants/__init__.py |
@@ -207,6 +207,12 @@ VALID_TEST_TYPES = ['gtest', 'instrumentation', 'junit', 'linker', 'monkey', |
'perf', 'python', 'uirobot'] |
VALID_DEVICE_TYPES = ['Android', 'iOS'] |
+# Whether CHROMIUM_OUT_DIR or CHROMIUM_OUTPUT_DIR must be set when calling |
+# GetOutDirectory(). Scripts that are called directly by devs are encouraged to |
+# enable this in order to eliminate confusion by having the wrong output |
+# directory used (http://crbug.com/573345) |
+require_explicit_output_dir = False |
+ |
def GetBuildType(): |
try: |
@@ -235,12 +241,25 @@ def GetOutDirectory(build_type=None): |
build_type: Build type, generally 'Debug' or 'Release'. Defaults to the |
globally set build type environment variable BUILDTYPE. |
""" |
- if 'CHROMIUM_OUTPUT_DIR' in os.environ: |
+ output_dir = os.environ.get('CHROMIUM_OUTPUT_DIR') |
+ out_dir = os.environ.get('CHROMIUM_OUT_DIR') |
+ if not output_dir and not out_dir: |
+ # If CWD is an output directory, then assume it's the desired one. |
+ if os.path.exists('build.ninja'): |
+ output_dir = os.getcwd() |
+ SetOutputDirectory(output_dir) |
+ |
+ if output_dir: |
return os.path.abspath(os.path.join( |
DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUTPUT_DIR'))) |
- return os.path.abspath(os.path.join( |
- DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUT_DIR', 'out'), |
+ if not out_dir: |
+ if require_explicit_output_dir: |
+ raise EnvironmentError('Neither CHROMIUM_OUTPUT_DIR nor CHROMIUM_OUT_DIR ' |
+ 'has been set') |
+ out_dir = 'out' |
+ |
+ return os.path.abspath(os.path.join(DIR_SOURCE_ROOT, out_dir, |
GetBuildType() if build_type is None else build_type)) |