Permalink
Browse files

Android backend: allow targets to have unmangled names.

The Android backend mangles gyp target names because the Android build
system requires that they be globally unique. This is fine for most targets,
but for the final build products that are being used by other Android
components it's annoying to refer to long mangled names. Add a
generator-specific flag to denote that a target should have an unmangled
name, which can be set on the targets that are important after verifying
that no existing module in Android has the same name.
Review URL: https://codereview.chromium.org/11088078

git-svn-id: http://gyp.googlecode.com/svn/trunk@1520 78cadc50-ecff-11dd-a971-7dbc132099af
  • Loading branch information...
1 parent 523297f commit 15e31a45b472ac7916febbfc73c05c5daa1cdac8 torne@chromium.org committed Oct 17, 2012
Showing with 18 additions and 4 deletions.
  1. +18 −4 pylib/gyp/generator/android.py
@@ -45,6 +45,15 @@
generator_supports_multiple_toolsets = True
+# Generator-specific gyp specs.
+generator_additional_non_configuration_keys = [
+ # Boolean to declare that this target does not want its name mangled.
+ 'android_unmangled_name',
+]
+generator_additional_path_sections = []
+generator_extra_sources_for_rules = []
+
+
SHARED_FOOTER = """\
# "gyp_all_modules" is a concatenation of the "gyp_all_modules" targets from
# all the included sub-makefiles. This is just here to clarify.
@@ -577,6 +586,10 @@ def ComputeAndroidModule(self, spec):
distinguish gyp-generated module names.
"""
+ if int(spec.get('android_unmangled_name', 0)):
+ assert self.type != 'shared_library' or self.target.startswith('lib')
+ return self.target
+
if self.type == 'shared_library':
# For reasons of convention, the Android build system requires that all
# shared library modules are named 'libfoo' when generating -l flags.
@@ -839,10 +852,11 @@ def WriteTarget(self, spec, configs, deps, link_deps, part_of_all):
# Add an alias from the gyp target name to the Android module name. This
# simplifies manual builds of the target, and is required by the test
# framework.
- self.WriteLn('# Alias gyp target name.')
- self.WriteLn('.PHONY: %s' % self.target)
- self.WriteLn('%s: %s' % (self.target, self.android_module))
- self.WriteLn('')
+ if self.target != self.android_module:
+ self.WriteLn('# Alias gyp target name.')
+ self.WriteLn('.PHONY: %s' % self.target)
+ self.WriteLn('%s: %s' % (self.target, self.android_module))
+ self.WriteLn('')
# Add the command to trigger build of the target type depending
# on the toolset. Ex: BUILD_STATIC_LIBRARY vs. BUILD_HOST_STATIC_LIBRARY

0 comments on commit 15e31a4

Please sign in to comment.