| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """A module to add gyp support to cr.""" | 5 """A module to add gyp support to cr.""" |
| 6 | 6 |
| 7 import cr | 7 import cr |
| 8 import os | 8 import os |
| 9 | 9 |
| 10 GYP_DEFINE_PREFIX = 'GYP_DEF_' | 10 GYP_DEFINE_PREFIX = 'GYP_DEF_' |
| 11 | 11 |
| 12 class GypPrepareOut(cr.PrepareOut): | 12 class GypPrepareOut(cr.PrepareOut): |
| 13 """A prepare action that runs gyp whenever you select an output directory.""" | 13 """A prepare action that runs gyp whenever you select an output directory.""" |
| 14 | 14 |
| 15 ENABLED = cr.Config.From( | 15 ACTIVE = cr.Config.From( |
| 16 GYP_GENERATORS='ninja', | 16 GYP_GENERATORS='ninja', |
| 17 GYP_GENERATOR_FLAGS='output_dir={CR_OUT_BASE} config={CR_BUILDTYPE}', | 17 GYP_GENERATOR_FLAGS='output_dir={CR_OUT_BASE} config={CR_BUILDTYPE}', |
| 18 GYP_DEF_target_arch='{CR_ENVSETUP_ARCH}', | 18 GYP_DEF_target_arch='{CR_ENVSETUP_ARCH}', |
| 19 ) | 19 ) |
| 20 | 20 |
| 21 def UpdateContext(self): | 21 def UpdateContext(self): |
| 22 # Collapse GYP_DEFINES from all GYP_DEF prefixes | 22 # Collapse GYP_DEFINES from all GYP_DEF prefixes |
| 23 gyp_defines = cr.context.Find('GYP_DEFINES') or '' | 23 gyp_defines = cr.context.Find('GYP_DEFINES') or '' |
| 24 for key, value in cr.context.exported.items(): | 24 for key, value in cr.context.exported.items(): |
| 25 if key.startswith(GYP_DEFINE_PREFIX): | 25 if key.startswith(GYP_DEFINE_PREFIX): |
| 26 gyp_defines += ' %s=%s' % (key[len(GYP_DEFINE_PREFIX):], value) | 26 gyp_defines += ' %s=%s' % (key[len(GYP_DEFINE_PREFIX):], value) |
| 27 cr.context['GYP_DEFINES'] = gyp_defines.strip() | 27 cr.context['GYP_DEFINES'] = gyp_defines.strip() |
| 28 if cr.context.verbose >= 1: | 28 if cr.context.verbose >= 1: |
| 29 print cr.context.Substitute('GYP_DEFINES = {GYP_DEFINES}') | 29 print cr.context.Substitute('GYP_DEFINES = {GYP_DEFINES}') |
| 30 | 30 |
| 31 def Prepare(self): | 31 def Prepare(self): |
| 32 if cr.context.verbose >= 1: | 32 if cr.context.verbose >= 1: |
| 33 print cr.context.Substitute('Invoking gyp with {GYP_GENERATOR_FLAGS}') | 33 print cr.context.Substitute('Invoking gyp with {GYP_GENERATOR_FLAGS}') |
| 34 | 34 |
| 35 cr.Host.Execute( | 35 cr.Host.Execute( |
| 36 '{CR_SRC}/build/gyp_chromium', | 36 '{CR_SRC}/build/gyp_chromium', |
| 37 '--depth={CR_SRC}', | 37 '--depth={CR_SRC}', |
| 38 '--check' | 38 '--check' |
| 39 ) | 39 ) |
| OLD | NEW |