diff options
author | torne@chromium.org <torne@chromium.org> | 2014-09-12 16:06:22 +0000 |
---|---|---|
committer | torne@chromium.org <torne@chromium.org> | 2014-09-12 16:06:22 +0000 |
commit | 46282cedf40ff7fe803be4af357b9d59050f02e4 (patch) | |
tree | e46cb69f1426df33ce5f73de201110eb991edb9c | |
parent | 911f177ec4cedf9875ea79d9906ce474c43ea5e6 (diff) | |
download | gyp-46282cedf40ff7fe803be4af357b9d59050f02e4.tar.gz |
android: Add a way to override build system variables.
Add a key 'aosp_build_settings' which a target can use to set Android
build system variables in the generated makefile, for edge cases not
directly supported by gyp. aosp_build_settings is a dictionary which
maps variable names to values (values may be integers, strings or lists;
all values will be quoted appropriately for make and lists will be
converted to whitespace-separated form).
BUG=
R=primiano@chromium.org, thakis@chromium.org
Review URL: https://codereview.chromium.org/565743004
git-svn-id: http://gyp.googlecode.com/svn/trunk@1977 78cadc50-ecff-11dd-a971-7dbc132099af
-rw-r--r-- | pylib/gyp/generator/android.py | 12 | ||||
-rwxr-xr-x | test/android/gyptest-settings-list.py | 24 | ||||
-rwxr-xr-x | test/android/gyptest-settings.py | 24 | ||||
-rw-r--r-- | test/android/settings-list.gyp | 18 | ||||
-rw-r--r-- | test/android/settings.gyp | 18 |
5 files changed, 96 insertions, 0 deletions
diff --git a/pylib/gyp/generator/android.py b/pylib/gyp/generator/android.py index 9dcbb4fd..5afeb534 100644 --- a/pylib/gyp/generator/android.py +++ b/pylib/gyp/generator/android.py @@ -50,6 +50,8 @@ generator_supports_multiple_toolsets = True generator_additional_non_configuration_keys = [ # Boolean to declare that this target does not want its name mangled. 'android_unmangled_name', + # Map of android build system variables to set. + 'aosp_build_settings', ] generator_additional_path_sections = [] generator_extra_sources_for_rules = [] @@ -829,6 +831,16 @@ class AndroidMkWriter(object): if self.type != 'none': self.WriteTargetFlags(spec, configs, link_deps) + settings = spec.get('aosp_build_settings', {}) + if settings: + self.WriteLn('### Set directly by aosp_build_settings.') + for k, v in settings.iteritems(): + if isinstance(v, list): + self.WriteList(v, k) + else: + self.WriteLn('%s := %s' % (k, make.QuoteIfNecessary(v))) + self.WriteLn('') + # Add to the set of targets which represent the gyp 'all' target. We use the # name 'gyp_all_modules' as the Android build system doesn't allow the use # of the Make target 'all' and because 'all_modules' is the equivalent of diff --git a/test/android/gyptest-settings-list.py b/test/android/gyptest-settings-list.py new file mode 100755 index 00000000..5850d47a --- /dev/null +++ b/test/android/gyptest-settings-list.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +# Copyright (c) 2014 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Verifies that it's possible to set Android build system settings using the +aosp_build_settings key, with list values. +""" + +import TestGyp + +test = TestGyp.TestGyp(formats=['android']) + +test.run_gyp('settings-list.gyp') + +test.build('settings-list.gyp', 'hello') + +test.run_built_executable('hello.foo', stdout="Hello, world!\n") + +test.up_to_date('settings-list.gyp', test.DEFAULT) + +test.pass_test() diff --git a/test/android/gyptest-settings.py b/test/android/gyptest-settings.py new file mode 100755 index 00000000..f4e89d1b --- /dev/null +++ b/test/android/gyptest-settings.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +# Copyright (c) 2014 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Verifies that it's possible to set Android build system settings using the +aosp_build_settings key. +""" + +import TestGyp + +test = TestGyp.TestGyp(formats=['android']) + +test.run_gyp('settings.gyp') + +test.build('settings.gyp', 'hello') + +test.run_built_executable('hello.foo', stdout="Hello, world!\n") + +test.up_to_date('settings.gyp', test.DEFAULT) + +test.pass_test() diff --git a/test/android/settings-list.gyp b/test/android/settings-list.gyp new file mode 100644 index 00000000..b392ce2b --- /dev/null +++ b/test/android/settings-list.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2014 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'targets': [ + { + 'target_name': 'hello', + 'type': 'executable', + 'sources': [ + 'hello.c', + ], + 'aosp_build_settings': { + 'LOCAL_MODULE_SUFFIX': ['.foo'], + } + }, + ], +} diff --git a/test/android/settings.gyp b/test/android/settings.gyp new file mode 100644 index 00000000..2f8ce7f5 --- /dev/null +++ b/test/android/settings.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2014 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'targets': [ + { + 'target_name': 'hello', + 'type': 'executable', + 'sources': [ + 'hello.c', + ], + 'aosp_build_settings': { + 'LOCAL_MODULE_SUFFIX': '.foo', + } + }, + ], +} |