Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2013 Google Inc. All rights reserved. | 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 | 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 import collections | 5 import collections |
| 6 import copy | 6 import copy |
| 7 import hashlib | 7 import hashlib |
| 8 import json | 8 import json |
| 9 import multiprocessing | 9 import multiprocessing |
| 10 import os.path | 10 import os.path |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 798 | 798 |
| 799 def WriteSources(self, ninja_file, config_name, config, sources, predepends, | 799 def WriteSources(self, ninja_file, config_name, config, sources, predepends, |
| 800 precompiled_header, spec): | 800 precompiled_header, spec): |
| 801 """Write build rules to compile all of |sources|.""" | 801 """Write build rules to compile all of |sources|.""" |
| 802 if self.toolset == 'host': | 802 if self.toolset == 'host': |
| 803 self.ninja.variable('ar', '$ar_host') | 803 self.ninja.variable('ar', '$ar_host') |
| 804 self.ninja.variable('cc', '$cc_host') | 804 self.ninja.variable('cc', '$cc_host') |
| 805 self.ninja.variable('cxx', '$cxx_host') | 805 self.ninja.variable('cxx', '$cxx_host') |
| 806 self.ninja.variable('ld', '$ld_host') | 806 self.ninja.variable('ld', '$ld_host') |
| 807 self.ninja.variable('ldxx', '$ldxx_host') | 807 self.ninja.variable('ldxx', '$ldxx_host') |
| 808 self.ninja.variable('nm', '$nm_host') | |
| 809 self.ninja.variable('readelf', '$readelf_host') | |
| 808 | 810 |
| 809 if self.flavor != 'mac' or len(self.archs) == 1: | 811 if self.flavor != 'mac' or len(self.archs) == 1: |
| 810 return self.WriteSourcesForArch( | 812 return self.WriteSourcesForArch( |
| 811 self.ninja, config_name, config, sources, predepends, | 813 self.ninja, config_name, config, sources, predepends, |
| 812 precompiled_header, spec) | 814 precompiled_header, spec) |
| 813 else: | 815 else: |
| 814 return dict((arch, self.WriteSourcesForArch( | 816 return dict((arch, self.WriteSourcesForArch( |
| 815 self.arch_subninjas[arch], config_name, config, sources, predepends, | 817 self.arch_subninjas[arch], config_name, config, sources, predepends, |
| 816 precompiled_header, spec, arch=arch)) | 818 precompiled_header, spec, arch=arch)) |
| 817 for arch in self.archs) | 819 for arch in self.archs) |
| (...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1735 ldxx = '$cxx' | 1737 ldxx = '$cxx' |
| 1736 ld_host = '$cc_host' | 1738 ld_host = '$cc_host' |
| 1737 ldxx_host = '$cxx_host' | 1739 ldxx_host = '$cxx_host' |
| 1738 | 1740 |
| 1739 ar_host = 'ar' | 1741 ar_host = 'ar' |
| 1740 cc_host = None | 1742 cc_host = None |
| 1741 cxx_host = None | 1743 cxx_host = None |
| 1742 cc_host_global_setting = None | 1744 cc_host_global_setting = None |
| 1743 cxx_host_global_setting = None | 1745 cxx_host_global_setting = None |
| 1744 clang_cl = None | 1746 clang_cl = None |
| 1747 nm = 'nm' | |
| 1748 nm_host = 'nm' | |
| 1749 readelf = 'readelf' | |
| 1750 readelf_host = 'readelf' | |
| 1745 | 1751 |
| 1746 build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) | 1752 build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) |
| 1747 make_global_settings = data[build_file].get('make_global_settings', []) | 1753 make_global_settings = data[build_file].get('make_global_settings', []) |
| 1748 build_to_root = gyp.common.InvertRelativePath(build_dir, | 1754 build_to_root = gyp.common.InvertRelativePath(build_dir, |
| 1749 options.toplevel_dir) | 1755 options.toplevel_dir) |
| 1750 wrappers = {} | 1756 wrappers = {} |
| 1751 for key, value in make_global_settings: | 1757 for key, value in make_global_settings: |
| 1752 if key == 'AR': | 1758 if key == 'AR': |
| 1753 ar = os.path.join(build_to_root, value) | 1759 ar = os.path.join(build_to_root, value) |
| 1754 if key == 'AR.host': | 1760 if key == 'AR.host': |
| 1755 ar_host = os.path.join(build_to_root, value) | 1761 ar_host = os.path.join(build_to_root, value) |
| 1756 if key == 'CC': | 1762 if key == 'CC': |
| 1757 cc = os.path.join(build_to_root, value) | 1763 cc = os.path.join(build_to_root, value) |
| 1758 if cc.endswith('clang-cl'): | 1764 if cc.endswith('clang-cl'): |
| 1759 clang_cl = cc | 1765 clang_cl = cc |
| 1760 if key == 'CXX': | 1766 if key == 'CXX': |
| 1761 cxx = os.path.join(build_to_root, value) | 1767 cxx = os.path.join(build_to_root, value) |
| 1762 if key == 'CC.host': | 1768 if key == 'CC.host': |
| 1763 cc_host = os.path.join(build_to_root, value) | 1769 cc_host = os.path.join(build_to_root, value) |
| 1764 cc_host_global_setting = value | 1770 cc_host_global_setting = value |
| 1765 if key == 'CXX.host': | 1771 if key == 'CXX.host': |
| 1766 cxx_host = os.path.join(build_to_root, value) | 1772 cxx_host = os.path.join(build_to_root, value) |
| 1767 cxx_host_global_setting = value | 1773 cxx_host_global_setting = value |
| 1768 if key == 'LD': | 1774 if key == 'LD': |
| 1769 ld = os.path.join(build_to_root, value) | 1775 ld = os.path.join(build_to_root, value) |
| 1770 if key == 'LD.host': | 1776 if key == 'LD.host': |
| 1771 ld_host = os.path.join(build_to_root, value) | 1777 ld_host = os.path.join(build_to_root, value) |
| 1778 if key == 'NM': | |
| 1779 nm = os.path.join(build_to_root, value) | |
| 1780 if key == 'NM.host': | |
| 1781 nm_host = os.path.join(build_to_root, value) | |
| 1782 if key == 'READELF': | |
| 1783 readelf = os.path.join(build_to_root, value) | |
| 1784 if key == 'READELF.host': | |
| 1785 readelf_host = os.path.join(build_to_root, value) | |
| 1772 if key.endswith('_wrapper'): | 1786 if key.endswith('_wrapper'): |
| 1773 wrappers[key[:-len('_wrapper')]] = os.path.join(build_to_root, value) | 1787 wrappers[key[:-len('_wrapper')]] = os.path.join(build_to_root, value) |
| 1774 | 1788 |
| 1775 # Support wrappers from environment variables too. | 1789 # Support wrappers from environment variables too. |
| 1776 for key, value in os.environ.iteritems(): | 1790 for key, value in os.environ.iteritems(): |
| 1777 if key.lower().endswith('_wrapper'): | 1791 if key.lower().endswith('_wrapper'): |
| 1778 key_prefix = key[:-len('_wrapper')] | 1792 key_prefix = key[:-len('_wrapper')] |
| 1779 key_prefix = re.sub(r'\.HOST$', '.host', key_prefix) | 1793 key_prefix = re.sub(r'\.HOST$', '.host', key_prefix) |
| 1780 wrappers[key_prefix] = os.path.join(build_to_root, value) | 1794 wrappers[key_prefix] = os.path.join(build_to_root, value) |
| 1781 | 1795 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 1809 master_ninja.variable('ld', ld) | 1823 master_ninja.variable('ld', ld) |
| 1810 master_ninja.variable('idl', 'midl.exe') | 1824 master_ninja.variable('idl', 'midl.exe') |
| 1811 master_ninja.variable('ar', ar) | 1825 master_ninja.variable('ar', ar) |
| 1812 master_ninja.variable('rc', 'rc.exe') | 1826 master_ninja.variable('rc', 'rc.exe') |
| 1813 master_ninja.variable('asm', 'ml.exe') | 1827 master_ninja.variable('asm', 'ml.exe') |
| 1814 master_ninja.variable('mt', 'mt.exe') | 1828 master_ninja.variable('mt', 'mt.exe') |
| 1815 else: | 1829 else: |
| 1816 master_ninja.variable('ld', CommandWithWrapper('LINK', wrappers, ld)) | 1830 master_ninja.variable('ld', CommandWithWrapper('LINK', wrappers, ld)) |
| 1817 master_ninja.variable('ldxx', CommandWithWrapper('LINK', wrappers, ldxx)) | 1831 master_ninja.variable('ldxx', CommandWithWrapper('LINK', wrappers, ldxx)) |
| 1818 master_ninja.variable('ar', GetEnvironFallback(['AR_target', 'AR'], ar)) | 1832 master_ninja.variable('ar', GetEnvironFallback(['AR_target', 'AR'], ar)) |
| 1833 if flavor != 'mac': | |
| 1834 # Mac does not use readelf/nm for .TOC generation, so avoiding polluting | |
| 1835 # the master ninja with extra unused variables. | |
| 1836 master_ninja.variable( | |
| 1837 'nm', GetEnvironFallback(['NM_target', 'NM'], nm)) | |
| 1838 master_ninja.variable( | |
| 1839 'readelf', GetEnvironFallback(['READELF_target', 'READELF'], readelf)) | |
| 1819 | 1840 |
| 1820 if generator_supports_multiple_toolsets: | 1841 if generator_supports_multiple_toolsets: |
| 1821 if not cc_host: | 1842 if not cc_host: |
| 1822 cc_host = cc | 1843 cc_host = cc |
| 1823 if not cxx_host: | 1844 if not cxx_host: |
| 1824 cxx_host = cxx | 1845 cxx_host = cxx |
| 1825 | 1846 |
| 1826 master_ninja.variable('ar_host', GetEnvironFallback(['AR_host'], ar_host)) | 1847 master_ninja.variable('ar_host', GetEnvironFallback(['AR_host'], ar_host)) |
| 1848 master_ninja.variable('nm_host', GetEnvironFallback(['NM_host'], nm_host)) | |
| 1849 master_ninja.variable('readelf_host', | |
| 1850 GetEnvironFallback(['READELF_host'], readelf_host)) | |
| 1827 cc_host = GetEnvironFallback(['CC_host'], cc_host) | 1851 cc_host = GetEnvironFallback(['CC_host'], cc_host) |
| 1828 cxx_host = GetEnvironFallback(['CXX_host'], cxx_host) | 1852 cxx_host = GetEnvironFallback(['CXX_host'], cxx_host) |
| 1829 | 1853 |
| 1830 # The environment variable could be used in 'make_global_settings', like | 1854 # The environment variable could be used in 'make_global_settings', like |
| 1831 # ['CC.host', '$(CC)'] or ['CXX.host', '$(CXX)'], transform them here. | 1855 # ['CC.host', '$(CC)'] or ['CXX.host', '$(CXX)'], transform them here. |
| 1832 if '$(CC)' in cc_host and cc_host_global_setting: | 1856 if '$(CC)' in cc_host and cc_host_global_setting: |
| 1833 cc_host = cc_host_global_setting.replace('$(CC)', cc) | 1857 cc_host = cc_host_global_setting.replace('$(CC)', cc) |
| 1834 if '$(CXX)' in cxx_host and cxx_host_global_setting: | 1858 if '$(CXX)' in cxx_host and cxx_host_global_setting: |
| 1835 cxx_host = cxx_host_global_setting.replace('$(CXX)', cxx) | 1859 cxx_host = cxx_host_global_setting.replace('$(CXX)', cxx) |
| 1836 master_ninja.variable('cc_host', | 1860 master_ninja.variable('cc_host', |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1914 command=('%s gyp-win-tool rc-wrapper ' | 1938 command=('%s gyp-win-tool rc-wrapper ' |
| 1915 '$arch $rc $defines $resource_includes $rcflags /fo$out $in' % | 1939 '$arch $rc $defines $resource_includes $rcflags /fo$out $in' % |
| 1916 sys.executable)) | 1940 sys.executable)) |
| 1917 master_ninja.rule( | 1941 master_ninja.rule( |
| 1918 'asm', | 1942 'asm', |
| 1919 description='ASM $out', | 1943 description='ASM $out', |
| 1920 command=('%s gyp-win-tool asm-wrapper ' | 1944 command=('%s gyp-win-tool asm-wrapper ' |
| 1921 '$arch $asm $defines $includes $asmflags /c /Fo $out $in' % | 1945 '$arch $asm $defines $includes $asmflags /c /Fo $out $in' % |
| 1922 sys.executable)) | 1946 sys.executable)) |
| 1923 | 1947 |
| 1924 if flavor != 'mac' and flavor != 'win': | 1948 if flavor != 'mac' and flavor != 'win': |
|
yukawa
2014/08/27 22:54:39
Nico, I have a question here.
Do you think we nee
Nico
2014/08/27 22:59:49
You can say GYP_GENERATORS=ninja-android and then
| |
| 1925 master_ninja.rule( | 1949 master_ninja.rule( |
| 1926 'alink', | 1950 'alink', |
| 1927 description='AR $out', | 1951 description='AR $out', |
| 1928 command='rm -f $out && $ar rcs $out $in') | 1952 command='rm -f $out && $ar rcs $out $in') |
| 1929 master_ninja.rule( | 1953 master_ninja.rule( |
| 1930 'alink_thin', | 1954 'alink_thin', |
| 1931 description='AR $out', | 1955 description='AR $out', |
| 1932 command='rm -f $out && $ar rcsT $out $in') | 1956 command='rm -f $out && $ar rcsT $out $in') |
| 1933 | 1957 |
| 1934 # This allows targets that only need to depend on $lib's API to declare an | 1958 # This allows targets that only need to depend on $lib's API to declare an |
| 1935 # order-only dependency on $lib.TOC and avoid relinking such downstream | 1959 # order-only dependency on $lib.TOC and avoid relinking such downstream |
| 1936 # dependencies when $lib changes only in non-public ways. | 1960 # dependencies when $lib changes only in non-public ways. |
| 1937 # The resulting string leaves an uninterpolated %{suffix} which | 1961 # The resulting string leaves an uninterpolated %{suffix} which |
| 1938 # is used in the final substitution below. | 1962 # is used in the final substitution below. |
| 1939 mtime_preserving_solink_base = ( | 1963 mtime_preserving_solink_base = ( |
| 1940 'if [ ! -e $lib -o ! -e $lib.TOC ]; then ' | 1964 'if [ ! -e $lib -o ! -e $lib.TOC ]; then ' |
| 1941 '%(solink)s && %(extract_toc)s > $lib.TOC; else ' | 1965 '%(solink)s && %(extract_toc)s > $lib.TOC; else ' |
| 1942 '%(solink)s && %(extract_toc)s > $lib.tmp && ' | 1966 '%(solink)s && %(extract_toc)s > $lib.tmp && ' |
| 1943 'if ! cmp -s $lib.tmp $lib.TOC; then mv $lib.tmp $lib.TOC ; ' | 1967 'if ! cmp -s $lib.tmp $lib.TOC; then mv $lib.tmp $lib.TOC ; ' |
| 1944 'fi; fi' | 1968 'fi; fi' |
| 1945 % { 'solink': | 1969 % { 'solink': |
| 1946 '$ld -shared $ldflags -o $lib -Wl,-soname=$soname %(suffix)s', | 1970 '$ld -shared $ldflags -o $lib -Wl,-soname=$soname %(suffix)s', |
| 1947 'extract_toc': | 1971 'extract_toc': |
| 1948 ('{ readelf -d $lib | grep SONAME ; ' | 1972 ('{ $readelf -d $lib | grep SONAME ; ' |
| 1949 'nm -gD -f p $lib | cut -f1-2 -d\' \'; }')}) | 1973 '$nm -gD -f p $lib | cut -f1-2 -d\' \'; }')}) |
| 1950 | 1974 |
| 1951 master_ninja.rule( | 1975 master_ninja.rule( |
| 1952 'solink', | 1976 'solink', |
| 1953 description='SOLINK $lib', | 1977 description='SOLINK $lib', |
| 1954 restat=True, | 1978 restat=True, |
| 1955 command=mtime_preserving_solink_base % {'suffix': '@$link_file_list'}, | 1979 command=mtime_preserving_solink_base % {'suffix': '@$link_file_list'}, |
| 1956 rspfile='$link_file_list', | 1980 rspfile='$link_file_list', |
| 1957 rspfile_content= | 1981 rspfile_content= |
| 1958 '-Wl,--whole-archive $in $solibs -Wl,--no-whole-archive $libs', | 1982 '-Wl,--whole-archive $in $solibs -Wl,--no-whole-archive $libs', |
| 1959 pool='link_pool') | 1983 pool='link_pool') |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2230 arglists.append( | 2254 arglists.append( |
| 2231 (target_list, target_dicts, data, params, config_name)) | 2255 (target_list, target_dicts, data, params, config_name)) |
| 2232 pool.map(CallGenerateOutputForConfig, arglists) | 2256 pool.map(CallGenerateOutputForConfig, arglists) |
| 2233 except KeyboardInterrupt, e: | 2257 except KeyboardInterrupt, e: |
| 2234 pool.terminate() | 2258 pool.terminate() |
| 2235 raise e | 2259 raise e |
| 2236 else: | 2260 else: |
| 2237 for config_name in config_names: | 2261 for config_name in config_names: |
| 2238 GenerateOutputForConfig(target_list, target_dicts, data, params, | 2262 GenerateOutputForConfig(target_list, target_dicts, data, params, |
| 2239 config_name) | 2263 config_name) |
| OLD | NEW |