Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: pylib/gyp/generator/ninja.py

Issue 9121011: ninja/mac: Don't choke on bundles that have no 'sources'. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: actual test Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mac/gyptest-sourceless-module.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 Google Inc. All rights reserved. 1 # Copyright (c) 2012 Google Inc. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import gyp 5 import gyp
6 import gyp.common 6 import gyp.common
7 import gyp.system_test 7 import gyp.system_test
8 import gyp.xcode_emulation 8 import gyp.xcode_emulation
9 import os.path 9 import os.path
10 import re 10 import re
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 259
260 # If we have actions/rules/copies, we depend directly on those, but 260 # If we have actions/rules/copies, we depend directly on those, but
261 # otherwise we depend on dependent target's actions/rules/copies etc. 261 # otherwise we depend on dependent target's actions/rules/copies etc.
262 # We never need to explicitly depend on previous target's link steps, 262 # We never need to explicitly depend on previous target's link steps,
263 # because no compile ever depends on them. 263 # because no compile ever depends on them.
264 compile_depends = self.WriteCollapsedDependencies('compile_depends', 264 compile_depends = self.WriteCollapsedDependencies('compile_depends',
265 sources_depends or compile_depends) 265 sources_depends or compile_depends)
266 266
267 # Write out the compilation steps, if any. 267 # Write out the compilation steps, if any.
268 link_deps = [] 268 link_deps = []
269 has_binary = True
269 sources = spec.get('sources', []) + extra_sources 270 sources = spec.get('sources', []) + extra_sources
270 if sources: 271 if sources:
271 link_deps = self.WriteSources( 272 link_deps = self.WriteSources(
272 config_name, config, sources, compile_depends, 273 config_name, config, sources, compile_depends,
273 gyp.xcode_emulation.MacPrefixHeader( 274 gyp.xcode_emulation.MacPrefixHeader(
274 self.xcode_settings, self.GypPathToNinja, 275 self.xcode_settings, self.GypPathToNinja,
275 lambda path, lang: self.GypPathToUniqueOutput(path + '-' + lang))) 276 lambda path, lang: self.GypPathToUniqueOutput(path + '-' + lang)))
276 # Some actions/rules output 'sources' that are already object files. 277 # Some actions/rules output 'sources' that are already object files.
277 link_deps += [self.GypPathToNinja(f) for f in sources if f.endswith('.o')] 278 link_deps += [self.GypPathToNinja(f) for f in sources if f.endswith('.o')]
279 else:
280 has_binary = False
278 281
279 # The final output of our target depends on the last output of the 282 # The final output of our target depends on the last output of the
280 # above steps. 283 # above steps.
281 output = output_binary = None 284 output = output_binary = None
282 final_deps = link_deps or sources_depends or actions_depends 285 final_deps = link_deps or sources_depends or actions_depends
283 if final_deps: 286 if final_deps:
284 output, output_binary = self.WriteTarget( 287 output, output_binary = self.WriteTarget(
285 spec, config_name, config, final_deps, mac_bundle_depends, 288 spec, config_name, config, final_deps, mac_bundle_depends,
286 order_only=actions_depends) 289 has_binary, order_only=actions_depends)
287 if self.name != output and self.toolset == 'target': 290 if self.name != output and self.toolset == 'target':
288 # Write a short name to build this target. This benefits both the 291 # Write a short name to build this target. This benefits both the
289 # "build chrome" case as well as the gyp tests, which expect to be 292 # "build chrome" case as well as the gyp tests, which expect to be
290 # able to run actions and build libraries by their short name. 293 # able to run actions and build libraries by their short name.
291 self.ninja.build(self.name, 'phony', output) 294 self.ninja.build(self.name, 'phony', output)
295 else:
296 self.ninja.build(self.name, 'phony', output)
Evan Martin 2012/01/07 21:10:12 Would reusing the above similar line for this case
292 return output, output_binary, compile_depends 297 return output, output_binary, compile_depends
293 298
294 def WriteActionsRulesCopies(self, spec, extra_sources, prebuild, 299 def WriteActionsRulesCopies(self, spec, extra_sources, prebuild,
295 mac_bundle_depends): 300 mac_bundle_depends):
296 """Write out the Actions, Rules, and Copies steps. Return any outputs 301 """Write out the Actions, Rules, and Copies steps. Return any outputs
297 of these steps (or a stamp file if there are lots of outputs).""" 302 of these steps (or a stamp file if there are lots of outputs)."""
298 outputs = [] 303 outputs = []
299 extra_mac_bundle_resources = [] 304 extra_mac_bundle_resources = []
300 305
301 if 'actions' in spec: 306 if 'actions' in spec:
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 'c': 'cflags_pch_c', 571 'c': 'cflags_pch_c',
567 'cc': 'cflags_pch_cc', 572 'cc': 'cflags_pch_cc',
568 'm': 'cflags_pch_objc', 573 'm': 'cflags_pch_objc',
569 'mm': 'cflags_pch_objcc', 574 'mm': 'cflags_pch_objcc',
570 }[lang] 575 }[lang]
571 576
572 cmd = { 'c': 'cc', 'cc': 'cxx', 'm': 'objc', 'mm': 'objcxx', }.get(lang) 577 cmd = { 'c': 'cc', 'cc': 'cxx', 'm': 'objc', 'mm': 'objcxx', }.get(lang)
573 self.ninja.build(gch, cmd, input, variables=[(var_name, lang_flag)]) 578 self.ninja.build(gch, cmd, input, variables=[(var_name, lang_flag)])
574 579
575 def WriteTarget(self, spec, config_name, config, final_deps, 580 def WriteTarget(self, spec, config_name, config, final_deps,
576 mac_bundle_depends, order_only): 581 mac_bundle_depends, has_binary, order_only):
577 if spec['type'] == 'none': 582 if spec['type'] == 'none':
578 # This target doesn't have any explicit final output, but is instead 583 # This target doesn't have any explicit final output, but is instead
579 # used for its effects before the final output (e.g. copies steps). 584 # used for its effects before the final output (e.g. copies steps).
580 # Reuse the existing output if it's easy. 585 # Reuse the existing output if it's easy.
581 if len(final_deps) == 1: 586 if len(final_deps) == 1:
582 return final_deps[0], final_deps[0] 587 return final_deps[0], final_deps[0]
583 # Otherwise, fall through to writing out a stamp file. 588 # Otherwise, fall through to writing out a stamp file.
584 589
585 if self.is_mac_bundle: 590 if self.is_mac_bundle:
586 output = self.ComputeMacBundleOutput(spec) 591 output = self.ComputeMacBundleOutput(spec)
587 output_binary = self.ComputeMacBundleBinaryOutput(spec) 592 output_binary = self.ComputeMacBundleBinaryOutput(spec)
588 mac_bundle_depends.append(output_binary) 593 if has_binary:
594 mac_bundle_depends.append(output_binary)
589 else: 595 else:
590 output = output_binary = self.ComputeOutput(spec) 596 output = output_binary = self.ComputeOutput(spec)
591 597
592 output_uses_linker = spec['type'] in ('executable', 'loadable_module', 598 output_uses_linker = spec['type'] in ('executable', 'loadable_module',
593 'shared_library') 599 'shared_library')
594 600
595 implicit_deps = set() 601 implicit_deps = set()
596 if 'dependencies' in spec: 602 if 'dependencies' in spec:
597 # Two kinds of dependencies: 603 # Two kinds of dependencies:
598 # - Linkable dependencies (like a .a or a .so): add them to the link line. 604 # - Linkable dependencies (like a .a or a .so): add them to the link line.
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 # For bundles, the binary in the bundle is the right answer. 1000 # For bundles, the binary in the bundle is the right answer.
995 target_outputs[qualified_target] = ( 1001 target_outputs[qualified_target] = (
996 output_binary, compile_depends, linkable) 1002 output_binary, compile_depends, linkable)
997 1003
998 # But for all_outputs, the bundle is the interesting bit. 1004 # But for all_outputs, the bundle is the interesting bit.
999 if qualified_target in all_targets: 1005 if qualified_target in all_targets:
1000 all_outputs.add(output) 1006 all_outputs.add(output)
1001 1007
1002 if all_outputs: 1008 if all_outputs:
1003 master_ninja.build('all', 'phony', list(all_outputs)) 1009 master_ninja.build('all', 'phony', list(all_outputs))
OLDNEW
« no previous file with comments | « no previous file | test/mac/gyptest-sourceless-module.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698