1*635a8641SAndroid Build Coastguard Worker# Copyright 2014 The Chromium Authors. All rights reserved. 2*635a8641SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be 3*635a8641SAndroid Build Coastguard Worker# found in the LICENSE file. 4*635a8641SAndroid Build Coastguard Worker 5*635a8641SAndroid Build Coastguard Worker""" 6*635a8641SAndroid Build Coastguard WorkerSets up various automatic gyp environment variables. These are used by 7*635a8641SAndroid Build Coastguard Workergyp_chromium and landmines.py which run at different stages of runhooks. To 8*635a8641SAndroid Build Coastguard Workermake sure settings are consistent between them, all setup should happen here. 9*635a8641SAndroid Build Coastguard Worker""" 10*635a8641SAndroid Build Coastguard Worker 11*635a8641SAndroid Build Coastguard Workerimport gyp_helper 12*635a8641SAndroid Build Coastguard Workerimport os 13*635a8641SAndroid Build Coastguard Workerimport sys 14*635a8641SAndroid Build Coastguard Workerimport vs_toolchain 15*635a8641SAndroid Build Coastguard Worker 16*635a8641SAndroid Build Coastguard Workerdef SetEnvironment(): 17*635a8641SAndroid Build Coastguard Worker """Sets defaults for GYP_* variables.""" 18*635a8641SAndroid Build Coastguard Worker gyp_helper.apply_chromium_gyp_env() 19*635a8641SAndroid Build Coastguard Worker 20*635a8641SAndroid Build Coastguard Worker # Default to ninja on linux and windows, but only if no generator has 21*635a8641SAndroid Build Coastguard Worker # explicitly been set. 22*635a8641SAndroid Build Coastguard Worker # Also default to ninja on mac, but only when not building chrome/ios. 23*635a8641SAndroid Build Coastguard Worker # . -f / --format has precedence over the env var, no need to check for it 24*635a8641SAndroid Build Coastguard Worker # . set the env var only if it hasn't been set yet 25*635a8641SAndroid Build Coastguard Worker # . chromium.gyp_env has been applied to os.environ at this point already 26*635a8641SAndroid Build Coastguard Worker if sys.platform.startswith(('linux', 'win', 'freebsd', 'darwin')) and \ 27*635a8641SAndroid Build Coastguard Worker not os.environ.get('GYP_GENERATORS'): 28*635a8641SAndroid Build Coastguard Worker os.environ['GYP_GENERATORS'] = 'ninja' 29*635a8641SAndroid Build Coastguard Worker 30*635a8641SAndroid Build Coastguard Worker vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() 31