# Copyright 2013 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.

"""A module to add gyp support to cr."""

import cr
import os

GYP_DEFINE_PREFIX = 'GYP_DEF_'

class GypPrepareOut(cr.PrepareOut):
  """A prepare action that runs gyp whenever you select an output directory."""

  ENABLED = cr.Config.From(
      GYP_GENERATORS='ninja',
      GYP_GENERATOR_FLAGS='output_dir={CR_OUT_BASE} config={CR_BUILDTYPE}',
      GPP_DEF_target_arch='{CR_ENVSETUP_ARCH}',
  )

  def Prepare(self):
    # Collapse GYP_DEFINES from all GYP_DEF prefixes
    gyp_defines = cr.context.Find('GYP_DEFINES') or ''
    for key, value in cr.context.exported.items():
      if key.startswith(GYP_DEFINE_PREFIX):
        gyp_defines += ' %s=%s' % (key[len(GYP_DEFINE_PREFIX):], value)
    cr.context['GYP_DEFINES'] = gyp_defines.strip()

    if cr.context.verbose >= 1:
      print cr.context.Substitute('Invoking gyp with {GYP_GENERATOR_FLAGS}')
      print cr.context.Substitute('GYP_DEFINES = {GYP_DEFINES}')

    cr.Host.Execute(
        '{CR_SRC}/build/gyp_chromium',
        '--depth={CR_SRC}',
        '--check'
    )

# Copyright 2013 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.

"""A module to add gyp support to cr."""

import cr
import os

GYP_DEFINE_PREFIX = 'GYP_DEF_'

class GypPrepareOut(cr.PrepareOut):
  """A prepare action that runs gyp whenever you select an output directory."""

  ENABLED = cr.Config.From(
      GYP_GENERATORS='ninja',
      GYP_GENERATOR_FLAGS='output_dir={CR_OUT_BASE} config={CR_BUILDTYPE}',
      GYP_DEF_target_arch='{CR_ENVSETUP_ARCH}',
  )

  def Prepare(self):
    # Collapse GYP_DEFINES from all GYP_DEF prefixes
    gyp_defines = cr.context.Find('GYP_DEFINES') or ''
    for key, value in cr.context.exported.items():
      if key.startswith(GYP_DEFINE_PREFIX):
        gyp_defines += ' %s=%s' % (key[len(GYP_DEFINE_PREFIX):], value)
    cr.context['GYP_DEFINES'] = gyp_defines.strip()

    if cr.context.verbose >= 1:
      print cr.context.Substitute('Invoking gyp with {GYP_GENERATOR_FLAGS}')
      print cr.context.Substitute('GYP_DEFINES = {GYP_DEFINES}')

    cr.Host.Execute(
        '{CR_SRC}/build/gyp_chromium',
        '--depth={CR_SRC}',
        '--check'
    )

Fix typo GYP_DEF_target_arch v GPP_DEF_target_arch
Fix typo GYP_DEF_target_arch v GPP_DEF_target_arch

BUG=

Review URL: https://codereview.chromium.org/218623005

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@260590 0039d316-1c4b-4281-b951-d872f2087c98
