Imported Upstream version 0.1~svn1729
Jérémy Lal
10 years ago
0 | setup.py | |
1 | gyp | |
2 | LICENSE | |
3 | AUTHORS | |
4 | pylib/gyp/MSVSNew.py | |
5 | pylib/gyp/MSVSProject.py | |
6 | pylib/gyp/MSVSToolFile.py | |
7 | pylib/gyp/MSVSUserFile.py | |
8 | pylib/gyp/MSVSVersion.py | |
9 | pylib/gyp/__init__.py | |
10 | pylib/gyp/common.py | |
11 | pylib/gyp/input.py | |
12 | pylib/gyp/xcodeproj_file.py | |
13 | pylib/gyp/generator/__init__.py | |
14 | pylib/gyp/generator/gypd.py | |
15 | pylib/gyp/generator/gypsh.py | |
16 | pylib/gyp/generator/make.py | |
17 | pylib/gyp/generator/msvs.py | |
18 | pylib/gyp/generator/xcode.py |
14 | 14 | import gyp |
15 | 15 | |
16 | 16 | if __name__ == '__main__': |
17 | sys.exit(gyp.main(sys.argv[1:])) | |
17 | sys.exit(gyp.script_main()) |
82 | 82 | # vcvars32, which it can only find if VS??COMNTOOLS is set, which it |
83 | 83 | # isn't always. |
84 | 84 | if target_arch == 'x86': |
85 | if self.short_name == '2013' and ( | |
86 | os.environ.get('PROCESSOR_ARCHITECTURE') == 'AMD64' or | |
87 | os.environ.get('PROCESSOR_ARCHITEW6432') == 'AMD64'): | |
88 | # VS2013 non-Express has a x64-x86 cross that we want to prefer. | |
89 | return [os.path.normpath( | |
90 | os.path.join(self.path, 'VC/vcvarsall.bat')), 'amd64_x86'] | |
91 | # Otherwise, the standard x86 compiler. | |
85 | 92 | return [os.path.normpath( |
86 | 93 | os.path.join(self.path, 'Common7/Tools/vsvars32.bat'))] |
87 | 94 | else: |
541 | 541 | sys.stderr.write("gyp: %s\n" % e) |
542 | 542 | return 1 |
543 | 543 | |
544 | # NOTE: setuptools generated console_scripts calls function with no arguments | |
545 | def script_main(): | |
546 | return main(sys.argv[1:]) | |
547 | ||
544 | 548 | if __name__ == '__main__': |
545 | sys.exit(main(sys.argv[1:])) | |
549 | sys.exit(script_main()) |
165 | 165 | quiet_cmd_link = LINK($(TOOLSET)) $@ |
166 | 166 | cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) |
167 | 167 | |
168 | # TODO(thakis): Find out and document the difference between shared_library and | |
169 | # loadable_module on mac. | |
170 | 168 | quiet_cmd_solink = SOLINK($(TOOLSET)) $@ |
171 | 169 | cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) |
172 | 170 | |
173 | # TODO(thakis): The solink_module rule is likely wrong. Xcode seems to pass | |
174 | # -bundle -single_module here (for osmesa.so). | |
175 | 171 | quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ |
176 | cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) | |
172 | cmd_solink_module = $(LINK.$(TOOLSET)) -bundle $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) | |
177 | 173 | """ |
178 | 174 | |
179 | 175 | LINK_COMMANDS_ANDROID = """\ |
248 | 244 | all_deps := |
249 | 245 | |
250 | 246 | %(make_global_settings)s |
247 | ||
248 | CC.target ?= %(CC.target)s | |
249 | CFLAGS.target ?= $(CFLAGS) | |
250 | CXX.target ?= %(CXX.target)s | |
251 | CXXFLAGS.target ?= $(CXXFLAGS) | |
252 | LINK.target ?= %(LINK.target)s | |
253 | LDFLAGS.target ?= $(LDFLAGS) | |
254 | AR.target ?= $(AR) | |
251 | 255 | |
252 | 256 | # C++ apps need to be linked with g++. |
253 | 257 | # |
259 | 263 | # |
260 | 264 | # This will allow make to invoke N linker processes as specified in -jN. |
261 | 265 | LINK ?= %(flock)s $(builddir)/linker.lock $(CXX.target) |
262 | ||
263 | CC.target ?= %(CC.target)s | |
264 | CFLAGS.target ?= $(CFLAGS) | |
265 | CXX.target ?= %(CXX.target)s | |
266 | CXXFLAGS.target ?= $(CXXFLAGS) | |
267 | LINK.target ?= %(LINK.target)s | |
268 | LDFLAGS.target ?= $(LDFLAGS) | |
269 | AR.target ?= $(AR) | |
270 | 266 | |
271 | 267 | # TODO(evan): move all cross-compilation logic to gyp-time so we don't need |
272 | 268 | # to replicate this environment fallback in make as well. |
2003 | 1999 | 'CC.target': GetEnvironFallback(('CC_target', 'CC'), '$(CC)'), |
2004 | 2000 | 'AR.target': GetEnvironFallback(('AR_target', 'AR'), '$(AR)'), |
2005 | 2001 | 'CXX.target': GetEnvironFallback(('CXX_target', 'CXX'), '$(CXX)'), |
2006 | 'LINK.target': GetEnvironFallback(('LD_target', 'LD'), '$(LINK)'), | |
2002 | 'LINK.target': GetEnvironFallback(('LINK_target', 'LINK'), '$(LINK)'), | |
2007 | 2003 | 'CC.host': GetEnvironFallback(('CC_host',), 'gcc'), |
2008 | 2004 | 'AR.host': GetEnvironFallback(('AR_host',), 'ar'), |
2009 | 2005 | 'CXX.host': GetEnvironFallback(('CXX_host',), 'g++'), |
2010 | 'LINK.host': GetEnvironFallback(('LD_host',), 'g++'), | |
2006 | 'LINK.host': GetEnvironFallback(('LINK_host',), '$(CXX.host)'), | |
2011 | 2007 | }) |
2012 | 2008 | |
2013 | 2009 | build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) |
14 | 14 | import gyp.msvs_emulation |
15 | 15 | import gyp.MSVSUtil as MSVSUtil |
16 | 16 | import gyp.xcode_emulation |
17 | from cStringIO import StringIO | |
17 | 18 | |
18 | 19 | from gyp.common import GetEnvironFallback |
19 | 20 | import gyp.ninja_syntax as ninja_syntax |
209 | 210 | class NinjaWriter: |
210 | 211 | def __init__(self, qualified_target, target_outputs, base_dir, build_dir, |
211 | 212 | output_file, toplevel_build, output_file_name, flavor, |
212 | toplevel_dir=None): | |
213 | deps_file=None, toplevel_dir=None): | |
213 | 214 | """ |
214 | 215 | base_dir: path from source root to directory containing this gyp file, |
215 | 216 | by gyp semantics, all input paths are relative to this |
243 | 244 | # Relative path from base dir to build dir. |
244 | 245 | base_to_top = gyp.common.InvertRelativePath(base_dir, toplevel_dir) |
245 | 246 | self.base_to_build = os.path.join(base_to_top, build_dir) |
247 | self.link_deps_file = deps_file | |
246 | 248 | |
247 | 249 | def ExpandSpecial(self, path, product_dir=None): |
248 | 250 | """Expand specials like $!PRODUCT_DIR in |path|. |
372 | 374 | self.target = Target(spec['type']) |
373 | 375 | self.is_standalone_static_library = bool( |
374 | 376 | spec.get('standalone_static_library', 0)) |
377 | # Track if this target contains any C++ files, to decide if gcc or g++ | |
378 | # should be used for linking. | |
379 | self.uses_cpp = False | |
375 | 380 | |
376 | 381 | self.is_mac_bundle = gyp.xcode_emulation.IsMacBundle(self.flavor, spec) |
377 | 382 | self.xcode_settings = self.msvs_settings = None |
390 | 395 | if len(self.archs) > 1: |
391 | 396 | self.arch_subninjas = dict( |
392 | 397 | (arch, ninja_syntax.Writer( |
393 | open(os.path.join(self.toplevel_build, | |
394 | self._SubninjaNameForArch(arch)), | |
395 | 'w'))) | |
398 | OpenOutput(os.path.join(self.toplevel_build, | |
399 | self._SubninjaNameForArch(arch)), | |
400 | 'w'))) | |
396 | 401 | for arch in self.archs) |
397 | 402 | |
398 | 403 | # Compute predepends for all rules. |
472 | 477 | |
473 | 478 | # Write out a link step, if needed. |
474 | 479 | output = None |
475 | is_empty_bundle = True | |
480 | is_empty_bundle = not link_deps and not mac_bundle_depends | |
476 | 481 | if link_deps or self.target.actions_stamp or actions_depends: |
477 | 482 | output = self.WriteTarget(spec, config_name, config, link_deps, |
478 | 483 | self.target.actions_stamp or actions_depends) |
479 | 484 | if self.is_mac_bundle: |
480 | is_empty_bundle = not link_deps and not mac_bundle_depends | |
481 | 485 | mac_bundle_depends.append(output) |
482 | 486 | |
483 | 487 | # Bundle all of the above together, if needed. |
529 | 533 | """Write out the Actions, Rules, and Copies steps. Return a path |
530 | 534 | representing the outputs of these steps.""" |
531 | 535 | outputs = [] |
536 | if self.is_mac_bundle: | |
537 | mac_bundle_resources = spec.get('mac_bundle_resources', [])[:] | |
538 | else: | |
539 | mac_bundle_resources = [] | |
532 | 540 | extra_mac_bundle_resources = [] |
533 | 541 | |
534 | 542 | if 'actions' in spec: |
536 | 544 | extra_mac_bundle_resources) |
537 | 545 | if 'rules' in spec: |
538 | 546 | outputs += self.WriteRules(spec['rules'], extra_sources, prebuild, |
547 | mac_bundle_resources, | |
539 | 548 | extra_mac_bundle_resources) |
540 | 549 | if 'copies' in spec: |
541 | 550 | outputs += self.WriteCopies(spec['copies'], prebuild, mac_bundle_depends) |
546 | 555 | stamp = self.WriteCollapsedDependencies('actions_rules_copies', outputs) |
547 | 556 | |
548 | 557 | if self.is_mac_bundle: |
549 | mac_bundle_resources = spec.get('mac_bundle_resources', []) + \ | |
550 | extra_mac_bundle_resources | |
551 | self.WriteMacBundleResources(mac_bundle_resources, mac_bundle_depends) | |
558 | self.WriteMacBundleResources( | |
559 | mac_bundle_resources + extra_mac_bundle_resources, mac_bundle_depends) | |
552 | 560 | self.WriteMacInfoPlist(mac_bundle_depends) |
553 | 561 | |
554 | 562 | return stamp |
605 | 613 | return all_outputs |
606 | 614 | |
607 | 615 | def WriteRules(self, rules, extra_sources, prebuild, |
608 | extra_mac_bundle_resources): | |
616 | mac_bundle_resources, extra_mac_bundle_resources): | |
609 | 617 | env = self.GetSortedXcodeEnv() |
610 | 618 | all_outputs = [] |
611 | 619 | for rule in rules: |
659 | 667 | |
660 | 668 | if int(rule.get('process_outputs_as_sources', False)): |
661 | 669 | extra_sources += outputs |
662 | if int(rule.get('process_outputs_as_mac_bundle_resources', False)): | |
670 | ||
671 | was_mac_bundle_resource = source in mac_bundle_resources | |
672 | if was_mac_bundle_resource or \ | |
673 | int(rule.get('process_outputs_as_mac_bundle_resources', False)): | |
663 | 674 | extra_mac_bundle_resources += outputs |
675 | # Note: This is n_resources * n_outputs_in_rule. Put to-be-removed | |
676 | # items in a set and remove them all in a single pass if this becomes | |
677 | # a performance issue. | |
678 | if was_mac_bundle_resource: | |
679 | mac_bundle_resources.remove(source) | |
664 | 680 | |
665 | 681 | extra_bindings = [] |
666 | 682 | for var in needed_variables: |
764 | 780 | self.ninja.variable('cc', '$cc_host') |
765 | 781 | self.ninja.variable('cxx', '$cxx_host') |
766 | 782 | self.ninja.variable('ld', '$ld_host') |
783 | self.ninja.variable('ldxx', '$ldxx_host') | |
767 | 784 | |
768 | 785 | if self.flavor != 'mac' or len(self.archs) == 1: |
769 | 786 | return self.WriteSourcesForArch( |
861 | 878 | obj_ext = self.obj_ext |
862 | 879 | if ext in ('cc', 'cpp', 'cxx'): |
863 | 880 | command = 'cxx' |
881 | self.uses_cpp = True | |
864 | 882 | elif ext == 'c' or (ext == 'S' and self.flavor != 'win'): |
865 | 883 | command = 'cc' |
866 | 884 | elif ext == 's' and self.flavor != 'win': # Doesn't generate .o.d files. |
877 | 895 | command = 'objc' |
878 | 896 | elif self.flavor == 'mac' and ext == 'mm': |
879 | 897 | command = 'objcxx' |
898 | self.uses_cpp = True | |
880 | 899 | elif self.flavor == 'win' and ext == 'rc': |
881 | 900 | command = 'rc' |
882 | 901 | obj_ext = '.res' |
962 | 981 | continue |
963 | 982 | linkable = target.Linkable() |
964 | 983 | if linkable: |
984 | if self.link_deps_file: | |
985 | # Save the mapping of link deps. | |
986 | self.link_deps_file.write(self.qualified_target) | |
987 | self.link_deps_file.write(' ') | |
988 | self.link_deps_file.write(target.binary) | |
989 | self.link_deps_file.write('\n') | |
990 | ||
965 | 991 | if (self.flavor == 'win' and |
966 | 992 | target.component_objs and |
967 | 993 | self.msvs_settings.IsUseLibraryDependencyInputs(config_name)): |
981 | 1007 | link_deps.extend(list(extra_link_deps)) |
982 | 1008 | |
983 | 1009 | extra_bindings = [] |
1010 | if self.uses_cpp and self.flavor != 'win': | |
1011 | extra_bindings.append(('ld', '$ldxx')) | |
1012 | ||
984 | 1013 | output = self.ComputeOutput(spec, arch) |
985 | 1014 | if arch is None and not self.is_mac_bundle: |
986 | 1015 | self.AppendPostbuildVariable(extra_bindings, spec, output, output) |
1483 | 1512 | stat.dwLength = ctypes.sizeof(stat) |
1484 | 1513 | ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat)) |
1485 | 1514 | |
1486 | return max(1, stat.ullTotalPhys / (4 * (2 ** 30))) # total / 4GB | |
1515 | mem_limit = max(1, stat.ullTotalPhys / (4 * (2 ** 30))) # total / 4GB | |
1516 | hard_cap = max(1, int(os.getenv('GYP_LINK_CONCURRENCY_MAX', 2**32))) | |
1517 | return min(mem_limit, hard_cap) | |
1487 | 1518 | elif sys.platform.startswith('linux'): |
1488 | 1519 | with open("/proc/meminfo") as meminfo: |
1489 | 1520 | memtotal_re = re.compile(r'^MemTotal:\s*(\d*)\s*kB') |
1629 | 1660 | else: |
1630 | 1661 | cc = 'gcc' |
1631 | 1662 | cxx = 'g++' |
1632 | ld = '$cxx' | |
1633 | ld_host = '$cxx_host' | |
1663 | ld = '$cc' | |
1664 | ldxx = '$cxx' | |
1665 | ld_host = '$cc_host' | |
1666 | ldxx_host = '$cxx_host' | |
1634 | 1667 | |
1635 | 1668 | cc_host = None |
1636 | 1669 | cxx_host = None |
1647 | 1680 | cc = os.path.join(build_to_root, value) |
1648 | 1681 | if key == 'CXX': |
1649 | 1682 | cxx = os.path.join(build_to_root, value) |
1650 | if key == 'LD': | |
1651 | ld = os.path.join(build_to_root, value) | |
1652 | 1683 | if key == 'CC.host': |
1653 | 1684 | cc_host = os.path.join(build_to_root, value) |
1654 | 1685 | cc_host_global_setting = value |
1655 | 1686 | if key == 'CXX.host': |
1656 | 1687 | cxx_host = os.path.join(build_to_root, value) |
1657 | 1688 | cxx_host_global_setting = value |
1658 | if key == 'LD.host': | |
1659 | ld_host = os.path.join(build_to_root, value) | |
1660 | 1689 | if key.endswith('_wrapper'): |
1661 | 1690 | wrappers[key[:-len('_wrapper')]] = os.path.join(build_to_root, value) |
1662 | 1691 | |
1679 | 1708 | master_ninja.variable('cc', CommandWithWrapper('CC', wrappers, cc)) |
1680 | 1709 | cxx = GetEnvironFallback(['CXX_target', 'CXX'], cxx) |
1681 | 1710 | master_ninja.variable('cxx', CommandWithWrapper('CXX', wrappers, cxx)) |
1682 | ld = GetEnvironFallback(['LD_target', 'LD'], ld) | |
1683 | 1711 | |
1684 | 1712 | if flavor == 'win': |
1685 | 1713 | master_ninja.variable('ld', ld) |
1690 | 1718 | master_ninja.variable('mt', 'mt.exe') |
1691 | 1719 | else: |
1692 | 1720 | master_ninja.variable('ld', CommandWithWrapper('LINK', wrappers, ld)) |
1721 | master_ninja.variable('ldxx', CommandWithWrapper('LINK', wrappers, ldxx)) | |
1693 | 1722 | master_ninja.variable('ar', GetEnvironFallback(['AR_target', 'AR'], 'ar')) |
1694 | 1723 | |
1695 | 1724 | if generator_supports_multiple_toolsets: |
1701 | 1730 | master_ninja.variable('ar_host', GetEnvironFallback(['AR_host'], 'ar')) |
1702 | 1731 | cc_host = GetEnvironFallback(['CC_host'], cc_host) |
1703 | 1732 | cxx_host = GetEnvironFallback(['CXX_host'], cxx_host) |
1704 | ld_host = GetEnvironFallback(['LD_host'], ld_host) | |
1705 | 1733 | |
1706 | 1734 | # The environment variable could be used in 'make_global_settings', like |
1707 | 1735 | # ['CC.host', '$(CC)'] or ['CXX.host', '$(CXX)'], transform them here. |
1718 | 1746 | else: |
1719 | 1747 | master_ninja.variable('ld_host', CommandWithWrapper( |
1720 | 1748 | 'LINK', wrappers, ld_host)) |
1749 | master_ninja.variable('ldxx_host', CommandWithWrapper( | |
1750 | 'LINK', wrappers, ldxx_host)) | |
1721 | 1751 | |
1722 | 1752 | master_ninja.newline() |
1723 | 1753 | |
1882 | 1912 | |
1883 | 1913 | # Record the public interface of $lib in $lib.TOC. See the corresponding |
1884 | 1914 | # comment in the posix section above for details. |
1885 | solink_base = '$ld -shared $ldflags -o $lib %(suffix)s' | |
1915 | solink_base = '$ld %(type)s $ldflags -o $lib %(suffix)s' | |
1886 | 1916 | mtime_preserving_solink_base = ( |
1887 | 1917 | 'if [ ! -e $lib -o ! -e ${lib}.TOC ] || ' |
1888 | 1918 | # Always force dependent targets to relink if this library |
1901 | 1931 | '{ otool -l $lib | grep LC_ID_DYLIB -A 5; ' |
1902 | 1932 | 'nm -gP $lib | cut -f1-2 -d\' \' | grep -v U$$; true; }'}) |
1903 | 1933 | |
1904 | # TODO(thakis): The solink_module rule is likely wrong. Xcode seems to pass | |
1905 | # -bundle -single_module here (for osmesa.so). | |
1906 | 1934 | solink_suffix = '$in $solibs $libs$postbuilds' |
1907 | 1935 | master_ninja.rule( |
1908 | 1936 | 'solink', |
1909 | 1937 | description='SOLINK $lib, POSTBUILDS', |
1910 | 1938 | restat=True, |
1911 | command=mtime_preserving_solink_base % {'suffix':solink_suffix}, | |
1939 | command=mtime_preserving_solink_base % {'suffix': solink_suffix, | |
1940 | 'type': '-shared'}, | |
1912 | 1941 | pool='link_pool') |
1913 | 1942 | master_ninja.rule( |
1914 | 1943 | 'solink_notoc', |
1915 | 1944 | description='SOLINK $lib, POSTBUILDS', |
1916 | 1945 | restat=True, |
1917 | command=solink_base % {'suffix':solink_suffix}, | |
1946 | command=solink_base % {'suffix':solink_suffix, 'type': '-shared'}, | |
1918 | 1947 | pool='link_pool') |
1919 | 1948 | |
1920 | 1949 | solink_module_suffix = '$in $solibs $libs$postbuilds' |
1922 | 1951 | 'solink_module', |
1923 | 1952 | description='SOLINK(module) $lib, POSTBUILDS', |
1924 | 1953 | restat=True, |
1925 | command=mtime_preserving_solink_base % {'suffix':solink_module_suffix}, | |
1954 | command=mtime_preserving_solink_base % {'suffix': solink_module_suffix, | |
1955 | 'type': '-bundle'}, | |
1926 | 1956 | pool='link_pool') |
1927 | 1957 | master_ninja.rule( |
1928 | 1958 | 'solink_module_notoc', |
1929 | 1959 | description='SOLINK(module) $lib, POSTBUILDS', |
1930 | 1960 | restat=True, |
1931 | command=solink_base % {'suffix':solink_module_suffix}, | |
1961 | command=solink_base % {'suffix': solink_module_suffix, 'type': '-bundle'}, | |
1932 | 1962 | pool='link_pool') |
1933 | 1963 | |
1934 | 1964 | master_ninja.rule( |
1984 | 2014 | # target_short_names is a map from target short name to a list of Target |
1985 | 2015 | # objects. |
1986 | 2016 | target_short_names = {} |
2017 | ||
2018 | # Extract the optional link deps file name. | |
2019 | LINK_DEPS_FILE = 'link_deps_file' | |
2020 | if LINK_DEPS_FILE in generator_flags: | |
2021 | link_deps_file = open(generator_flags.get(LINK_DEPS_FILE), 'wb') | |
2022 | else: | |
2023 | link_deps_file = None | |
2024 | ||
1987 | 2025 | for qualified_target in target_list: |
1988 | 2026 | # qualified_target is like: third_party/icu/icu.gyp:icui18n#target |
1989 | 2027 | build_file, name, toolset = \ |
2005 | 2043 | obj += '.' + toolset |
2006 | 2044 | output_file = os.path.join(obj, base_path, name + '.ninja') |
2007 | 2045 | |
2046 | ninja_output = StringIO() | |
2008 | 2047 | writer = NinjaWriter(qualified_target, target_outputs, base_path, build_dir, |
2009 | OpenOutput(os.path.join(toplevel_build, output_file)), | |
2048 | ninja_output, | |
2010 | 2049 | toplevel_build, output_file, |
2011 | flavor, toplevel_dir=options.toplevel_dir) | |
2012 | master_ninja.subninja(output_file) | |
2050 | flavor, link_deps_file, | |
2051 | toplevel_dir=options.toplevel_dir) | |
2013 | 2052 | |
2014 | 2053 | target = writer.WriteSpec(spec, config_name, generator_flags) |
2054 | ||
2055 | if ninja_output.tell() > 0: | |
2056 | # Only create files for ninja files that actually have contents. | |
2057 | with OpenOutput(os.path.join(toplevel_build, output_file)) as ninja_file: | |
2058 | ninja_file.write(ninja_output.getvalue()) | |
2059 | ninja_output.close() | |
2060 | master_ninja.subninja(output_file) | |
2061 | ||
2015 | 2062 | if target: |
2016 | 2063 | if name != target.FinalOutput() and spec['toolset'] == 'target': |
2017 | 2064 | target_short_names.setdefault(name, []).append(target) |
68 | 68 | 'default_configuration', |
69 | 69 | 'dependencies', |
70 | 70 | 'dependencies_original', |
71 | 'link_languages', | |
72 | 71 | 'libraries', |
73 | 72 | 'postbuilds', |
74 | 73 | 'product_dir', |
1583 | 1582 | |
1584 | 1583 | return dependencies |
1585 | 1584 | |
1586 | def LinkDependencies(self, targets, dependencies=None, initial=True): | |
1585 | def _LinkDependenciesInternal(self, targets, include_shared_libraries, | |
1586 | dependencies=None, initial=True): | |
1587 | 1587 | """Returns a list of dependency targets that are linked into this target. |
1588 | 1588 | |
1589 | 1589 | This function has a split personality, depending on the setting of |
1593 | 1593 | When adding a target to the list of dependencies, this function will |
1594 | 1594 | recurse into itself with |initial| set to False, to collect dependencies |
1595 | 1595 | that are linked into the linkable target for which the list is being built. |
1596 | ||
1597 | If |include_shared_libraries| is False, the resulting dependencies will not | |
1598 | include shared_library targets that are linked into this target. | |
1596 | 1599 | """ |
1597 | 1600 | if dependencies == None: |
1598 | 1601 | dependencies = [] |
1635 | 1638 | # dependencies in the sense that a dependent target might run an |
1636 | 1639 | # executable or load the loadable_module. |
1637 | 1640 | if not initial and target_type in ('executable', 'loadable_module'): |
1641 | return dependencies | |
1642 | ||
1643 | # Shared libraries are already fully linked. They should only be included | |
1644 | # in |dependencies| when adjusting static library dependencies (in order to | |
1645 | # link against the shared_library's import lib), but should not be included | |
1646 | # in |dependencies| when propagating link_settings. | |
1647 | # The |include_shared_libraries| flag controls which of these two cases we | |
1648 | # are handling. | |
1649 | if (not initial and target_type == 'shared_library' and | |
1650 | not include_shared_libraries): | |
1638 | 1651 | return dependencies |
1639 | 1652 | |
1640 | 1653 | # The target is linkable, add it to the list of link dependencies. |
1646 | 1659 | # this target linkable. Always look at dependencies of the initial |
1647 | 1660 | # target, and always look at dependencies of non-linkables. |
1648 | 1661 | for dependency in self.dependencies: |
1649 | dependency.LinkDependencies(targets, dependencies, False) | |
1662 | dependency._LinkDependenciesInternal(targets, | |
1663 | include_shared_libraries, | |
1664 | dependencies, False) | |
1650 | 1665 | |
1651 | 1666 | return dependencies |
1667 | ||
1668 | def DependenciesForLinkSettings(self, targets): | |
1669 | """ | |
1670 | Returns a list of dependency targets whose link_settings should be merged | |
1671 | into this target. | |
1672 | """ | |
1673 | ||
1674 | # TODO(sbaig) Currently, chrome depends on the bug that shared libraries' | |
1675 | # link_settings are propagated. So for now, we will allow it, unless the | |
1676 | # 'allow_sharedlib_linksettings_propagation' flag is explicitly set to | |
1677 | # False. Once chrome is fixed, we can remove this flag. | |
1678 | include_shared_libraries = \ | |
1679 | targets[self.ref].get('allow_sharedlib_linksettings_propagation', True) | |
1680 | return self._LinkDependenciesInternal(targets, include_shared_libraries) | |
1681 | ||
1682 | def DependenciesToLinkAgainst(self, targets): | |
1683 | """ | |
1684 | Returns a list of dependency targets that are linked into this target. | |
1685 | """ | |
1686 | return self._LinkDependenciesInternal(targets, True) | |
1652 | 1687 | |
1653 | 1688 | |
1654 | 1689 | def BuildDependencyList(targets): |
1766 | 1801 | dependencies = \ |
1767 | 1802 | dependency_nodes[target].DirectAndImportedDependencies(targets) |
1768 | 1803 | elif key == 'link_settings': |
1769 | dependencies = dependency_nodes[target].LinkDependencies(targets) | |
1804 | dependencies = \ | |
1805 | dependency_nodes[target].DependenciesForLinkSettings(targets) | |
1770 | 1806 | else: |
1771 | 1807 | raise GypError("DoDependentSettings doesn't know how to determine " |
1772 | 1808 | 'dependencies for ' + key) |
1839 | 1875 | # target. Add them to the dependencies list if they're not already |
1840 | 1876 | # present. |
1841 | 1877 | |
1842 | link_dependencies = dependency_nodes[target].LinkDependencies(targets) | |
1878 | link_dependencies = \ | |
1879 | dependency_nodes[target].DependenciesToLinkAgainst(targets) | |
1843 | 1880 | for dependency in link_dependencies: |
1844 | 1881 | if dependency == target: |
1845 | 1882 | continue |
107 | 107 | return None |
108 | 108 | fp.close() |
109 | 109 | if header.startswith("\xFE\xFF"): |
110 | return "UTF-16BE" | |
110 | return "UTF-16" | |
111 | 111 | elif header.startswith("\xFF\xFE"): |
112 | return "UTF-16LE" | |
112 | return "UTF-16" | |
113 | 113 | elif header.startswith("\xEF\xBB\xBF"): |
114 | 114 | return "UTF-8" |
115 | 115 | else: |
360 | 360 | cl('AdditionalOptions', prefix='') |
361 | 361 | cflags.extend(['/FI' + f for f in self._Setting( |
362 | 362 | ('VCCLCompilerTool', 'ForcedIncludeFiles'), config, default=[])]) |
363 | if self.vs_version.short_name == '2013' or self.vs_version == '2013e': | |
364 | # New flag required in 2013 to maintain previous PDB behavior. | |
365 | cflags.append('/FS') | |
363 | 366 | # ninja handles parallelism by itself, don't have the compiler do it too. |
364 | 367 | cflags = filter(lambda x: not x.startswith('/MP'), cflags) |
365 | 368 | return cflags |
608 | 608 | ldflags.append('-L' + product_dir) |
609 | 609 | |
610 | 610 | install_name = self.GetInstallName() |
611 | if install_name: | |
611 | if install_name and self.spec['type'] != 'loadable_module': | |
612 | 612 | ldflags.append('-install_name ' + install_name.replace(' ', r'\ ')) |
613 | 613 | |
614 | 614 | for rpath in self._Settings().get('LD_RUNPATH_SEARCH_PATHS', []): |
168 | 168 | |
169 | 169 | # This pattern should match any character that needs to be escaped by |
170 | 170 | # XCObject._EncodeString. See that function. |
171 | _escaped = re.compile('[\\\\"]|[^ -~]') | |
171 | _escaped = re.compile('[\\\\"]|[\x00-\x1f]') | |
172 | 172 | |
173 | 173 | |
174 | 174 | # Used by SourceTreeAndPathFromPath |
556 | 556 | # 10 ^J NL is encoded as "\n" |
557 | 557 | # 13 ^M CR is encoded as "\n" rendering it indistinguishable from |
558 | 558 | # 10 ^J NL |
559 | # All other nonprintable characters within the ASCII range (0 through 127 | |
560 | # inclusive) are encoded as "\U001f" referring to the Unicode code point in | |
561 | # hexadecimal. For example, character 14 (^N SO) is encoded as "\U000e". | |
559 | # All other characters within the ASCII control character range (0 through | |
560 | # 31 inclusive) are encoded as "\U001f" referring to the Unicode code point | |
561 | # in hexadecimal. For example, character 14 (^N SO) is encoded as "\U000e". | |
562 | 562 | # Characters above the ASCII range are passed through to the output encoded |
563 | 563 | # as UTF-8 without any escaping. These mappings are contained in the |
564 | 564 | # class' _encode_transforms list. |
3 | 3 | # Use of this source code is governed by a BSD-style license that can be |
4 | 4 | # found in the LICENSE file. |
5 | 5 | |
6 | from distutils.core import setup | |
7 | from distutils.command.install import install | |
8 | from distutils.command.install_lib import install_lib | |
9 | from distutils.command.install_scripts import install_scripts | |
6 | from ez_setup import use_setuptools | |
7 | use_setuptools() | |
8 | from setuptools import setup | |
10 | 9 | |
11 | 10 | setup( |
12 | 11 | name='gyp', |
17 | 16 | url='http://code.google.com/p/gyp', |
18 | 17 | package_dir = {'': 'pylib'}, |
19 | 18 | packages=['gyp', 'gyp.generator'], |
20 | ||
21 | scripts = ['gyp'], | |
22 | cmdclass = {'install': install, | |
23 | 'install_lib': install_lib, | |
24 | 'install_scripts': install_scripts}, | |
19 | entry_points = {'console_scripts': ['gyp=gyp:script_main'] } | |
25 | 20 | ) |
19 | 19 | sys.exit(0) |
20 | 20 | |
21 | 21 | # Clear any existing compiler related env vars. |
22 | for key in 'CC', 'CXX', 'LD', 'CC_host', 'CXX_host', 'LD_host': | |
22 | for key in ['CC', 'CXX', 'LINK', 'CC_host', 'CXX_host', 'LINK_host']: | |
23 | 23 | if key in os.environ: |
24 | 24 | del os.environ[key] |
25 | 25 | |
37 | 37 | test = TestGyp.TestGyp(formats=['ninja', 'make']) |
38 | 38 | |
39 | 39 | def TestTargetOveride(): |
40 | expected = ['my_cc.py', 'my_cxx.py', 'FOO' ] | |
41 | if test.format != 'ninja': # ninja just uses $CC / $CXX as linker. | |
42 | expected.append('FOO_LINK') | |
43 | ||
40 | 44 | # Check that CC, CXX and LD set target compiler |
41 | 45 | oldenv = os.environ.copy() |
42 | 46 | try: |
43 | 47 | os.environ['CC'] = 'python %s/my_cc.py FOO' % here |
44 | 48 | os.environ['CXX'] = 'python %s/my_cxx.py FOO' % here |
45 | os.environ['LD'] = 'python %s/my_ld.py FOO_LINK' % here | |
49 | os.environ['LINK'] = 'python %s/my_ld.py FOO_LINK' % here | |
46 | 50 | |
47 | CheckCompiler(test, 'compiler.gyp', | |
48 | ['my_cc.py', 'my_cxx.py', 'FOO', 'FOO_LINK'], | |
51 | CheckCompiler(test, 'compiler.gyp', expected, | |
49 | 52 | True) |
50 | 53 | finally: |
51 | 54 | os.environ.clear() |
54 | 57 | # Run the same tests once the eviron has been restored. The |
55 | 58 | # generated should have embedded all the settings in the |
56 | 59 | # project files so the results should be the same. |
57 | CheckCompiler(test, 'compiler.gyp', | |
58 | ['my_cc.py', 'my_cxx.py', 'FOO', 'FOO_LINK'], | |
60 | CheckCompiler(test, 'compiler.gyp', expected, | |
59 | 61 | False) |
60 | 62 | |
61 | 63 | def TestTargetOverideCompilerOnly(): |
81 | 83 | |
82 | 84 | |
83 | 85 | def TestHostOveride(): |
86 | expected = ['my_cc.py', 'my_cxx.py', 'HOST' ] | |
87 | if test.format != 'ninja': # ninja just uses $CC / $CXX as linker. | |
88 | expected.append('HOST_LINK') | |
89 | ||
84 | 90 | # Check that CC_host sets host compilee |
85 | 91 | oldenv = os.environ.copy() |
86 | 92 | try: |
87 | 93 | os.environ['CC_host'] = 'python %s/my_cc.py HOST' % here |
88 | 94 | os.environ['CXX_host'] = 'python %s/my_cxx.py HOST' % here |
89 | os.environ['LD_host'] = 'python %s/my_ld.py HOST_LINK' % here | |
90 | CheckCompiler(test, 'compiler-host.gyp', | |
91 | ['my_cc.py', 'my_cxx.py', 'HOST', 'HOST_LINK'], | |
92 | True) | |
95 | os.environ['LINK_host'] = 'python %s/my_ld.py HOST_LINK' % here | |
96 | CheckCompiler(test, 'compiler-host.gyp', expected, True) | |
93 | 97 | finally: |
94 | 98 | os.environ.clear() |
95 | 99 | os.environ.update(oldenv) |
97 | 101 | # Run the same tests once the eviron has been restored. The |
98 | 102 | # generated should have embedded all the settings in the |
99 | 103 | # project files so the results should be the same. |
100 | CheckCompiler(test, 'compiler-host.gyp', | |
101 | ['my_cc.py', 'my_cxx.py', 'HOST', 'HOST_LINK'], | |
102 | False) | |
104 | CheckCompiler(test, 'compiler-host.gyp', expected, False) | |
103 | 105 | |
104 | 106 | |
105 | 107 | TestTargetOveride() |
0 | #!/usr/bin/env python | |
1 | ||
2 | # Copyright (c) 2013 Google Inc. All rights reserved. | |
3 | # Use of this source code is governed by a BSD-style license that can be | |
4 | # found in the LICENSE file. | |
5 | ||
6 | """ | |
7 | Verify that link_settings in a shared_library are not propagated to targets | |
8 | that depend on the shared_library, but are used in the shared_library itself. | |
9 | """ | |
10 | ||
11 | import TestGyp | |
12 | import sys | |
13 | ||
14 | CHDIR='sharedlib-linksettings' | |
15 | ||
16 | test = TestGyp.TestGyp() | |
17 | test.run_gyp('test.gyp', chdir=CHDIR) | |
18 | test.build('test.gyp', test.ALL, chdir=CHDIR) | |
19 | test.run_built_executable('program', stdout="1\n2\n", chdir=CHDIR) | |
20 | test.pass_test() |
0 | /* | |
1 | * Copyright (c) 2013 Google Inc. All rights reserved. | |
2 | * Use of this source code is governed by a BSD-style license that can be | |
3 | * found in the LICENSE file. | |
4 | */ | |
5 | ||
6 | #include <stdio.h> | |
7 | ||
8 | /* | |
9 | * This will fail to compile if TEST_DEFINE was propagated from sharedlib to | |
10 | * program. | |
11 | */ | |
12 | #ifdef TEST_DEFINE | |
13 | #error TEST_DEFINE is already defined! | |
14 | #endif | |
15 | ||
16 | #define TEST_DEFINE 2 | |
17 | ||
18 | extern int staticLibFunc(); | |
19 | ||
20 | int main() { | |
21 | printf("%d\n", staticLibFunc()); | |
22 | printf("%d\n", TEST_DEFINE); | |
23 | return 0; | |
24 | } |
0 | /* | |
1 | * Copyright (c) 2013 Google Inc. All rights reserved. | |
2 | * Use of this source code is governed by a BSD-style license that can be | |
3 | * found in the LICENSE file. | |
4 | */ | |
5 | ||
6 | #ifdef _WIN32 | |
7 | __declspec(dllexport) | |
8 | #endif | |
9 | int sharedLibFunc() { | |
10 | /* | |
11 | * This will fail to compile if TEST_DEFINE was not obtained from sharedlib's | |
12 | * link_settings. | |
13 | */ | |
14 | return TEST_DEFINE; | |
15 | } |
0 | /* | |
1 | * Copyright (c) 2013 Google Inc. All rights reserved. | |
2 | * Use of this source code is governed by a BSD-style license that can be | |
3 | * found in the LICENSE file. | |
4 | */ | |
5 | ||
6 | /* | |
7 | * This will fail to compile if TEST_DEFINE was propagated from sharedlib to | |
8 | * staticlib. | |
9 | */ | |
10 | #ifdef TEST_DEFINE | |
11 | #error TEST_DEFINE is defined! | |
12 | #endif | |
13 | ||
14 | #ifdef _WIN32 | |
15 | __declspec(dllimport) | |
16 | #else | |
17 | extern | |
18 | #endif | |
19 | int sharedLibFunc(); | |
20 | ||
21 | int staticLibFunc() { | |
22 | return sharedLibFunc(); | |
23 | } |
0 | # Copyright (c) 2013 Google Inc. All rights reserved. | |
1 | # Use of this source code is governed by a BSD-style license that can be | |
2 | # found in the LICENSE file. | |
3 | ||
4 | { | |
5 | 'target_defaults': { | |
6 | 'allow_sharedlib_linksettings_propagation': 0, | |
7 | }, | |
8 | 'targets': [ | |
9 | { | |
10 | 'target_name': 'sharedlib', | |
11 | 'type': 'shared_library', | |
12 | 'sources': [ 'sharedlib.c' ], | |
13 | 'link_settings': { | |
14 | 'defines': [ 'TEST_DEFINE=1' ], | |
15 | }, | |
16 | 'conditions': [ | |
17 | ['OS=="linux"', { | |
18 | # Support 64-bit shared libs (also works fine for 32-bit). | |
19 | 'cflags': ['-fPIC'], | |
20 | }], | |
21 | ], | |
22 | }, | |
23 | { | |
24 | 'target_name': 'staticlib', | |
25 | 'type': 'static_library', | |
26 | 'sources': [ 'staticlib.c' ], | |
27 | 'dependencies': [ 'sharedlib' ], | |
28 | }, | |
29 | { | |
30 | 'target_name': 'program', | |
31 | 'type': 'executable', | |
32 | 'sources': [ 'program.c' ], | |
33 | 'dependencies': [ 'staticlib' ], | |
34 | }, | |
35 | ], | |
36 | } |
Binary diff not shown
Binary diff not shown
22 | 22 | 'TestApp/TestAppAppDelegate.m', |
23 | 23 | ], |
24 | 24 | 'mac_bundle_resources': [ |
25 | 'TestApp/English.lproj/InfoPlist.strings', | |
25 | 'TestApp/English.lproj/InfoPlist.strings', # UTF-8 | |
26 | 'TestApp/English.lproj/utf-16be.strings', | |
27 | 'TestApp/English.lproj/utf-16le.strings', | |
26 | 28 | 'TestApp/English.lproj/MainMenu.xib', |
27 | 29 | ], |
28 | 30 | 'link_settings': { |
0 | abc |
0 | # Copyright (c) 2013 Google Inc. All rights reserved. | |
1 | # Use of this source code is governed by a BSD-style license that can be | |
2 | # found in the LICENSE file. | |
3 | { | |
4 | 'targets': [ | |
5 | { | |
6 | 'target_name': 'resource', | |
7 | 'type': 'executable', | |
8 | 'mac_bundle': 1, | |
9 | 'mac_bundle_resources': [ | |
10 | 'secret.txt', | |
11 | ], | |
12 | }, | |
13 | # A rule with process_outputs_as_mac_bundle_resources should copy files | |
14 | # into the Resources folder. | |
15 | { | |
16 | 'target_name': 'source_rule', | |
17 | 'type': 'executable', | |
18 | 'mac_bundle': 1, | |
19 | 'sources': [ | |
20 | 'secret.txt', | |
21 | ], | |
22 | 'rules': [ | |
23 | { | |
24 | 'rule_name': 'bundlerule', | |
25 | 'extension': 'txt', | |
26 | 'outputs': [ | |
27 | '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).txt', | |
28 | ], | |
29 | 'action': ['./change.sh', '<(RULE_INPUT_PATH)', '<@(_outputs)'], | |
30 | 'message': 'Running rule on <(RULE_INPUT_PATH)', | |
31 | 'process_outputs_as_mac_bundle_resources': 1, | |
32 | }, | |
33 | ], | |
34 | }, | |
35 | # So should an ordinary rule acting on mac_bundle_resources. | |
36 | { | |
37 | 'target_name': 'resource_rule', | |
38 | 'type': 'executable', | |
39 | 'mac_bundle': 1, | |
40 | 'mac_bundle_resources': [ | |
41 | 'secret.txt', | |
42 | ], | |
43 | 'rules': [ | |
44 | { | |
45 | 'rule_name': 'bundlerule', | |
46 | 'extension': 'txt', | |
47 | 'outputs': [ | |
48 | '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).txt', | |
49 | ], | |
50 | 'action': ['./change.sh', '<(RULE_INPUT_PATH)', '<@(_outputs)'], | |
51 | 'message': 'Running rule on <(RULE_INPUT_PATH)', | |
52 | }, | |
53 | ], | |
54 | }, | |
55 | ], | |
56 | } | |
57 |
41 | 41 | test.must_not_contain(info_plist, '${MACOSX_DEPLOYMENT_TARGET}'); |
42 | 42 | |
43 | 43 | # Resources |
44 | strings = test.built_file_path( | |
45 | 'Test App Gyp.app/Contents/Resources/English.lproj/InfoPlist.strings', | |
46 | chdir='app-bundle') | |
47 | test.must_exist(strings) | |
48 | # Xcodes writes UTF-16LE with BOM. | |
49 | test.must_contain(strings, '\xff\xfe' + '/* Localized'.encode('utf-16le')) | |
44 | strings_files = ['InfoPlist.strings', 'utf-16be.strings', 'utf-16le.strings'] | |
45 | for f in strings_files: | |
46 | strings = test.built_file_path( | |
47 | os.path.join('Test App Gyp.app/Contents/Resources/English.lproj', f), | |
48 | chdir='app-bundle') | |
49 | test.must_exist(strings) | |
50 | # Xcodes writes UTF-16LE with BOM. | |
51 | contents = open(strings, 'rb').read() | |
52 | if not contents.startswith('\xff\xfe' + '/* Localized'.encode('utf-16le')): | |
53 | test.fail_test() | |
50 | 54 | |
51 | 55 | test.built_file_must_exist( |
52 | 56 | 'Test App Gyp.app/Contents/Resources/English.lproj/MainMenu.nib', |
62 | 66 | if set(ls(test.built_file_path('Test App Gyp.app', chdir='app-bundle'))) != \ |
63 | 67 | set(['Contents/MacOS/Test App Gyp', |
64 | 68 | 'Contents/Info.plist', |
65 | 'Contents/Resources/English.lproj/InfoPlist.strings', | |
66 | 69 | 'Contents/Resources/English.lproj/MainMenu.nib', |
67 | 70 | 'Contents/PkgInfo', |
68 | ]): | |
71 | ] + | |
72 | [os.path.join('Contents/Resources/English.lproj', f) | |
73 | for f in strings_files]): | |
69 | 74 | test.fail_test() |
70 | 75 | |
71 | 76 | test.pass_test() |
0 | #!/usr/bin/env python | |
1 | ||
2 | # Copyright (c) 2013 Google Inc. All rights reserved. | |
3 | # Use of this source code is governed by a BSD-style license that can be | |
4 | # found in the LICENSE file. | |
5 | ||
6 | """ | |
7 | Verifies things related to bundle resources. | |
8 | """ | |
9 | ||
10 | import TestGyp | |
11 | ||
12 | import sys | |
13 | ||
14 | if sys.platform == 'darwin': | |
15 | # set |match| to ignore build stderr output. | |
16 | test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) | |
17 | ||
18 | CHDIR = 'bundle-resources' | |
19 | test.run_gyp('test.gyp', chdir=CHDIR) | |
20 | ||
21 | test.build('test.gyp', test.ALL, chdir=CHDIR) | |
22 | ||
23 | test.built_file_must_match('resource.app/Contents/Resources/secret.txt', | |
24 | 'abc\n', chdir=CHDIR) | |
25 | test.built_file_must_match('source_rule.app/Contents/Resources/secret.txt', | |
26 | 'ABC\n', chdir=CHDIR) | |
27 | ||
28 | # TODO(thakis): This currently fails with make. | |
29 | if test.format != 'make': | |
30 | test.built_file_must_match( | |
31 | 'resource_rule.app/Contents/Resources/secret.txt', 'ABC\n', chdir=CHDIR) | |
32 | ||
33 | test.pass_test() |
10 | 10 | import TestGyp |
11 | 11 | |
12 | 12 | import os |
13 | import struct | |
13 | 14 | import sys |
14 | 15 | |
15 | 16 | if sys.platform == 'darwin': |
16 | 17 | test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) |
17 | 18 | |
18 | test.run_gyp('test.gyp', chdir='loadable-module') | |
19 | test.build('test.gyp', test.ALL, chdir='loadable-module') | |
19 | CHDIR = 'loadable-module' | |
20 | test.run_gyp('test.gyp', chdir=CHDIR) | |
21 | test.build('test.gyp', test.ALL, chdir=CHDIR) | |
20 | 22 | |
21 | 23 | # Binary. |
22 | test.built_file_must_exist( | |
24 | binary = test.built_file_path( | |
23 | 25 | 'test_loadable_module.plugin/Contents/MacOS/test_loadable_module', |
24 | chdir='loadable-module') | |
26 | chdir=CHDIR) | |
27 | test.must_exist(binary) | |
28 | MH_BUNDLE = 8 | |
29 | if struct.unpack('4I', open(binary, 'rb').read(16))[3] != MH_BUNDLE: | |
30 | test.fail_test() | |
25 | 31 | |
26 | 32 | # Info.plist. |
27 | 33 | info_plist = test.built_file_path( |
28 | 'test_loadable_module.plugin/Contents/Info.plist', | |
29 | chdir='loadable-module') | |
34 | 'test_loadable_module.plugin/Contents/Info.plist', chdir=CHDIR) | |
30 | 35 | test.must_exist(info_plist) |
31 | 36 | test.must_contain(info_plist, """ |
32 | 37 | <key>CFBundleExecutable</key> |
35 | 40 | |
36 | 41 | # PkgInfo. |
37 | 42 | test.built_file_must_not_exist( |
38 | 'test_loadable_module.plugin/Contents/PkgInfo', | |
39 | chdir='loadable-module') | |
43 | 'test_loadable_module.plugin/Contents/PkgInfo', chdir=CHDIR) | |
40 | 44 | test.built_file_must_not_exist( |
41 | 'test_loadable_module.plugin/Contents/Resources', | |
42 | chdir='loadable-module') | |
45 | 'test_loadable_module.plugin/Contents/Resources', chdir=CHDIR) | |
43 | 46 | |
44 | 47 | test.pass_test() |
31 | 31 | 'resource_bundle.bundle/Contents/MacOS/resource_bundle', |
32 | 32 | chdir='sourceless-module') |
33 | 33 | |
34 | # Build an app containing an actionless bundle. | |
35 | test.build( | |
36 | 'test.gyp', | |
37 | 'bundle_dependent_on_resource_bundle_no_actions', | |
38 | chdir='sourceless-module') | |
39 | ||
40 | test.built_file_must_exist( | |
41 | 'bundle_dependent_on_resource_bundle_no_actions.app/Contents/Resources/' | |
42 | 'mac_resource_bundle_no_actions.bundle/Contents/Resources/empty.txt', | |
43 | chdir='sourceless-module') | |
44 | ||
34 | 45 | # Needs to build and cause the bundle to be built. |
35 | 46 | test.build( |
36 | 47 | 'test.gyp', 'dependent_on_resource_bundle', chdir='sourceless-module') |
0 | #!/usr/bin/env python | |
1 | ||
2 | # Copyright 2013 Google Inc. All rights reserved. | |
3 | # Use of this source code is governed by a BSD-style license that can be | |
4 | # found in the LICENSE file. | |
5 | ||
6 | """ | |
7 | Verifies that unicode strings in 'xcode_settings' work. | |
8 | Also checks that ASCII control characters are escaped properly. | |
9 | """ | |
10 | ||
11 | import TestGyp | |
12 | ||
13 | import sys | |
14 | ||
15 | if sys.platform == 'darwin': | |
16 | test = TestGyp.TestGyp(formats=['xcode']) | |
17 | test.run_gyp('test.gyp', chdir='unicode-settings') | |
18 | test.build('test.gyp', test.ALL, chdir='unicode-settings') | |
19 | test.pass_test() |
68 | 68 | 'resource_framework', |
69 | 69 | ], |
70 | 70 | }, |
71 | ||
72 | { # No actions, but still have resources. | |
73 | 'target_name': 'mac_resource_bundle_no_actions', | |
74 | 'product_extension': 'bundle', | |
75 | 'type': 'executable', | |
76 | 'mac_bundle': 1, | |
77 | 'mac_bundle_resources': [ | |
78 | 'empty.txt', | |
79 | ], | |
80 | }, | |
81 | { | |
82 | 'target_name': 'bundle_dependent_on_resource_bundle_no_actions', | |
83 | 'type': 'executable', | |
84 | 'mac_bundle': 1, | |
85 | 'sources': [ 'empty.c' ], | |
86 | 'dependencies': [ | |
87 | 'mac_resource_bundle_no_actions', | |
88 | ], | |
89 | 'mac_bundle_resources': [ | |
90 | '<(PRODUCT_DIR)/mac_resource_bundle_no_actions.bundle', | |
91 | ], | |
92 | }, | |
71 | 93 | ], |
72 | 94 | } |
73 | 95 |
0 | # Copyright 2013 Google Inc. All rights reserved. | |
1 | # Use of this source code is governed by a BSD-style license that can be | |
2 | # found in the LICENSE file. | |
3 | ||
4 | { | |
5 | 'targets': [ | |
6 | { | |
7 | 'target_name': 'myapp', | |
8 | 'type': 'executable', | |
9 | 'mac_bundle': 1, | |
10 | 'sources': [ 'file.cc', ], | |
11 | 'xcode_settings': { | |
12 | 'BUNDLE_DISPLAY_NAME': 'α\011', | |
13 | }, | |
14 | 'postbuilds': [ | |
15 | { | |
16 | 'postbuild_name': 'envtest', | |
17 | 'action': [ './test_bundle_display_name.sh', ], | |
18 | }, | |
19 | ], | |
20 | }, | |
21 | ], | |
22 | } |
0 | #!/bin/bash | |
1 | ||
2 | # Copyright 2013 Google Inc. All rights reserved. | |
3 | # Use of this source code is governed by a BSD-style license that can be | |
4 | # found in the LICENSE file. | |
5 | ||
6 | test "${BUNDLE_DISPLAY_NAME}" = 'α ' |
26 | 26 | """ |
27 | 27 | if sys.platform == 'linux2': |
28 | 28 | link_expected = """ |
29 | LINK ?= flock $(builddir)/linker.lock $(abspath clang++) | |
29 | LINK ?= flock $(builddir)/linker.lock $(abspath clang) | |
30 | 30 | """ |
31 | 31 | elif sys.platform == 'darwin': |
32 | 32 | link_expected = """ |
33 | LINK ?= ./gyp-mac-tool flock $(builddir)/linker.lock $(abspath clang++) | |
33 | LINK ?= ./gyp-mac-tool flock $(builddir)/linker.lock $(abspath clang) | |
34 | 34 | """ |
35 | 35 | test.must_contain('Makefile', cc_expected) |
36 | 36 | test.must_contain('Makefile', link_expected) |
37 | 37 | if test.format == 'ninja': |
38 | 38 | cc_expected = 'cc = ' + os.path.join('..', '..', 'clang') |
39 | ld_expected = 'ld = $cxx' | |
39 | ld_expected = 'ld = $cc' | |
40 | 40 | if sys.platform == 'win32': |
41 | 41 | ld_expected = 'link.exe' |
42 | 42 | test.must_contain('out/Default/build.ninja', cc_expected) |
4 | 4 | { |
5 | 5 | 'make_global_settings': [ |
6 | 6 | ['CC', 'clang'], |
7 | ['LINK', 'clang++'], | |
7 | ['LINK', 'clang'], | |
8 | 8 | ], |
9 | 9 | 'targets': [ |
10 | 10 | { |
30 | 30 | os.path.join('..', '..', 'clang')) |
31 | 31 | cc_host_expected = ('cc_host = ' + os.path.join('..', '..', 'ccache') + ' ' + |
32 | 32 | os.path.join('..', '..', 'clang')) |
33 | ld_expected = 'ld = ../../distlink $cxx' | |
33 | ld_expected = 'ld = ../../distlink $cc' | |
34 | if sys.platform != 'win32': | |
35 | ldxx_expected = 'ldxx = ../../distlink $cxx' | |
36 | ||
34 | 37 | if sys.platform == 'win32': |
35 | 38 | ld_expected = 'link.exe' |
36 | 39 | test.must_contain('out/Default/build.ninja', cc_expected) |
37 | 40 | test.must_contain('out/Default/build.ninja', cc_host_expected) |
38 | 41 | test.must_contain('out/Default/build.ninja', ld_expected) |
42 | if sys.platform != 'win32': | |
43 | test.must_contain('out/Default/build.ninja', ldxx_expected) | |
39 | 44 | |
40 | 45 | test.pass_test() |
4 | 4 | { |
5 | 5 | 'make_global_settings': [ |
6 | 6 | ['CC', 'clang'], |
7 | ['LINK', 'clang++'], | |
8 | 7 | ['CC.host', 'clang'], |
9 | 8 | ], |
10 | 9 | 'targets': [ |
36 | 36 | os.path.join('..', '..', 'clang')) |
37 | 37 | cc_host_expected = ('cc_host = ' + os.path.join('..', '..', 'ccache') + ' ' + |
38 | 38 | os.path.join('..', '..', 'clang')) |
39 | ld_expected = 'ld = ../../distlink $cxx' | |
39 | ld_expected = 'ld = ../../distlink $cc' | |
40 | 40 | if sys.platform == 'win32': |
41 | 41 | ld_expected = 'link.exe' |
42 | 42 | test.must_contain('out/Default/build.ninja', cc_expected) |
35 | 35 | 'type': 'loadable_module', |
36 | 36 | 'product_name': 'lib1', |
37 | 37 | 'product_prefix': '', |
38 | 'xcode_settings': {'OTHER_LDFLAGS': ['-dynamiclib'], 'MACH_O_TYPE': ''}, | |
39 | 38 | 'sources': [ |
40 | 39 | 'lib1.c', |
41 | 40 | ], |
45 | 44 | 'product_name': 'lib2', |
46 | 45 | 'product_prefix': '', |
47 | 46 | 'type': 'loadable_module', |
48 | 'xcode_settings': {'OTHER_LDFLAGS': ['-dynamiclib'], 'MACH_O_TYPE': ''}, | |
49 | 47 | 'sources': [ |
50 | 48 | 'lib2.c', |
51 | 49 | ], |
0 | #!/usr/bin/env python | |
1 | ||
2 | # Copyright (c) 2012 Google Inc. All rights reserved. | |
3 | # Use of this source code is governed by a BSD-style license that can be | |
4 | # found in the LICENSE file. | |
5 | ||
6 | """ | |
7 | Checks that C-only targets aren't linked against libstdc++. | |
8 | """ | |
9 | ||
10 | import TestGyp | |
11 | ||
12 | import re | |
13 | import subprocess | |
14 | import sys | |
15 | ||
16 | # set |match| to ignore build stderr output. | |
17 | test = TestGyp.TestGyp(match = lambda a, b: True) | |
18 | if sys.platform != 'win32' and test.format not in ('make', 'android'): | |
19 | # TODO: This doesn't pass with make. | |
20 | # TODO: Does a test like this make sense with Windows? Android? | |
21 | ||
22 | CHDIR = 'src' | |
23 | test.run_gyp('test.gyp', chdir=CHDIR) | |
24 | test.build('test.gyp', 'no_cpp', chdir=CHDIR) | |
25 | ||
26 | def LinksLibStdCpp(path): | |
27 | path = test.built_file_path(path, chdir=CHDIR) | |
28 | if sys.platform == 'darwin': | |
29 | proc = subprocess.Popen(['otool', '-L', path], stdout=subprocess.PIPE) | |
30 | else: | |
31 | proc = subprocess.Popen(['ldd', path], stdout=subprocess.PIPE) | |
32 | output = proc.communicate()[0] | |
33 | assert not proc.returncode | |
34 | return 'libstdc++' in output or 'libc++' in output | |
35 | ||
36 | if LinksLibStdCpp('no_cpp'): | |
37 | test.fail_test() | |
38 | ||
39 | build_error_code = { | |
40 | 'xcode': [1, 65], # 1 for xcode 3, 65 for xcode 4 (see `man sysexits`) | |
41 | 'make': 2, | |
42 | 'ninja': 1, | |
43 | }[test.format] | |
44 | ||
45 | test.build('test.gyp', 'no_cpp_dep_on_cc_lib', chdir=CHDIR, | |
46 | status=build_error_code) | |
47 | ||
48 | test.pass_test() |
0 | int main() {} |
0 | # Copyright (c) 2013 Google Inc. All rights reserved. | |
1 | # Use of this source code is governed by a BSD-style license that can be | |
2 | # found in the LICENSE file. | |
3 | { | |
4 | 'targets': [ | |
5 | { | |
6 | 'target_name': 'no_cpp', | |
7 | 'type': 'executable', | |
8 | 'sources': [ 'empty-main.c' ], | |
9 | }, | |
10 | # A static_library with a cpp file and a linkable with only .c files | |
11 | # depending on it causes a linker error: | |
12 | { | |
13 | 'target_name': 'cpp_lib', | |
14 | 'type': 'static_library', | |
15 | 'sources': [ 'f.cc' ], | |
16 | }, | |
17 | { | |
18 | 'target_name': 'no_cpp_dep_on_cc_lib', | |
19 | 'type': 'executable', | |
20 | 'dependencies': [ 'cpp_lib' ], | |
21 | 'sources': [ 'call-f-main.c' ], | |
22 | }, | |
23 | ], | |
24 | } |