| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 # This file helps gyp_chromium and landmines correctly set up the gyp | 5 # This file helps gyp_chromium and landmines correctly set up the gyp |
| 6 # environment from chromium.gyp_env on disk | 6 # environment from chromium.gyp_env on disk |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 | 9 |
| 10 SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) | 10 SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) |
| 11 CHROME_SRC = os.path.dirname(SCRIPT_DIR) | 11 CHROME_SRC = os.path.dirname(SCRIPT_DIR) |
| 12 | 12 |
| 13 | 13 |
| 14 def apply_gyp_environment_from_file(file_path): | 14 def apply_gyp_environment_from_file(file_path): |
| 15 """Reads in a *.gyp_env file and applies the valid keys to os.environ.""" | 15 """Reads in a *.gyp_env file and applies the valid keys to os.environ.""" |
| 16 if not os.path.exists(file_path): | 16 if not os.path.exists(file_path): |
| 17 return | 17 return |
| 18 with open(file_path, 'rU') as f: | 18 with open(file_path, 'rU') as f: |
| 19 file_contents = f.read() | 19 file_contents = f.read() |
| 20 try: | 20 try: |
| 21 file_data = eval(file_contents, {'__builtins__': None}, None) | 21 file_data = eval(file_contents, {'__builtins__': None}, None) |
| 22 except SyntaxError, e: | 22 except SyntaxError, e: |
| 23 e.filename = os.path.abspath(file_path) | 23 e.filename = os.path.abspath(file_path) |
| 24 raise | 24 raise |
| 25 supported_vars = ( | 25 supported_vars = ( |
| 26 'CC', | 26 'CC', |
| 27 'CC_wrapper', | 27 'CC_wrapper', |
| 28 'CC.host_wrapper', |
| 28 'CHROMIUM_GYP_FILE', | 29 'CHROMIUM_GYP_FILE', |
| 29 'CHROMIUM_GYP_SYNTAX_CHECK', | 30 'CHROMIUM_GYP_SYNTAX_CHECK', |
| 30 'CXX', | 31 'CXX', |
| 31 'CXX_wrapper', | 32 'CXX_wrapper', |
| 33 'CXX.host_wrapper', |
| 32 'GYP_DEFINES', | 34 'GYP_DEFINES', |
| 33 'GYP_GENERATOR_FLAGS', | 35 'GYP_GENERATOR_FLAGS', |
| 34 'GYP_CROSSCOMPILE', | 36 'GYP_CROSSCOMPILE', |
| 35 'GYP_GENERATOR_OUTPUT', | 37 'GYP_GENERATOR_OUTPUT', |
| 36 'GYP_GENERATORS', | 38 'GYP_GENERATORS', |
| 37 'GYP_INCLUDE_FIRST', | 39 'GYP_INCLUDE_FIRST', |
| 38 'GYP_INCLUDE_LAST', | 40 'GYP_INCLUDE_LAST', |
| 39 'GYP_MSVS_VERSION', | 41 'GYP_MSVS_VERSION', |
| 40 ) | 42 ) |
| 41 for var in supported_vars: | 43 for var in supported_vars: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 57 os.environ[var] = result | 59 os.environ[var] = result |
| 58 else: | 60 else: |
| 59 os.environ[var] = file_val | 61 os.environ[var] = file_val |
| 60 | 62 |
| 61 | 63 |
| 62 def apply_chromium_gyp_env(): | 64 def apply_chromium_gyp_env(): |
| 63 if 'SKIP_CHROMIUM_GYP_ENV' not in os.environ: | 65 if 'SKIP_CHROMIUM_GYP_ENV' not in os.environ: |
| 64 # Update the environment based on chromium.gyp_env | 66 # Update the environment based on chromium.gyp_env |
| 65 path = os.path.join(os.path.dirname(CHROME_SRC), 'chromium.gyp_env') | 67 path = os.path.join(os.path.dirname(CHROME_SRC), 'chromium.gyp_env') |
| 66 apply_gyp_environment_from_file(path) | 68 apply_gyp_environment_from_file(path) |
| OLD | NEW |