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

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

Issue 7085012: Revert r928 and r918. (Closed) Base URL: https://gyp.googlecode.com/svn/trunk
Patch Set: Created 9 years, 6 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2011 Google Inc. All rights reserved. 3 # Copyright (c) 2011 Google Inc. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # Notes: 7 # Notes:
8 # 8 #
9 # This is all roughly based on the Makefile system used by the Linux 9 # This is all roughly based on the Makefile system used by the Linux
10 # kernel, but is a non-recursive make -- we put the entire dependency 10 # kernel, but is a non-recursive make -- we put the entire dependency
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 quiet_cmd_copy = COPY $@ 200 quiet_cmd_copy = COPY $@
201 # send stderr to /dev/null to ignore messages when linking directories. 201 # send stderr to /dev/null to ignore messages when linking directories.
202 cmd_copy = ln -f $< $@ 2>/dev/null || cp -af $< $@ 202 cmd_copy = ln -f $< $@ 2>/dev/null || cp -af $< $@
203 203
204 # Due to circular dependencies between libraries :(, we wrap the 204 # Due to circular dependencies between libraries :(, we wrap the
205 # special "figure out circular dependencies" flags around the entire 205 # special "figure out circular dependencies" flags around the entire
206 # input list during linking. 206 # input list during linking.
207 quiet_cmd_link = LINK($(TOOLSET)) $@ 207 quiet_cmd_link = LINK($(TOOLSET)) $@
208 cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--s tart-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) 208 cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--s tart-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS)
209 209
210 # We support two kinds of shared objects (.so): 210 # Shared-object link (for generating .so).
211 # 1) shared_library, which is just bundling together many dependent libraries 211 # Set SONAME to the library filename so our binaries don't reference the local,
212 # into a link line. 212 # absolute paths used on the link command-line.
213 # 2) loadable_module, which is generating a module intended for dlopen(). 213 # TODO: perhaps this can share with the LINK command above?
214 #
215 # They differ only slightly:
216 # In the former case, we want to package all dependent code into the .so.
217 # In the latter case, we want to package just the API exposed by the
218 # outermost module.
219 # This means shared_library uses --whole-archive, while loadable_module doesn't.
220 # (Note that --whole-archive is incompatible with the --start-group used in
221 # normal linking.)
222
223 # Other shared-object link notes:
224 # - Set SONAME to the library filename so our binaries don't reference
225 # the local, absolute paths used on the link command-line.
226 quiet_cmd_solink = SOLINK($(TOOLSET)) $@ 214 quiet_cmd_solink = SOLINK($(TOOLSET)) $@
227 cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl ,-soname=$(@F) -o $@ -Wl,--whole-archive $(filter-out FORCE_DO_CMD, $^) -Wl,--no -whole-archive $(LIBS) 215 cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl ,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end- group $(LIBS)
228
229 quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
230 cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSE T)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl ,--end-group $(LIBS)
231 """ 216 """
232
233 r""" 217 r"""
234 # Define an escape_quotes function to escape single quotes. 218 # Define an escape_quotes function to escape single quotes.
235 # This allows us to handle quotes properly as long as we always use 219 # This allows us to handle quotes properly as long as we always use
236 # use single quotes and escape_quotes. 220 # use single quotes and escape_quotes.
237 escape_quotes = $(subst ','\'',$(1)) 221 escape_quotes = $(subst ','\'',$(1))
238 # This comment is here just to include a ' to unconfuse syntax highlighting. 222 # This comment is here just to include a ' to unconfuse syntax highlighting.
239 # Define an escape_vars function to escape '$' variable syntax. 223 # Define an escape_vars function to escape '$' variable syntax.
240 # This allows us to read/write command lines with shell variables (e.g. 224 # This allows us to read/write command lines with shell variables (e.g.
241 # $LD_LIBRARY_PATH), without triggering make substitution. 225 # $LD_LIBRARY_PATH), without triggering make substitution.
242 escape_vars = $(subst $$,$$$$,$(1)) 226 escape_vars = $(subst $$,$$$$,$(1))
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 """Convert a path to its source directory form.""" 488 """Convert a path to its source directory form."""
505 if '$(' in path: 489 if '$(' in path:
506 return path 490 return path
507 if os.path.isabs(path): 491 if os.path.isabs(path):
508 return path 492 return path
509 return srcdir_prefix + path 493 return srcdir_prefix + path
510 494
511 495
512 # Map from qualified target to path to output. 496 # Map from qualified target to path to output.
513 target_outputs = {} 497 target_outputs = {}
514 # Map from qualified target to a list of linkable outputs. A subset 498 # Map from qualified target to a list of all linker dependencies,
515 # of target_outputs. E.g. when mybinary depends on liba, we want to 499 # transitively expanded.
516 # include liba in the linker line; when otherbinary depends on 500 # Used in building shared-library-based executables.
517 # mybinary, we just want to build mybinary first.
518 target_link_deps = {} 501 target_link_deps = {}
519 502
520 503
521 class MakefileWriter: 504 class MakefileWriter:
522 """MakefileWriter packages up the writing of one target-specific foobar.mk. 505 """MakefileWriter packages up the writing of one target-specific foobar.mk.
523 506
524 Its only real entry point is Write(), and is mostly used for namespacing. 507 Its only real entry point is Write(), and is mostly used for namespacing.
525 """ 508 """
526 509
527 def __init__(self, generator_flags): 510 def __init__(self, generator_flags):
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 self.WriteLn('# End of this set of suffix rules') 595 self.WriteLn('# End of this set of suffix rules')
613 596
614 597
615 self.WriteTarget(spec, configs, deps, 598 self.WriteTarget(spec, configs, deps,
616 extra_link_deps + link_deps, extra_outputs, part_of_all) 599 extra_link_deps + link_deps, extra_outputs, part_of_all)
617 600
618 # Update global list of target outputs, used in dependency tracking. 601 # Update global list of target outputs, used in dependency tracking.
619 target_outputs[qualified_target] = install_path 602 target_outputs[qualified_target] = install_path
620 603
621 # Update global list of link dependencies. 604 # Update global list of link dependencies.
622 if self.type in ('static_library', 'shared_library'): 605 if self.type == 'static_library':
623 target_link_deps[qualified_target] = [self.output] 606 target_link_deps[qualified_target] = [self.output]
607 elif self.type == 'shared_library':
608 # Anyone that uses us transitively depend on all of our link
609 # dependencies.
610 target_link_deps[qualified_target] = [self.output] + link_deps
624 611
625 # Currently any versions have the same effect, but in future the behavior 612 # Currently any versions have the same effect, but in future the behavior
626 # could be different. 613 # could be different.
627 if self.generator_flags.get('android_ndk_version', None): 614 if self.generator_flags.get('android_ndk_version', None):
628 self.WriteAndroidNdkModuleRule(self.target, all_sources, link_deps) 615 self.WriteAndroidNdkModuleRule(self.target, all_sources, link_deps)
629 616
630 self.fp.close() 617 self.fp.close()
631 618
632 619
633 def WriteSubMake(self, output_filename, makefile_path, targets, build_dir): 620 def WriteSubMake(self, output_filename, makefile_path, targets, build_dir):
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 # Remove duplicate entries 1008 # Remove duplicate entries
1022 libraries = gyp.common.uniquer(libraries) 1009 libraries = gyp.common.uniquer(libraries)
1023 self.WriteList(libraries, 'LIBS') 1010 self.WriteList(libraries, 'LIBS')
1024 self.WriteLn('%s: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))' % self.output) 1011 self.WriteLn('%s: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))' % self.output)
1025 self.WriteLn('%s: LIBS := $(LIBS)' % self.output) 1012 self.WriteLn('%s: LIBS := $(LIBS)' % self.output)
1026 1013
1027 if self.type == 'executable': 1014 if self.type == 'executable':
1028 self.WriteDoCmd([self.output], link_deps, 'link', part_of_all) 1015 self.WriteDoCmd([self.output], link_deps, 'link', part_of_all)
1029 elif self.type == 'static_library': 1016 elif self.type == 'static_library':
1030 self.WriteDoCmd([self.output], link_deps, 'alink', part_of_all) 1017 self.WriteDoCmd([self.output], link_deps, 'alink', part_of_all)
1031 elif self.type == 'shared_library': 1018 elif self.type in ('loadable_module', 'shared_library'):
1032 self.WriteDoCmd([self.output], link_deps, 'solink', part_of_all) 1019 self.WriteDoCmd([self.output], link_deps, 'solink', part_of_all)
1033 elif self.type == 'loadable_module':
1034 self.WriteDoCmd([self.output], link_deps, 'solink_module', part_of_all)
1035 elif self.type == 'none': 1020 elif self.type == 'none':
1036 # Write a stamp line. 1021 # Write a stamp line.
1037 self.WriteDoCmd([self.output], deps, 'touch', part_of_all) 1022 self.WriteDoCmd([self.output], deps, 'touch', part_of_all)
1038 elif self.type == 'settings': 1023 elif self.type == 'settings':
1039 # Only used for passing flags around. 1024 # Only used for passing flags around.
1040 pass 1025 pass
1041 else: 1026 else:
1042 print "WARNING: no output for", self.type, target 1027 print "WARNING: no output for", self.type, target
1043 1028
1044 # Add an alias for each target (if there are any outputs). 1029 # Add an alias for each target (if there are any outputs).
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 # Add a check to make sure we tried to process all the .d files. 1518 # Add a check to make sure we tried to process all the .d files.
1534 all_deps += """ 1519 all_deps += """
1535 ifneq ($(word %(last)d,$(d_files)),) 1520 ifneq ($(word %(last)d,$(d_files)),)
1536 $(error Found unprocessed dependency files (gyp didn't generate enough rules !)) 1521 $(error Found unprocessed dependency files (gyp didn't generate enough rules !))
1537 endif 1522 endif
1538 """ % { 'last': ((num_outputs / 1000) + 1) * 1000 + 1 } 1523 """ % { 'last': ((num_outputs / 1000) + 1) * 1000 + 1 }
1539 1524
1540 root_makefile.write(SHARED_FOOTER % { 'generate_all_deps': all_deps }) 1525 root_makefile.write(SHARED_FOOTER % { 'generate_all_deps': all_deps })
1541 1526
1542 root_makefile.close() 1527 root_makefile.close()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698