OLD | NEW |
1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 Google Inc. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # Notes: | 5 # Notes: |
6 # | 6 # |
7 # This is all roughly based on the Makefile system used by the Linux | 7 # This is all roughly based on the Makefile system used by the Linux |
8 # kernel, but is a non-recursive make -- we put the entire dependency | 8 # kernel, but is a non-recursive make -- we put the entire dependency |
9 # graph in front of make and let it figure it out. | 9 # graph in front of make and let it figure it out. |
10 # | 10 # |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 return path | 612 return path |
613 if os.path.isabs(path): | 613 if os.path.isabs(path): |
614 return path | 614 return path |
615 return srcdir_prefix + path | 615 return srcdir_prefix + path |
616 | 616 |
617 | 617 |
618 def QuoteSpaces(s, quote=r'\ '): | 618 def QuoteSpaces(s, quote=r'\ '): |
619 return s.replace(' ', quote) | 619 return s.replace(' ', quote) |
620 | 620 |
621 | 621 |
622 def InvertRelativePath(path): | |
623 """Given a relative path like foo/bar, return the inverse relative path: | |
624 the path from the relative path back to the origin dir. | |
625 | |
626 E.g. os.path.normpath(os.path.join(path, InvertRelativePath(path))) | |
627 should always produce the empty string.""" | |
628 | |
629 if not path: | |
630 return path | |
631 # Only need to handle relative paths into subdirectories for now. | |
632 assert '..' not in path, path | |
633 depth = len(path.split(os.path.sep)) | |
634 return os.path.sep.join(['..'] * depth) | |
635 | |
636 | |
637 # Map from qualified target to path to output. | 622 # Map from qualified target to path to output. |
638 target_outputs = {} | 623 target_outputs = {} |
639 # Map from qualified target to any linkable output. A subset | 624 # Map from qualified target to any linkable output. A subset |
640 # of target_outputs. E.g. when mybinary depends on liba, we want to | 625 # of target_outputs. E.g. when mybinary depends on liba, we want to |
641 # include liba in the linker line; when otherbinary depends on | 626 # include liba in the linker line; when otherbinary depends on |
642 # mybinary, we just want to build mybinary first. | 627 # mybinary, we just want to build mybinary first. |
643 target_link_deps = {} | 628 target_link_deps = {} |
644 | 629 |
645 | 630 |
646 class MakefileWriter: | 631 class MakefileWriter: |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 target_postbuilds = {} | 1395 target_postbuilds = {} |
1411 if self.type != 'none': | 1396 if self.type != 'none': |
1412 for configname in sorted(configs.keys()): | 1397 for configname in sorted(configs.keys()): |
1413 config = configs[configname] | 1398 config = configs[configname] |
1414 if self.flavor == 'mac': | 1399 if self.flavor == 'mac': |
1415 ldflags = self.xcode_settings.GetLdflags(configname, | 1400 ldflags = self.xcode_settings.GetLdflags(configname, |
1416 generator_default_variables['PRODUCT_DIR'], | 1401 generator_default_variables['PRODUCT_DIR'], |
1417 lambda p: Sourceify(self.Absolutify(p))) | 1402 lambda p: Sourceify(self.Absolutify(p))) |
1418 | 1403 |
1419 # TARGET_POSTBUILDS_$(BUILDTYPE) is added to postbuilds later on. | 1404 # TARGET_POSTBUILDS_$(BUILDTYPE) is added to postbuilds later on. |
1420 gyp_to_build = InvertRelativePath(self.path) | 1405 gyp_to_build = gyp.common.InvertRelativePath(self.path) |
1421 target_postbuild = self.xcode_settings.GetTargetPostbuilds( | 1406 target_postbuild = self.xcode_settings.GetTargetPostbuilds( |
1422 configname, | 1407 configname, |
1423 QuoteSpaces(os.path.normpath(os.path.join(gyp_to_build, | 1408 QuoteSpaces(os.path.normpath(os.path.join(gyp_to_build, |
1424 self.output))), | 1409 self.output))), |
1425 QuoteSpaces(os.path.normpath(os.path.join(gyp_to_build, | 1410 QuoteSpaces(os.path.normpath(os.path.join(gyp_to_build, |
1426 self.output_binary)))) | 1411 self.output_binary)))) |
1427 if target_postbuild: | 1412 if target_postbuild: |
1428 target_postbuilds[configname] = target_postbuild | 1413 target_postbuilds[configname] = target_postbuild |
1429 else: | 1414 else: |
1430 ldflags = config.get('ldflags', []) | 1415 ldflags = config.get('ldflags', []) |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2144 root_makefile.write("endif\n") | 2129 root_makefile.write("endif\n") |
2145 root_makefile.write('\n') | 2130 root_makefile.write('\n') |
2146 | 2131 |
2147 if (not generator_flags.get('standalone') | 2132 if (not generator_flags.get('standalone') |
2148 and generator_flags.get('auto_regeneration', True)): | 2133 and generator_flags.get('auto_regeneration', True)): |
2149 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files) | 2134 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files) |
2150 | 2135 |
2151 root_makefile.write(SHARED_FOOTER) | 2136 root_makefile.write(SHARED_FOOTER) |
2152 | 2137 |
2153 root_makefile.close() | 2138 root_makefile.close() |
OLD | NEW |