diff options
author | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-16 18:28:24 +0000 |
---|---|---|
committer | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-16 18:28:24 +0000 |
commit | 573e8ba41c0454e696394a9434bb48a066f10570 (patch) | |
tree | 674b63b459eda9f09f95cb35d7e1994b6c9c1e2f /gyp | |
parent | dddf6f6363c39d7bd9bfd15a273f717b34e461b4 (diff) |
Add os_posix gyp variable, nesting variables dicts as needed to do so.
Review URL: https://codereview.appspot.com/5845050
git-svn-id: http://skia.googlecode.com/svn/trunk@3418 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gyp')
-rw-r--r-- | gyp/common.gypi | 16 | ||||
-rw-r--r-- | gyp/common_variables.gypi | 80 |
2 files changed, 84 insertions, 12 deletions
diff --git a/gyp/common.gypi b/gyp/common.gypi index aa6e2769bc..ad684c2629 100644 --- a/gyp/common.gypi +++ b/gyp/common.gypi @@ -6,17 +6,9 @@ # This file is automatically included by gyp_skia when building any target. { - # Define all variables, allowing for override in GYP_DEFINES. - # - # One such variable is 'skia_os', which we use instead of 'OS' throughout - # our gyp files. We set it automatically based on 'OS', but allow the - # user to override it via GYP_DEFINES if they like. - 'variables': { - 'skia_scalar%': 'float', - 'skia_os%': '<(OS)', - 'skia_mesa%': 0, - 'skia_target_arch%': 'x86', - }, + 'includes': [ + 'common_variables.gypi', + ], 'target_defaults': { @@ -32,7 +24,7 @@ ], }, 'includes': [ - 'common_conditions.gypi' + 'common_conditions.gypi', ], 'conditions': [ [ 'skia_scalar == "float"', diff --git a/gyp/common_variables.gypi b/gyp/common_variables.gypi new file mode 100644 index 0000000000..eb58de0c88 --- /dev/null +++ b/gyp/common_variables.gypi @@ -0,0 +1,80 @@ +# Copyright 2012 The Android Open Source Project +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + # Get ready for the ugly... + # + # - We have to nest our variables dictionaries multiple levels deep, so that + # this and other gyp files can rely on previously-set variable values in + # their 'variables': { 'conditions': [] } clauses. + # + # Example 1: + # Within this file, we use the value of variable 'skia_os' to set the + # value of variable 'os_posix', so 'skia_os' must be defined within a + # "more inner" (enclosed) scope than 'os_posix'. + # + # Example 2: + # http://src.chromium.org/viewvc/chrome/trunk/src/third_party/libjpeg/libjpeg.gyp?revision=102306 , + # which we currently import into our build, uses the value of 'os_posix' + # within the 'conditions' list in its 'variables' dict. + # In order for that to work, it needs the value of 'os_posix' to have been + # set within a "more inner" (enclosed) scope than its own 'variables' dict. + # + # - On the other hand, key/value pairs of a given 'variable' dict are only + # inherited by: + # 1. directly enclosing 'variable' dicts, and + # 2. "sibling" 'variable' dicts (which, I guess, are combined into a single + # 'variable' dict during gyp processing) + # and NOT inherited by "uncles" (siblings of directly enclosing 'variable' + # dicts), so we have to re-define every variable at every enclosure level + # within our ridiculous matryoshka doll of 'variable' dicts. That's why + # we have variable definitions like this: 'skia_os%': '<(skia_os)', + # + # See http://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi?revision=127004 , + # which deals with these same constraints in a similar manner. + # + 'variables': { # level 1 + 'variables': { # level 2 + + # Variables needed by conditions list within the level-2 variables dict. + 'variables': { # level 3 + # We use 'skia_os' instead of 'OS' throughout our gyp files, to allow + # for cross-compilation (e.g. building for either MacOS or iOS on Mac). + # We set it automatically based on 'OS' (the host OS), but allow the + # user to override it via GYP_DEFINES if they like. + 'skia_os%': '<(OS)', + }, + + # Re-define all variables defined within the level-3 'variables' dict, + # so that siblings of the level-2 'variables' dict can see them. + 'skia_os%': '<(skia_os)', + + 'conditions': [ + ['skia_os == "win"', { + 'os_posix%': 0, + }, { + 'os_posix%': 1, + }], + ], + + 'skia_scalar%': 'float', + 'skia_mesa%': 0, + 'skia_target_arch%': 'x86', + }, + + # Re-define all variables defined within the level-2 'variables' dict, + # so that siblings of the level-1 'variables' dict can see them. + 'skia_os%': '<(skia_os)', + 'os_posix%': '<(os_posix)', + 'skia_scalar%': '<(skia_scalar)', + 'skia_mesa%': '<(skia_mesa)', + 'skia_target_arch%': '<(skia_target_arch)', + }, +} +# Local Variables: +# tab-width:2 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=2 shiftwidth=2: |