Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. 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 # Define the sysroot directory. | 5 # Define the sysroot directory. |
| 6 sysroot = "$root_out_dir/sysroot" | 6 sysroot = "$root_out_dir/sysroot" |
| 7 | 7 |
| 8 config("fusl_config") { | 8 config("fusl_config") { |
| 9 cflags = [ | 9 cflags = [ |
| 10 # Flags from musl | 10 # Flags from musl |
| (...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1623 ] | 1623 ] |
| 1624 | 1624 |
| 1625 args = [ | 1625 args = [ |
| 1626 rebase_path(clang), | 1626 rebase_path(clang), |
| 1627 rebase_path(target), | 1627 rebase_path(target), |
| 1628 ] | 1628 ] |
| 1629 args += files | 1629 args += files |
| 1630 | 1630 |
| 1631 outputs = [ | 1631 outputs = [ |
| 1632 "$target/crtbegin.o", | 1632 "$target/crtbegin.o", |
| 1633 "$target/crtbeginSo.o", | 1633 "$target/crtbeginS.o", |
| 1634 "$target/crtbeginT.o", | 1634 "$target/crtbeginT.o", |
| 1635 "$target/crtend.o", | 1635 "$target/crtend.o", |
| 1636 "$target/crtendS.o", | 1636 "$target/crtendS.o", |
| 1637 | 1637 |
| 1638 "$target/libgcc.a", | 1638 "$target/libgcc.a", |
| 1639 "$target/libgcc_eh.a", | 1639 "$target/libgcc_eh.a", |
| 1640 "$target/libgcc_s.so", | 1640 "$target/libgcc_s.so", |
| 1641 ] | 1641 ] |
| 1642 | 1642 |
| 1643 deps = [ | 1643 deps = [ |
| 1644 ":copy_sysroot", | 1644 ":copy_sysroot", |
| 1645 ] | 1645 ] |
| 1646 } | 1646 } |
| 1647 | 1647 |
| 1648 config("sysroot_config") { | 1648 copy("copy_libcxx") { |
| 1649 sources = [ | |
| 1650 "${target_out_dir}/../third_party/libcxx/libcxx.a", | |
| 1651 ] | |
| 1652 outputs = [ | |
| 1653 "${sysroot_lib_dir}/libc++.a", | |
| 1654 ] | |
| 1655 deps = [ | |
| 1656 "//third_party/libcxx:libcxx", | |
| 1657 ] | |
| 1658 } | |
| 1659 | |
| 1660 action("copy_libcxx_headers") { | |
| 1661 script = "tools/copy_libcxx_headers.py" | |
| 1662 | |
| 1663 deps = [ | |
| 1664 ":copy_sysroot", | |
| 1665 ] | |
| 1666 | |
| 1667 source_dir = "//third_party/libcxx/libcxx/include" | |
| 1668 | |
| 1669 # Annoyingly, this has to be ".../c++/v1" for clang to automatically | |
| 1670 # add it to the includes. | |
| 1671 target_dir = "${sysroot_include_dir}/c++/v1" | |
| 1672 | |
| 1673 args = [ | |
| 1674 rebase_path(source_dir), | |
| 1675 rebase_path(target_dir), | |
| 1676 ] | |
| 1677 | |
| 1678 outputs = [ | |
| 1679 "${target_dir}/__bit_reference", | |
| 1680 "${target_dir}/__config", | |
| 1681 "${target_dir}/__config_site.in", | |
| 1682 "${target_dir}/__debug", | |
| 1683 "${target_dir}/__functional_03", | |
| 1684 "${target_dir}/__functional_base", | |
| 1685 "${target_dir}/__functional_base_03", | |
| 1686 "${target_dir}/__hash_table", | |
| 1687 "${target_dir}/__locale", | |
| 1688 "${target_dir}/__mutex_base", | |
| 1689 "${target_dir}/__nullptr", | |
| 1690 "${target_dir}/__refstring", | |
| 1691 "${target_dir}/__split_buffer", | |
| 1692 "${target_dir}/__sso_allocator", | |
| 1693 "${target_dir}/__std_stream", | |
| 1694 "${target_dir}/__tree", | |
| 1695 "${target_dir}/__tuple", | |
| 1696 "${target_dir}/__undef___deallocate", | |
| 1697 "${target_dir}/__undef_min_max", | |
| 1698 "${target_dir}/algorithm", | |
| 1699 "${target_dir}/array", | |
| 1700 "${target_dir}/atomic", | |
| 1701 "${target_dir}/bitset", | |
| 1702 "${target_dir}/cassert", | |
| 1703 "${target_dir}/ccomplex", | |
| 1704 "${target_dir}/cctype", | |
| 1705 "${target_dir}/cerrno", | |
| 1706 "${target_dir}/cfenv", | |
| 1707 "${target_dir}/cfloat", | |
| 1708 "${target_dir}/chrono", | |
| 1709 "${target_dir}/cinttypes", | |
| 1710 "${target_dir}/ciso646", | |
| 1711 "${target_dir}/climits", | |
| 1712 "${target_dir}/clocale", | |
| 1713 "${target_dir}/cmath", | |
| 1714 "${target_dir}/codecvt", | |
| 1715 "${target_dir}/complex", | |
| 1716 "${target_dir}/complex.h", | |
| 1717 "${target_dir}/condition_variable", | |
| 1718 "${target_dir}/csetjmp", | |
| 1719 "${target_dir}/csignal", | |
| 1720 "${target_dir}/cstdarg", | |
| 1721 "${target_dir}/cstdbool", | |
| 1722 "${target_dir}/cstddef", | |
| 1723 "${target_dir}/cstdint", | |
| 1724 "${target_dir}/cstdio", | |
| 1725 "${target_dir}/cstdlib", | |
| 1726 "${target_dir}/cstring", | |
| 1727 "${target_dir}/ctgmath", | |
| 1728 "${target_dir}/ctime", | |
| 1729 "${target_dir}/ctype.h", | |
| 1730 "${target_dir}/cwchar", | |
| 1731 "${target_dir}/cwctype", | |
| 1732 "${target_dir}/deque", | |
| 1733 "${target_dir}/errno.h", | |
| 1734 "${target_dir}/exception", | |
| 1735 "${target_dir}/experimental/__config", | |
| 1736 "${target_dir}/experimental/algorithm", | |
| 1737 "${target_dir}/experimental/any", | |
| 1738 "${target_dir}/experimental/chrono", | |
| 1739 "${target_dir}/experimental/dynarray", | |
| 1740 "${target_dir}/experimental/functional", | |
| 1741 "${target_dir}/experimental/optional", | |
| 1742 "${target_dir}/experimental/ratio", | |
| 1743 "${target_dir}/experimental/string_view", | |
| 1744 "${target_dir}/experimental/system_error", | |
| 1745 "${target_dir}/experimental/tuple", | |
| 1746 "${target_dir}/experimental/type_traits", | |
| 1747 "${target_dir}/experimental/utility", | |
| 1748 "${target_dir}/ext/__hash", | |
| 1749 "${target_dir}/ext/hash_map", | |
| 1750 "${target_dir}/ext/hash_set", | |
| 1751 "${target_dir}/float.h", | |
| 1752 "${target_dir}/forward_list", | |
| 1753 "${target_dir}/fstream", | |
| 1754 "${target_dir}/functional", | |
| 1755 "${target_dir}/future", | |
| 1756 "${target_dir}/initializer_list", | |
| 1757 "${target_dir}/inttypes.h", | |
| 1758 "${target_dir}/iomanip", | |
| 1759 "${target_dir}/ios", | |
| 1760 "${target_dir}/iosfwd", | |
| 1761 "${target_dir}/iostream", | |
| 1762 "${target_dir}/istream", | |
| 1763 "${target_dir}/iterator", | |
| 1764 "${target_dir}/limits", | |
| 1765 "${target_dir}/list", | |
| 1766 "${target_dir}/locale", | |
| 1767 "${target_dir}/map", | |
| 1768 "${target_dir}/math.h", | |
| 1769 "${target_dir}/memory", | |
| 1770 "${target_dir}/module.modulemap", | |
| 1771 "${target_dir}/mutex", | |
| 1772 "${target_dir}/new", | |
| 1773 "${target_dir}/numeric", | |
| 1774 "${target_dir}/ostream", | |
| 1775 "${target_dir}/queue", | |
| 1776 "${target_dir}/random", | |
| 1777 "${target_dir}/ratio", | |
| 1778 "${target_dir}/regex", | |
| 1779 "${target_dir}/scoped_allocator", | |
| 1780 "${target_dir}/set", | |
| 1781 "${target_dir}/setjmp.h", | |
| 1782 "${target_dir}/shared_mutex", | |
| 1783 "${target_dir}/sstream", | |
| 1784 "${target_dir}/stack", | |
| 1785 "${target_dir}/stddef.h", | |
| 1786 "${target_dir}/stdexcept", | |
| 1787 "${target_dir}/stdio.h", | |
| 1788 "${target_dir}/stdlib.h", | |
| 1789 "${target_dir}/streambuf", | |
| 1790 "${target_dir}/string", | |
| 1791 "${target_dir}/strstream", | |
| 1792 "${target_dir}/support/android/locale_bionic.h", | |
| 1793 "${target_dir}/support/ibm/limits.h", | |
| 1794 "${target_dir}/support/ibm/support.h", | |
| 1795 "${target_dir}/support/ibm/xlocale.h", | |
| 1796 "${target_dir}/support/musl/xlocale.h", | |
| 1797 "${target_dir}/support/newlib/xlocale.h", | |
| 1798 "${target_dir}/support/solaris/floatingpoint.h", | |
| 1799 "${target_dir}/support/solaris/wchar.h", | |
| 1800 "${target_dir}/support/solaris/xlocale.h", | |
| 1801 "${target_dir}/support/win32/limits_win32.h", | |
| 1802 "${target_dir}/support/win32/locale_win32.h", | |
| 1803 "${target_dir}/support/win32/math_win32.h", | |
| 1804 "${target_dir}/support/win32/support.h", | |
| 1805 "${target_dir}/support/xlocale/xlocale.h", | |
| 1806 "${target_dir}/system_error", | |
| 1807 "${target_dir}/tgmath.h", | |
| 1808 "${target_dir}/thread", | |
| 1809 "${target_dir}/tuple", | |
| 1810 "${target_dir}/type_traits", | |
| 1811 "${target_dir}/typeindex", | |
| 1812 "${target_dir}/typeinfo", | |
| 1813 "${target_dir}/unordered_map", | |
| 1814 "${target_dir}/unordered_set", | |
| 1815 "${target_dir}/utility", | |
| 1816 "${target_dir}/valarray", | |
| 1817 "${target_dir}/vector", | |
| 1818 "${target_dir}/wchar.h", | |
| 1819 "${target_dir}/wctype.h", | |
| 1820 ] | |
| 1821 } | |
| 1822 | |
| 1823 config("fusl_sysroot_config") { | |
| 1649 rebased_sysroot = rebase_path(sysroot) | 1824 rebased_sysroot = rebase_path(sysroot) |
| 1650 | 1825 |
| 1651 cflags = [ | 1826 cflags = [ |
| 1652 "--sysroot=$rebased_sysroot", | 1827 "--sysroot=$rebased_sysroot", |
| 1653 "-fPIC", | 1828 "-fPIC", |
| 1654 "-static", | 1829 "-static", |
| 1655 ] | 1830 ] |
| 1656 | 1831 |
| 1832 cflags_c = [ "-std=c11" ] | |
| 1833 | |
| 1834 cflags_cc = [ | |
| 1835 "-std=c++11", | |
| 1836 | |
| 1837 # Make everyone using our libc++ headers use musl paths rather | |
| 1838 # than glibc ones. | |
| 1839 "-D_LIBCPP_HAS_MUSL_LIBC", | |
| 1840 | |
| 1841 # This is necessary for clang to get the header search paths right. | |
| 1842 "-stdlib=libc++", | |
| 1843 ] | |
| 1844 | |
| 1657 ldflags = [ | 1845 ldflags = [ |
| 1658 "--sysroot=$rebased_sysroot", | 1846 "--sysroot=$rebased_sysroot", |
| 1659 "-static", | 1847 "-static", |
| 1848 "-stdlib=libc++", | |
| 1849 ] | |
| 1850 } | |
| 1851 | |
| 1852 config("fusl_sysroot_config_c") { | |
| 1853 ldflags = [ | |
| 1854 # Using clang++ as the linker driver is necessary for libc++ | |
| 1855 # resolution to work. | |
| 1856 "-nodefaultlibs", | |
|
kulakowski
2016/02/08 21:14:26
So gn really wasn't built to create C executables,
| |
| 1857 "-lc", | |
| 1660 ] | 1858 ] |
| 1661 } | 1859 } |
| 1662 | 1860 |
| 1663 executable("empty_main") { | 1861 executable("empty_main") { |
| 1664 configs = [] | 1862 configs = [] |
| 1665 configs += [ ":sysroot_config" ] | 1863 configs += [ |
| 1864 ":fusl_sysroot_config", | |
| 1865 ":fusl_sysroot_config_c", | |
| 1866 ] | |
| 1666 | 1867 |
| 1667 sources = [ | 1868 sources = [ |
| 1668 "test/empty_main.c", | 1869 "test/empty_main.c", |
| 1669 ] | 1870 ] |
| 1670 | 1871 |
| 1671 deps = [ | 1872 deps = [ |
| 1672 ":finish_sysroot", | 1873 ":finish_sysroot", |
| 1673 ] | 1874 ] |
| 1674 } | 1875 } |
| 1675 | 1876 |
| 1877 executable("vector") { | |
| 1878 configs = [] | |
| 1879 configs += [ ":fusl_sysroot_config" ] | |
| 1880 | |
| 1881 sources = [ | |
| 1882 "test/vector.cc", | |
| 1883 ] | |
| 1884 | |
| 1885 deps = [ | |
| 1886 ":copy_libcxx", | |
| 1887 ":copy_libcxx_headers", | |
| 1888 ] | |
| 1889 } | |
| 1890 | |
| 1891 group("fusl_pre_toolchain") { | |
| 1892 deps = [ | |
| 1893 ":crt", | |
| 1894 ":empty_main", | |
| 1895 ":finish_sysroot", | |
| 1896 ":libc", | |
| 1897 ":vector", | |
| 1898 "//third_party/libcxx:libcxx", | |
| 1899 ] | |
| 1900 } | |
| 1901 | |
| 1676 group("fusl") { | 1902 group("fusl") { |
| 1677 deps = [ | 1903 deps = [ |
| 1678 ":crt(//build/toolchain/fusl:fusl_$current_cpu)", | 1904 ":fusl_pre_toolchain(//build/toolchain/fusl:fusl_$current_cpu)", |
| 1679 ":empty_main(//build/toolchain/fusl:fusl_$current_cpu)", | |
| 1680 ":finish_sysroot(//build/toolchain/fusl:fusl_$current_cpu)", | |
| 1681 ":libc(//build/toolchain/fusl:fusl_$current_cpu)", | |
| 1682 ] | 1905 ] |
| 1683 } | 1906 } |
| OLD | NEW |