ninja/mac: Don't write an empty binary into sourceless bundles.
I fixed this issue once in https://codereview.chromium.org/9121011/ but added
the test in the wrong way so that it's not run automatically, and
https://codereview.chromium.org/9107028 broke that again.
Rename the test from .gyp to .py to make sure the bots run it, so that it
doesn't break again.
BUG=chromium:280718
R=mark@chromium.org
Review URL: https://codereview.chromium.org/23916002
git-svn-id: http://gyp.googlecode.com/svn/trunk@1709 78cadc50-ecff-11dd-a971-7dbc132099af
diff --git a/pylib/gyp/generator/ninja.py b/pylib/gyp/generator/ninja.py
index 4574375..8074136 100644
--- a/pylib/gyp/generator/ninja.py
+++ b/pylib/gyp/generator/ninja.py
@@ -474,15 +474,17 @@
# Write out a link step, if needed.
output = None
+ is_empty_bundle = True
if link_deps or self.target.actions_stamp or actions_depends:
output = self.WriteTarget(spec, config_name, config, link_deps,
self.target.actions_stamp or actions_depends)
if self.is_mac_bundle:
+ is_empty_bundle = not link_deps and not mac_bundle_depends
mac_bundle_depends.append(output)
# Bundle all of the above together, if needed.
if self.is_mac_bundle:
- output = self.WriteMacBundle(spec, mac_bundle_depends)
+ output = self.WriteMacBundle(spec, mac_bundle_depends, is_empty_bundle)
if not output:
return None
@@ -1071,7 +1073,7 @@
return linked_binary
def WriteTarget(self, spec, config_name, config, link_deps, compile_deps):
- if spec['type'] == 'none':
+ if spec['type'] == 'none' or not link_deps:
# TODO(evan): don't call this function for 'none' target types, as
# it doesn't do anything, and we fake out a 'binary' with a stamp file.
self.target.binary = compile_deps
@@ -1117,14 +1119,16 @@
self.target.binary = self.WriteLink(spec, config_name, config, link_deps)
return self.target.binary
- def WriteMacBundle(self, spec, mac_bundle_depends):
+ def WriteMacBundle(self, spec, mac_bundle_depends, is_empty):
assert self.is_mac_bundle
package_framework = spec['type'] in ('shared_library', 'loadable_module')
output = self.ComputeMacBundleOutput()
+ if is_empty:
+ output += '.stamp'
variables = []
self.AppendPostbuildVariable(variables, spec, output, self.target.binary,
is_command_start=not package_framework)
- if package_framework:
+ if package_framework and not is_empty:
variables.append(('version', self.xcode_settings.GetFrameworkVersion()))
self.ninja.build(output, 'package_framework', mac_bundle_depends,
variables=variables)
diff --git a/test/mac/gyptest-sourceless-module.gyp b/test/mac/gyptest-sourceless-module.py
similarity index 100%
rename from test/mac/gyptest-sourceless-module.gyp
rename to test/mac/gyptest-sourceless-module.py