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

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

Issue 6912005: make: remove hacks used for shared-object builds (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: '' Created 9 years, 7 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 # Shared-object link (for generating .so). 210 # Shared-object link (for generating .so).
211 # Set SONAME to the library filename so our binaries don't reference the local, 211 # - Set SONAME to the library filename so our binaries don't reference
212 # absolute paths used on the link command-line. 212 # the local, absolute paths used on the link command-line.
213 # TODO: perhaps this can share with the LINK command above? 213 # - Use --whole-archive so that the .a files we combine end up in the public
214 # API of the shared object. (Note that --whole-archive is incompatible with
215 # the --start-group used in normal linking.)
214 quiet_cmd_solink = SOLINK($(TOOLSET)) $@ 216 quiet_cmd_solink = SOLINK($(TOOLSET)) $@
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) 217 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)
Michael Moss 2011/05/02 22:39:28 Is --whole-archive advisable for all types of shar
216 """ 218 """
217 r""" 219 r"""
218 # Define an escape_quotes function to escape single quotes. 220 # Define an escape_quotes function to escape single quotes.
219 # This allows us to handle quotes properly as long as we always use 221 # This allows us to handle quotes properly as long as we always use
220 # use single quotes and escape_quotes. 222 # use single quotes and escape_quotes.
221 escape_quotes = $(subst ','\'',$(1)) 223 escape_quotes = $(subst ','\'',$(1))
222 # This comment is here just to include a ' to unconfuse syntax highlighting. 224 # This comment is here just to include a ' to unconfuse syntax highlighting.
223 # Define an escape_vars function to escape '$' variable syntax. 225 # Define an escape_vars function to escape '$' variable syntax.
224 # This allows us to read/write command lines with shell variables (e.g. 226 # This allows us to read/write command lines with shell variables (e.g.
225 # $LD_LIBRARY_PATH), without triggering make substitution. 227 # $LD_LIBRARY_PATH), without triggering make substitution.
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 """Convert a path to its source directory form.""" 490 """Convert a path to its source directory form."""
489 if '$(' in path: 491 if '$(' in path:
490 return path 492 return path
491 if os.path.isabs(path): 493 if os.path.isabs(path):
492 return path 494 return path
493 return srcdir_prefix + path 495 return srcdir_prefix + path
494 496
495 497
496 # Map from qualified target to path to output. 498 # Map from qualified target to path to output.
497 target_outputs = {} 499 target_outputs = {}
498 # Map from qualified target to a list of all linker dependencies, 500 # Map from qualified target to a list of linkable outputs. A subset
499 # transitively expanded. 501 # of target_outputs. E.g. when mybinary depends on liba, we want to
500 # Used in building shared-library-based executables. 502 # include liba in the linker line; when otherbinary depends on
503 # mybinary, we just want to build mybinary first.
501 target_link_deps = {} 504 target_link_deps = {}
502 505
503 506
504 class MakefileWriter: 507 class MakefileWriter:
505 """MakefileWriter packages up the writing of one target-specific foobar.mk. 508 """MakefileWriter packages up the writing of one target-specific foobar.mk.
506 509
507 Its only real entry point is Write(), and is mostly used for namespacing. 510 Its only real entry point is Write(), and is mostly used for namespacing.
508 """ 511 """
509 512
510 def __init__(self): 513 def __init__(self):
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 self.WriteLn('# End of this set of suffix rules') 597 self.WriteLn('# End of this set of suffix rules')
595 598
596 599
597 self.WriteTarget(spec, configs, deps, 600 self.WriteTarget(spec, configs, deps,
598 extra_link_deps + link_deps, extra_outputs, part_of_all) 601 extra_link_deps + link_deps, extra_outputs, part_of_all)
599 602
600 # Update global list of target outputs, used in dependency tracking. 603 # Update global list of target outputs, used in dependency tracking.
601 target_outputs[qualified_target] = install_path 604 target_outputs[qualified_target] = install_path
602 605
603 # Update global list of link dependencies. 606 # Update global list of link dependencies.
604 if self.type == 'static_library': 607 if self.type in ('static_library', 'shared_library'):
605 target_link_deps[qualified_target] = [self.output] 608 target_link_deps[qualified_target] = [self.output]
606 elif self.type == 'shared_library':
607 # Anyone that uses us transitively depend on all of our link
608 # dependencies.
609 target_link_deps[qualified_target] = [self.output] + link_deps
610 609
611 self.fp.close() 610 self.fp.close()
612 611
613 612
614 def WriteSubMake(self, output_filename, makefile_path, targets, build_dir): 613 def WriteSubMake(self, output_filename, makefile_path, targets, build_dir):
615 """Write a "sub-project" Makefile. 614 """Write a "sub-project" Makefile.
616 615
617 This is a small, wrapper Makefile that calls the top-level Makefile to build 616 This is a small, wrapper Makefile that calls the top-level Makefile to build
618 the targets from a single gyp file (i.e. a sub-project). 617 the targets from a single gyp file (i.e. a sub-project).
619 618
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 # Add a check to make sure we tried to process all the .d files. 1424 # Add a check to make sure we tried to process all the .d files.
1426 all_deps += """ 1425 all_deps += """
1427 ifneq ($(word %(last)d,$(d_files)),) 1426 ifneq ($(word %(last)d,$(d_files)),)
1428 $(error Found unprocessed dependency files (gyp didn't generate enough rules !)) 1427 $(error Found unprocessed dependency files (gyp didn't generate enough rules !))
1429 endif 1428 endif
1430 """ % { 'last': ((num_outputs / 1000) + 1) * 1000 + 1 } 1429 """ % { 'last': ((num_outputs / 1000) + 1) * 1000 + 1 }
1431 1430
1432 root_makefile.write(SHARED_FOOTER % { 'generate_all_deps': all_deps }) 1431 root_makefile.write(SHARED_FOOTER % { 'generate_all_deps': all_deps })
1433 1432
1434 root_makefile.close() 1433 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