OLD | NEW |
(Empty) | |
| 1 # Copyright 2014 The Chromium Authors. 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 import("//build/config/arm.gni") |
| 6 import("//build/config/android/config.gni") |
| 7 import("//build/config/chrome_build.gni") |
| 8 import("//build/config/sanitizers/sanitizers.gni") |
| 9 import("//third_party/libvpx_new/libvpx_srcs.gni") |
| 10 import("//third_party/yasm/yasm_assemble.gni") |
| 11 |
| 12 # Sets the architecture name for building libvpx. |
| 13 if (current_cpu == "x86") { |
| 14 cpu_arch_full = "ia32" |
| 15 } else if (current_cpu == "x64") { |
| 16 if (is_msan) { |
| 17 cpu_arch_full = "generic" |
| 18 } else { |
| 19 cpu_arch_full = "x64" |
| 20 } |
| 21 } else if (current_cpu == "arm") { |
| 22 if (arm_use_neon) { |
| 23 cpu_arch_full = "arm-neon" |
| 24 } else if (is_android) { |
| 25 cpu_arch_full = "arm-neon-cpu-detect" |
| 26 } else { |
| 27 cpu_arch_full = "arm" |
| 28 } |
| 29 } else { |
| 30 cpu_arch_full = current_cpu |
| 31 } |
| 32 |
| 33 if (is_nacl) { |
| 34 platform_include_dir = "//third_party/libvpx_new/source/config/nacl" |
| 35 } else { |
| 36 if (is_posix && !is_mac) { |
| 37 os_category = "linux" |
| 38 } else { |
| 39 os_category = current_os |
| 40 } |
| 41 platform_include_dir = |
| 42 "//third_party/libvpx_new/source/config/$os_category/$cpu_arch_full" |
| 43 } |
| 44 |
| 45 config("libvpx_config") { |
| 46 include_dirs = [ |
| 47 "//third_party/libvpx_new/source/config", |
| 48 platform_include_dir, |
| 49 "//third_party/libvpx_new/source/libvpx", |
| 50 "$root_gen_dir/third_party/libvpx_new", # Provides vpx_rtcd.h. |
| 51 ] |
| 52 } |
| 53 |
| 54 # gn orders flags on a target before flags from configs. The default config |
| 55 # adds -Wall, and these flags have to be after -Wall -- so they need to come |
| 56 # from a config and can't be on the target directly. |
| 57 config("libvpx_warnings") { |
| 58 if (is_clang) { |
| 59 cflags = [ |
| 60 # libvpx heavily relies on implicit enum casting. |
| 61 "-Wno-conversion", |
| 62 # libvpx does `if ((a == b))` in some places. |
| 63 "-Wno-parentheses-equality", |
| 64 # libvpx has many static functions in header, which trigger this warning. |
| 65 "-Wno-unused-function", |
| 66 ] |
| 67 } else if (!is_win) { |
| 68 cflags = [ "-Wno-unused-function", "-Wno-sign-compare" ] |
| 69 } |
| 70 } |
| 71 |
| 72 # This config is applied to targets that depend on libvpx. |
| 73 config("libvpx_external_config") { |
| 74 include_dirs = [ |
| 75 "//third_party/libvpx_new/source/libvpx", |
| 76 ] |
| 77 } |
| 78 |
| 79 if (current_cpu == "x86" || current_cpu == "x64") { |
| 80 yasm_assemble("libvpx_yasm") { |
| 81 if (current_cpu == "x86") { |
| 82 sources = libvpx_srcs_x86_assembly |
| 83 } else if (current_cpu == "x64") { |
| 84 sources = libvpx_srcs_x86_64_assembly |
| 85 } |
| 86 |
| 87 defines = [ "CHROMIUM" ] |
| 88 include_dirs = [ |
| 89 platform_include_dir, |
| 90 "//third_party/libvpx_new/source/config", |
| 91 "//third_party/libvpx_new/source/libvpx", |
| 92 target_gen_dir |
| 93 ] |
| 94 } |
| 95 } |
| 96 |
| 97 static_library("libvpx_intrinsics_mmx") { |
| 98 configs += [ ":libvpx_config" ] |
| 99 configs -= [ "//build/config/compiler:chromium_code" ] |
| 100 configs += [ "//build/config/compiler:no_chromium_code" ] |
| 101 configs += [ ":libvpx_warnings" ] |
| 102 if (!is_win) { |
| 103 cflags = [ "-mmmx" ] |
| 104 } |
| 105 if (current_cpu == "x86") { |
| 106 sources = libvpx_srcs_x86_mmx |
| 107 } else if (current_cpu == "x64") { |
| 108 sources = libvpx_srcs_x86_64_mmx |
| 109 } |
| 110 } |
| 111 |
| 112 static_library("libvpx_intrinsics_sse2") { |
| 113 configs += [ ":libvpx_config" ] |
| 114 configs -= [ "//build/config/compiler:chromium_code" ] |
| 115 configs += [ "//build/config/compiler:no_chromium_code" ] |
| 116 configs += [ ":libvpx_warnings" ] |
| 117 if (!is_win || is_clang) { |
| 118 cflags = [ "-msse2" ] |
| 119 } |
| 120 if (current_cpu == "x86") { |
| 121 sources = libvpx_srcs_x86_sse2 |
| 122 } else if (current_cpu == "x64") { |
| 123 sources = libvpx_srcs_x86_64_sse2 |
| 124 } |
| 125 } |
| 126 |
| 127 static_library("libvpx_intrinsics_ssse3") { |
| 128 configs += [ ":libvpx_config" ] |
| 129 configs -= [ "//build/config/compiler:chromium_code" ] |
| 130 configs += [ "//build/config/compiler:no_chromium_code" ] |
| 131 configs += [ ":libvpx_warnings" ] |
| 132 if (!is_win || is_clang) { |
| 133 cflags = [ "-mssse3" ] |
| 134 } |
| 135 if (current_cpu == "x86") { |
| 136 sources = libvpx_srcs_x86_ssse3 |
| 137 } else if (current_cpu == "x64") { |
| 138 sources = libvpx_srcs_x86_64_ssse3 |
| 139 } |
| 140 } |
| 141 |
| 142 static_library("libvpx_intrinsics_sse4_1") { |
| 143 configs += [ ":libvpx_config" ] |
| 144 configs -= [ "//build/config/compiler:chromium_code" ] |
| 145 configs += [ "//build/config/compiler:no_chromium_code" ] |
| 146 configs += [ ":libvpx_warnings" ] |
| 147 if (!is_win || is_clang) { |
| 148 cflags = [ "-msse4.1" ] |
| 149 } |
| 150 if (current_cpu == "x86") { |
| 151 sources = libvpx_srcs_x86_sse4_1 |
| 152 } else if (current_cpu == "x64") { |
| 153 sources = libvpx_srcs_x86_64_sse4_1 |
| 154 } |
| 155 } |
| 156 |
| 157 static_library("libvpx_intrinsics_avx2") { |
| 158 configs += [ ":libvpx_config" ] |
| 159 configs -= [ "//build/config/compiler:chromium_code" ] |
| 160 configs += [ "//build/config/compiler:no_chromium_code" ] |
| 161 configs += [ ":libvpx_warnings" ] |
| 162 if (is_win) { |
| 163 cflags = [ "/arch:AVX2" ] |
| 164 } else { |
| 165 cflags = [ "-mavx2" ] |
| 166 } |
| 167 if (current_cpu == "x86") { |
| 168 sources = libvpx_srcs_x86_avx2 |
| 169 } else if (current_cpu == "x64") { |
| 170 sources = libvpx_srcs_x86_64_avx2 |
| 171 } |
| 172 } |
| 173 |
| 174 if (cpu_arch_full == "arm-neon-cpu-detect") { |
| 175 static_library("libvpx_intrinsics_neon") { |
| 176 configs -= [ "//build/config/compiler:compiler_arm_fpu" ] |
| 177 configs += [ ":libvpx_config" ] |
| 178 configs += [ ":libvpx_warnings" ] |
| 179 cflags = [ "-mfpu=neon" ] |
| 180 sources = libvpx_srcs_arm_neon_cpu_detect_neon |
| 181 } |
| 182 } |
| 183 |
| 184 # Converts ARM assembly files to GAS style. |
| 185 if (current_cpu == "arm") { |
| 186 action_foreach("convert_arm_assembly") { |
| 187 script = "//third_party/libvpx_new/run_perl.py" |
| 188 if (cpu_arch_full == "arm-neon") { |
| 189 sources = libvpx_srcs_arm_neon_assembly |
| 190 } else if (cpu_arch_full == "arm-neon-cpu-detect") { |
| 191 sources = libvpx_srcs_arm_neon_cpu_detect_assembly |
| 192 } else { |
| 193 sources = libvpx_srcs_arm_assembly |
| 194 } |
| 195 outputs = [ "$target_gen_dir/{{source_name_part}}.S" ] |
| 196 args = [ |
| 197 "-s", |
| 198 rebase_path("//third_party/libvpx_new/source/libvpx/build/make/ads2gas.pl"
, |
| 199 root_build_dir), |
| 200 "-i", "{{source}}", |
| 201 "-o", rebase_path("$target_gen_dir/{{source_name_part}}.S") |
| 202 ] |
| 203 } |
| 204 |
| 205 static_library("libvpx_assembly_arm") { |
| 206 sources = get_target_outputs(":convert_arm_assembly") |
| 207 configs -= [ "//build/config/compiler:compiler_arm_fpu" ] |
| 208 configs += [ ":libvpx_config" ] |
| 209 configs += [ ":libvpx_warnings" ] |
| 210 if (cpu_arch_full == "arm-neon" || |
| 211 cpu_arch_full == "arm-neon-cpu-detect") { |
| 212 cflags = [ "-mfpu=neon" ] |
| 213 } |
| 214 deps = [ |
| 215 ":convert_arm_assembly", |
| 216 ] |
| 217 } |
| 218 } |
| 219 |
| 220 static_library("libvpx_new") { |
| 221 if (!is_debug && is_win && is_official_build) { |
| 222 configs -= [ "//build/config/compiler:optimize" ] |
| 223 configs += [ "//build/config/compiler:optimize_max" ] |
| 224 } |
| 225 |
| 226 if (is_nacl) { |
| 227 sources = libvpx_srcs_generic |
| 228 } else if (current_cpu == "x86") { |
| 229 sources = libvpx_srcs_x86 |
| 230 } else if (current_cpu == "x64") { |
| 231 if (is_msan) { |
| 232 sources = libvpx_srcs_generic |
| 233 } else { |
| 234 sources = libvpx_srcs_x86_64 |
| 235 } |
| 236 } else if (current_cpu == "mipsel") { |
| 237 sources = libvpx_srcs_mips |
| 238 } else if (current_cpu == "arm") { |
| 239 if (arm_use_neon) { |
| 240 sources = libvpx_srcs_arm_neon |
| 241 } else if (is_android) { |
| 242 sources = libvpx_srcs_arm_neon_cpu_detect |
| 243 } else { |
| 244 sources = libvpx_srcs_arm |
| 245 } |
| 246 } else if (current_cpu == "arm64") { |
| 247 sources = libvpx_srcs_arm64 |
| 248 } |
| 249 |
| 250 configs += [ ":libvpx_config" ] |
| 251 configs -= [ "//build/config/compiler:chromium_code" ] |
| 252 configs += [ "//build/config/compiler:no_chromium_code" ] |
| 253 configs += [ ":libvpx_warnings" ] |
| 254 deps = [] |
| 255 if (current_cpu == "x86" || (current_cpu == "x64" && !is_msan)) { |
| 256 deps += [ |
| 257 ":libvpx_yasm", |
| 258 ":libvpx_intrinsics_mmx", |
| 259 ":libvpx_intrinsics_sse2", |
| 260 ":libvpx_intrinsics_ssse3", |
| 261 ":libvpx_intrinsics_sse4_1", |
| 262 ":libvpx_intrinsics_avx2", |
| 263 ] |
| 264 } |
| 265 if (cpu_arch_full == "arm-neon-cpu-detect") { |
| 266 deps += [ ":libvpx_intrinsics_neon" ] |
| 267 } |
| 268 if (is_android) { |
| 269 deps += [ "//third_party/android_tools:cpu_features" ] |
| 270 } |
| 271 if (current_cpu == "arm") { |
| 272 deps += [ ":libvpx_assembly_arm" ] |
| 273 } |
| 274 |
| 275 public_configs = [ ":libvpx_external_config" ] |
| 276 } |
OLD | NEW |