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