OLD | NEW |
1 # Copyright 2016 Google Inc. | 1 # Copyright 2016 Google Inc. |
2 # | 2 # |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # It's best to keep the names and defaults of is_foo flags consistent with Chrom
e. | 6 # It's best to keep the names and defaults of is_foo flags consistent with Chrom
e. |
7 | 7 |
8 declare_args() { | 8 declare_args() { |
9 is_debug = true | 9 is_debug = true |
10 is_component_build = false | 10 is_component_build = false |
11 ndk = "" | 11 ndk = "" |
12 } | 12 } |
13 | 13 |
14 # Platform detection | 14 # Platform detection |
15 if (target_os == "") { | 15 if (target_os == "") { |
16 target_os = host_os | 16 target_os = host_os |
17 if (ndk != "") { | 17 if (ndk != "") { |
18 target_os = "android" | 18 target_os = "android" |
19 } | 19 } |
20 } | 20 } |
21 if (current_os == "") { | 21 if (current_os == "") { |
22 current_os = target_os | 22 current_os = target_os |
23 } | 23 } |
24 | 24 |
| 25 is_android = current_os == "android" |
| 26 is_fuchsia = current_os == "fuchsia" |
| 27 is_ios = current_os == "ios" |
| 28 is_linux = current_os == "linux" |
| 29 is_mac = current_os == "mac" |
| 30 is_win = current_os == "win" |
| 31 |
25 if (target_cpu == "") { | 32 if (target_cpu == "") { |
26 target_cpu = host_cpu | 33 target_cpu = host_cpu |
27 if (ndk != "") { | 34 if (is_android) { |
28 target_cpu = "arm64" | 35 target_cpu = "arm64" |
29 } | 36 } |
30 } | 37 } |
31 if (current_cpu == "") { | 38 if (current_cpu == "") { |
32 current_cpu = target_cpu | 39 current_cpu = target_cpu |
33 } | 40 } |
34 | 41 |
35 is_android = current_os == "android" | |
36 is_fuchsia = current_os == "fuchsia" | |
37 is_ios = current_os == "ios" | |
38 is_linux = current_os == "linux" | |
39 is_mac = current_os == "mac" | |
40 is_win = current_os == "win" | |
41 | |
42 is_posix = !is_win | |
43 | |
44 if (is_android) { | 42 if (is_android) { |
45 ndk_host = "" | 43 ndk_host = "" |
46 ndk_target = "" | 44 ndk_target = "" |
47 ndk_platform = "" | 45 ndk_platform = "" |
48 ndk_stdlib = "" | 46 ndk_stdlib = "" |
| 47 nkd_gccdir = "" |
49 | 48 |
50 if (host_os == "linux" && host_cpu == "x64") { | 49 if (host_os == "linux") { |
51 ndk_host = "linux-x86_64" | 50 ndk_host = "linux-x86_64" |
| 51 } else if (host_os == "mac") { |
| 52 ndk_host = "darwin-x86_64" |
52 } | 53 } |
| 54 |
53 if (target_cpu == "arm64") { | 55 if (target_cpu == "arm64") { |
54 ndk_target = "aarch64-linux-android" | 56 ndk_target = "aarch64-linux-android" |
55 ndk_platform = "android-21/arch-arm64" | 57 ndk_platform = "android-21/arch-arm64" |
56 ndk_stdlib = "arm64-v8a" | 58 ndk_stdlib = "arm64-v8a" |
| 59 ndk_gccdir = ndk_target |
| 60 } else if (target_cpu == "arm") { |
| 61 ndk_target = "arm-linux-androideabi" |
| 62 ndk_platform = "android-18/arch-arm" |
| 63 ndk_stdlib = "armeabi-v7a" |
| 64 ndk_gccdir = ndk_target |
| 65 } else if (target_cpu == "mips64el") { |
| 66 ndk_target = "mips64el-linux-android" |
| 67 ndk_platform = "android-21/arch-mips64" |
| 68 ndk_stdlib = "mips64" |
| 69 ndk_gccdir = ndk_target |
| 70 } else if (target_cpu == "mipsel") { |
| 71 ndk_target = "mipsel-linux-android" |
| 72 ndk_platform = "android-18/arch-mips" |
| 73 ndk_stdlib = "mips" |
| 74 ndk_gccdir = ndk_target |
| 75 } else if (target_cpu == "x64") { |
| 76 ndk_target = "x86_64-linux-android" |
| 77 ndk_platform = "android-21/arch-x86_64" |
| 78 ndk_stdlib = "x86_64" |
| 79 ndk_gccdir = ndk_stdlib |
| 80 } else if (target_cpu == "x86") { |
| 81 ndk_target = "i686-linux-android" |
| 82 ndk_platform = "android-18/arch-x86" |
| 83 ndk_stdlib = "x86" |
| 84 ndk_gccdir = ndk_stdlib |
57 } | 85 } |
58 } | 86 } |
59 | 87 |
60 # A component is either a static or a shared library. | 88 # A component is either a static or a shared library. |
61 template("component") { | 89 template("component") { |
62 _component_mode = "static_library" | 90 _component_mode = "static_library" |
63 if (is_component_build) { | 91 if (is_component_build) { |
64 _component_mode = "shared_library" | 92 _component_mode = "shared_library" |
65 } | 93 } |
66 | 94 |
(...skipping 29 matching lines...) Expand all Loading... |
96 | 124 |
97 set_defaults("component") { | 125 set_defaults("component") { |
98 configs = default_configs | 126 configs = default_configs |
99 if (!is_component_build) { | 127 if (!is_component_build) { |
100 complete_static_lib = true | 128 complete_static_lib = true |
101 } | 129 } |
102 } | 130 } |
103 | 131 |
104 # For now, we support GCC-like toolchains, including Clang. | 132 # For now, we support GCC-like toolchains, including Clang. |
105 set_default_toolchain("//gn:gcc_like") | 133 set_default_toolchain("//gn:gcc_like") |
OLD | NEW |