| OLD | NEW |
| 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 Loading... |
| 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 # Shared-object link (for generating .so). | 210 # We support two kinds of shared objects (.so): |
| 211 # 1) shared_library, which is just bundling together many dependent libraries |
| 212 # into a link line. |
| 213 # 2) loadable_module, which is generating a module intended for dlopen(). |
| 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: |
| 211 # - Set SONAME to the library filename so our binaries don't reference | 224 # - Set SONAME to the library filename so our binaries don't reference |
| 212 # the local, absolute paths used on the link command-line. | 225 # the local, absolute paths used on the link command-line. |
| 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.) | |
| 216 quiet_cmd_solink = SOLINK($(TOOLSET)) $@ | 226 quiet_cmd_solink = SOLINK($(TOOLSET)) $@ |
| 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) | 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) |
| 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) |
| 218 """ | 231 """ |
| 232 |
| 219 r""" | 233 r""" |
| 220 # Define an escape_quotes function to escape single quotes. | 234 # Define an escape_quotes function to escape single quotes. |
| 221 # This allows us to handle quotes properly as long as we always use | 235 # This allows us to handle quotes properly as long as we always use |
| 222 # use single quotes and escape_quotes. | 236 # use single quotes and escape_quotes. |
| 223 escape_quotes = $(subst ','\'',$(1)) | 237 escape_quotes = $(subst ','\'',$(1)) |
| 224 # This comment is here just to include a ' to unconfuse syntax highlighting. | 238 # This comment is here just to include a ' to unconfuse syntax highlighting. |
| 225 # Define an escape_vars function to escape '$' variable syntax. | 239 # Define an escape_vars function to escape '$' variable syntax. |
| 226 # This allows us to read/write command lines with shell variables (e.g. | 240 # This allows us to read/write command lines with shell variables (e.g. |
| 227 # $LD_LIBRARY_PATH), without triggering make substitution. | 241 # $LD_LIBRARY_PATH), without triggering make substitution. |
| 228 escape_vars = $(subst $$,$$$$,$(1)) | 242 escape_vars = $(subst $$,$$$$,$(1)) |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 # Remove duplicate entries | 1021 # Remove duplicate entries |
| 1008 libraries = gyp.common.uniquer(libraries) | 1022 libraries = gyp.common.uniquer(libraries) |
| 1009 self.WriteList(libraries, 'LIBS') | 1023 self.WriteList(libraries, 'LIBS') |
| 1010 self.WriteLn('%s: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))' % self.output) | 1024 self.WriteLn('%s: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))' % self.output) |
| 1011 self.WriteLn('%s: LIBS := $(LIBS)' % self.output) | 1025 self.WriteLn('%s: LIBS := $(LIBS)' % self.output) |
| 1012 | 1026 |
| 1013 if self.type == 'executable': | 1027 if self.type == 'executable': |
| 1014 self.WriteDoCmd([self.output], link_deps, 'link', part_of_all) | 1028 self.WriteDoCmd([self.output], link_deps, 'link', part_of_all) |
| 1015 elif self.type == 'static_library': | 1029 elif self.type == 'static_library': |
| 1016 self.WriteDoCmd([self.output], link_deps, 'alink', part_of_all) | 1030 self.WriteDoCmd([self.output], link_deps, 'alink', part_of_all) |
| 1017 elif self.type in ('loadable_module', 'shared_library'): | 1031 elif self.type == 'shared_library': |
| 1018 self.WriteDoCmd([self.output], link_deps, 'solink', part_of_all) | 1032 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) |
| 1019 elif self.type == 'none': | 1035 elif self.type == 'none': |
| 1020 # Write a stamp line. | 1036 # Write a stamp line. |
| 1021 self.WriteDoCmd([self.output], deps, 'touch', part_of_all) | 1037 self.WriteDoCmd([self.output], deps, 'touch', part_of_all) |
| 1022 elif self.type == 'settings': | 1038 elif self.type == 'settings': |
| 1023 # Only used for passing flags around. | 1039 # Only used for passing flags around. |
| 1024 pass | 1040 pass |
| 1025 else: | 1041 else: |
| 1026 print "WARNING: no output for", self.type, target | 1042 print "WARNING: no output for", self.type, target |
| 1027 | 1043 |
| 1028 # Add an alias for each target (if there are any outputs). | 1044 # Add an alias for each target (if there are any outputs). |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 # Add a check to make sure we tried to process all the .d files. | 1533 # Add a check to make sure we tried to process all the .d files. |
| 1518 all_deps += """ | 1534 all_deps += """ |
| 1519 ifneq ($(word %(last)d,$(d_files)),) | 1535 ifneq ($(word %(last)d,$(d_files)),) |
| 1520 $(error Found unprocessed dependency files (gyp didn't generate enough rules
!)) | 1536 $(error Found unprocessed dependency files (gyp didn't generate enough rules
!)) |
| 1521 endif | 1537 endif |
| 1522 """ % { 'last': ((num_outputs / 1000) + 1) * 1000 + 1 } | 1538 """ % { 'last': ((num_outputs / 1000) + 1) * 1000 + 1 } |
| 1523 | 1539 |
| 1524 root_makefile.write(SHARED_FOOTER % { 'generate_all_deps': all_deps }) | 1540 root_makefile.write(SHARED_FOOTER % { 'generate_all_deps': all_deps }) |
| 1525 | 1541 |
| 1526 root_makefile.close() | 1542 root_makefile.close() |
| OLD | NEW |