Index: pylib/gyp/generator/make.py |
=================================================================== |
--- pylib/gyp/generator/make.py (revision 1690) |
+++ pylib/gyp/generator/make.py (working copy) |
@@ -867,6 +867,8 @@ |
# makefile like $(TARGET), so hardcode the target. |
command = command.replace('$(TARGET)', self.target) |
cd_action = cd_action.replace('$(TARGET)', self.target) |
+ target_libraries_path = self._TargetLibrariesPath() |
+ ld_library_path = self._LibraryPathVarName() |
# Set LD_LIBRARY_PATH in case the action runs an executable from this |
# build which links to shared libs from this build. |
@@ -874,11 +876,16 @@ |
# libraries, but until everything is made cross-compile safe, also use |
# target libraries. |
# TODO(piman): when everything is cross-compile safe, remove lib.target |
- self.WriteLn('cmd_%s = LD_LIBRARY_PATH=$(builddir)/lib.host:' |
- '$(builddir)/lib.target:$$LD_LIBRARY_PATH; ' |
- 'export LD_LIBRARY_PATH; ' |
- '%s%s' |
- % (name, cd_action, command)) |
+ self.WriteLn( |
+ 'cmd_%(name)s = %(ld_library_path)s=$(builddir)/lib.host:' |
+ '%(target_libraries_path)s:$$%(ld_library_path)s; ' |
+ 'export %(ld_library_path)s; ' |
+ '%(cd_action)s%(command)s' % { |
+ 'name': name, |
+ 'cd_action': cd_action, |
+ 'command': command, |
+ 'target_libraries_path': target_libraries_path, |
+ 'ld_library_path': ld_library_path}) |
self.WriteLn() |
outputs = map(self.Absolutify, outputs) |
# The makefile rules are all relative to the top dir, but the gyp actions |
@@ -1007,6 +1014,8 @@ |
action = action.replace('$(TARGET)', self.target) |
cd_action = cd_action.replace('$(TARGET)', self.target) |
mkdirs = mkdirs.replace('$(TARGET)', self.target) |
+ target_libraries_path = self._TargetLibrariesPath() |
+ ld_library_path = self._LibraryPathVarName() |
# Set LD_LIBRARY_PATH in case the rule runs an executable from this |
# build which links to shared libs from this build. |
@@ -1015,15 +1024,18 @@ |
# target libraries. |
# TODO(piman): when everything is cross-compile safe, remove lib.target |
self.WriteLn( |
- "cmd_%(name)s_%(count)d = LD_LIBRARY_PATH=" |
- "$(builddir)/lib.host:$(builddir)/lib.target:$$LD_LIBRARY_PATH; " |
- "export LD_LIBRARY_PATH; " |
+ "cmd_%(name)s_%(count)d = %(ld_library_path)s=" |
+ "$(builddir)/lib.host:%(target_libraries_path)s:" |
+ "$$%(ld_library_path)s; " |
+ "export %(ld_library_path)s; " |
"%(cd_action)s%(mkdirs)s%(action)s" % { |
'action': action, |
'cd_action': cd_action, |
'count': count, |
'mkdirs': mkdirs, |
'name': name, |
+ 'target_libraries_path': target_libraries_path, |
+ 'ld_library_path': ld_library_path, |
}) |
self.WriteLn( |
'quiet_cmd_%(name)s_%(count)d = RULE %(name)s_%(count)d $@' % { |
@@ -1883,6 +1895,21 @@ |
return '$(builddir)/' + self.alias |
+ def _TargetLibrariesPath(self): |
+ """Returns the path to shared libraries in the "target" toolset.""" |
+ if self.flavor == 'mac': |
+ return '$(builddir)' |
+ else: |
+ return '$(builddir)/lib.target' |
+ |
+ def _LibraryPathVarName(self): |
+ """Returns the name of the environment variables for shared libraries.""" |
+ if self.flavor == 'mac': |
+ return 'DYLD_LIBRARY_PATH' |
+ else: |
+ return 'LD_LIBRARY_PATH' |
+ |
+ |
def WriteAutoRegenerationRule(params, root_makefile, makefile_name, |
build_files): |
"""Write the target to regenerate the Makefile.""" |