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 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1198 extra_mac_bundle_resources += outputs | 1198 extra_mac_bundle_resources += outputs |
1199 | 1199 |
1200 # Write the actual command. | 1200 # Write the actual command. |
1201 command = gyp.common.EncodePOSIXShellList(action['action']) | 1201 command = gyp.common.EncodePOSIXShellList(action['action']) |
1202 if 'message' in action: | 1202 if 'message' in action: |
1203 self.WriteLn('quiet_cmd_%s = ACTION %s $@' % (name, action['message'])) | 1203 self.WriteLn('quiet_cmd_%s = ACTION %s $@' % (name, action['message'])) |
1204 else: | 1204 else: |
1205 self.WriteLn('quiet_cmd_%s = ACTION %s $@' % (name, name)) | 1205 self.WriteLn('quiet_cmd_%s = ACTION %s $@' % (name, name)) |
1206 if len(dirs) > 0: | 1206 if len(dirs) > 0: |
1207 command = 'mkdir -p %s' % ' '.join(dirs) + '; ' + command | 1207 command = 'mkdir -p %s' % ' '.join(dirs) + '; ' + command |
| 1208 |
| 1209 cd_action = 'cd %s; ' % Sourceify(self.path or '.') |
| 1210 |
1208 # Set LD_LIBRARY_PATH in case the action runs an executable from this | 1211 # Set LD_LIBRARY_PATH in case the action runs an executable from this |
1209 # build which links to shared libs from this build. | 1212 # build which links to shared libs from this build. |
1210 if self.path: | |
1211 cd_action = 'cd %s; ' % Sourceify(self.path) | |
1212 else: | |
1213 cd_action = '' | |
1214 # actions run on the host, so they should in theory only use host | 1213 # actions run on the host, so they should in theory only use host |
1215 # libraries, but until everything is made cross-compile safe, also use | 1214 # libraries, but until everything is made cross-compile safe, also use |
1216 # target libraries. | 1215 # target libraries. |
1217 # TODO(piman): when everything is cross-compile safe, remove lib.target | 1216 # TODO(piman): when everything is cross-compile safe, remove lib.target |
1218 self.WriteLn('cmd_%s = export LD_LIBRARY_PATH=$(builddir)/lib.host:' | 1217 self.WriteLn('cmd_%s = export LD_LIBRARY_PATH=$(builddir)/lib.host:' |
1219 '$(builddir)/lib.target:$$LD_LIBRARY_PATH; %s%s' | 1218 '$(builddir)/lib.target:$$LD_LIBRARY_PATH; %s%s' |
1220 % (name, cd_action, command)) | 1219 % (name, cd_action, command)) |
1221 self.WriteLn() | 1220 self.WriteLn() |
1222 outputs = map(self.Absolutify, outputs) | 1221 outputs = map(self.Absolutify, outputs) |
1223 # The makefile rules are all relative to the top dir, but the gyp actions | 1222 # The makefile rules are all relative to the top dir, but the gyp actions |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 assert ' ' not in output, ( | 1308 assert ' ' not in output, ( |
1310 "Spaces in rule filenames not yet supported (%s)" % output) | 1309 "Spaces in rule filenames not yet supported (%s)" % output) |
1311 self.WriteLn('all_deps += %s' % ' '.join(outputs)) | 1310 self.WriteLn('all_deps += %s' % ' '.join(outputs)) |
1312 self._num_outputs += len(outputs) | 1311 self._num_outputs += len(outputs) |
1313 | 1312 |
1314 action = [self.ExpandInputRoot(ac, rule_source_root) | 1313 action = [self.ExpandInputRoot(ac, rule_source_root) |
1315 for ac in rule['action']] | 1314 for ac in rule['action']] |
1316 mkdirs = '' | 1315 mkdirs = '' |
1317 if len(dirs) > 0: | 1316 if len(dirs) > 0: |
1318 mkdirs = 'mkdir -p %s; ' % ' '.join(dirs) | 1317 mkdirs = 'mkdir -p %s; ' % ' '.join(dirs) |
1319 if self.path: | 1318 cd_action = 'cd %s; ' % Sourceify(self.path or '.') |
1320 cd_action = 'cd %s; ' % Sourceify(self.path) | |
1321 else: | |
1322 cd_action = '' | |
1323 # Set LD_LIBRARY_PATH in case the rule runs an executable from this | 1319 # Set LD_LIBRARY_PATH in case the rule runs an executable from this |
1324 # build which links to shared libs from this build. | 1320 # build which links to shared libs from this build. |
1325 # rules run on the host, so they should in theory only use host | 1321 # rules run on the host, so they should in theory only use host |
1326 # libraries, but until everything is made cross-compile safe, also use | 1322 # libraries, but until everything is made cross-compile safe, also use |
1327 # target libraries. | 1323 # target libraries. |
1328 # TODO(piman): when everything is cross-compile safe, remove lib.target | 1324 # TODO(piman): when everything is cross-compile safe, remove lib.target |
1329 self.WriteLn( | 1325 self.WriteLn( |
1330 "cmd_%(name)s_%(count)d = export LD_LIBRARY_PATH=" | 1326 "cmd_%(name)s_%(count)d = export LD_LIBRARY_PATH=" |
1331 "$(builddir)/lib.host:$(builddir)/lib.target:$$LD_LIBRARY_PATH; " | 1327 "$(builddir)/lib.host:$(builddir)/lib.target:$$LD_LIBRARY_PATH; " |
1332 "%(cd_action)s%(mkdirs)s%(action)s" % { | 1328 "%(cd_action)s%(mkdirs)s%(action)s" % { |
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2393 # Add a check to make sure we tried to process all the .d files. | 2389 # Add a check to make sure we tried to process all the .d files. |
2394 all_deps += """ | 2390 all_deps += """ |
2395 ifneq ($(word %(last)d,$(d_files)),) | 2391 ifneq ($(word %(last)d,$(d_files)),) |
2396 $(error Found unprocessed dependency files (gyp didn't generate enough rules
!)) | 2392 $(error Found unprocessed dependency files (gyp didn't generate enough rules
!)) |
2397 endif | 2393 endif |
2398 """ % { 'last': ((num_outputs / 1000) + 1) * 1000 + 1 } | 2394 """ % { 'last': ((num_outputs / 1000) + 1) * 1000 + 1 } |
2399 | 2395 |
2400 root_makefile.write(SHARED_FOOTER % { 'generate_all_deps': all_deps }) | 2396 root_makefile.write(SHARED_FOOTER % { 'generate_all_deps': all_deps }) |
2401 | 2397 |
2402 root_makefile.close() | 2398 root_makefile.close() |
OLD | NEW |