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 = os |
| 14 } |
| 15 |
| 16 # Sets the architecture name for building libvpx. |
| 17 if (cpu_arch == "x86") { |
| 18 cpu_arch_full = "ia32" |
| 19 } else if (cpu_arch == "x64") { |
| 20 if (is_msan) { |
| 21 cpu_arch_full = "generic" |
| 22 } else { |
| 23 cpu_arch_full = "x64" |
| 24 } |
| 25 } else if (cpu_arch == "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 = cpu_arch |
| 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 cflags = [ "-Wno-unused-function", "-Wno-sign-compare" ] |
| 45 } |
| 46 |
| 47 executable("libvpx_obj_int_extract") { |
| 48 sources = [ |
| 49 "//third_party/libvpx/source/libvpx/build/make/obj_int_extract.c" |
| 50 ] |
| 51 configs += [ ":libvpx_config" ] |
| 52 if (is_android_webview_build) { |
| 53 defines += [ "FORCE_PARSE_ELF" ] |
| 54 include_dirs += [ "//third_party/libvpx/include" ] |
| 55 } |
| 56 } |
| 57 |
| 58 # A library whose object files contain integers to be extracted. |
| 59 static_library("libvpx_asm_offsets") { |
| 60 sources = [ |
| 61 "//third_party/libvpx/source/libvpx/vp8/encoder/vp8_asm_enc_offsets.c", |
| 62 "//third_party/libvpx/source/libvpx/vpx_scale/vpx_scale_asm_offsets.c" |
| 63 ] |
| 64 configs += [ ":libvpx_config" ] |
| 65 if (is_clang) { |
| 66 cflags = [ "-Wno-unused-function" ] |
| 67 } |
| 68 } |
| 69 |
| 70 # This works only on POSIX to extract integer values from an object file. |
| 71 template("obj_int_extract") { |
| 72 action(target_name) { |
| 73 script = "//third_party/libvpx/obj_int_extract.py" |
| 74 bin_label = "//third_party/libvpx($host_toolchain)" |
| 75 |
| 76 args = [ |
| 77 "-e", |
| 78 "./" + rebase_path(get_label_info(bin_label, "root_out_dir") + |
| 79 "/libvpx_obj_int_extract", |
| 80 root_build_dir) |
| 81 ] |
| 82 |
| 83 if (cpu_arch == "arm") { |
| 84 args += [ "-f", "gas" ] |
| 85 } else { |
| 86 args += [ "-f", "rvds" ] |
| 87 } |
| 88 |
| 89 args += [ |
| 90 "-b", |
| 91 rebase_path(get_label_info(":libvpx_asm_offsets", "target_out_dir")) + |
| 92 "/" + invoker.src_dir + "/libvpx_asm_offsets." + |
| 93 invoker.obj_file_root + ".o" |
| 94 ] |
| 95 out_file = "$target_gen_dir/" + invoker.obj_file_root + ".asm" |
| 96 args += [ "-o", rebase_path(out_file) ] |
| 97 outputs = [ out_file ] |
| 98 deps = [ |
| 99 ":libvpx_asm_offsets", |
| 100 ":libvpx_obj_int_extract($host_toolchain)" |
| 101 ] |
| 102 } |
| 103 } |
| 104 |
| 105 obj_int_extract("gen_asm_offsets_vp8") { |
| 106 src_dir = "source/libvpx/vp8/encoder" |
| 107 obj_file_root = "vp8_asm_enc_offsets" |
| 108 } |
| 109 |
| 110 obj_int_extract("gen_asm_offsets_scale") { |
| 111 src_dir = "source/libvpx/vpx_scale" |
| 112 obj_file_root = "vpx_scale_asm_offsets" |
| 113 } |
| 114 |
| 115 if (cpu_arch == "x86" || cpu_arch == "x64") { |
| 116 yasm_assemble("libvpx_yasm") { |
| 117 if (cpu_arch == "x86") { |
| 118 sources = libvpx_srcs_x86_assembly |
| 119 } else if (cpu_arch == "x64") { |
| 120 sources = libvpx_srcs_x86_64_assembly |
| 121 } |
| 122 |
| 123 defines = [ "CHROMIUM" ] |
| 124 include_dirs = [ |
| 125 "//third_party/libvpx/source/config/$os_category/$cpu_arch_full", |
| 126 "//third_party/libvpx/source/config", |
| 127 "//third_party/libvpx/source/libvpx", |
| 128 target_gen_dir |
| 129 ] |
| 130 } |
| 131 } |
| 132 |
| 133 static_library("libvpx_intrinsics_mmx") { |
| 134 configs += [ ":libvpx_config" ] |
| 135 cflags = [ "-mmmx" ] |
| 136 if (cpu_arch == "x86") { |
| 137 sources = libvpx_srcs_x86_mmx |
| 138 } else if (cpu_arch == "x64") { |
| 139 sources = libvpx_srcs_x86_64_mmx |
| 140 } |
| 141 } |
| 142 |
| 143 static_library("libvpx_intrinsics_sse2") { |
| 144 configs += [ ":libvpx_config" ] |
| 145 cflags = [ "-msse2" ] |
| 146 if (cpu_arch == "x86") { |
| 147 sources = libvpx_srcs_x86_sse2 |
| 148 } else if (cpu_arch == "x64") { |
| 149 sources = libvpx_srcs_x86_64_sse2 |
| 150 } |
| 151 } |
| 152 |
| 153 static_library("libvpx_intrinsics_ssse3") { |
| 154 configs += [ ":libvpx_config" ] |
| 155 cflags = [ "-mssse3" ] |
| 156 if (cpu_arch == "x86") { |
| 157 sources = libvpx_srcs_x86_ssse3 |
| 158 } else if (cpu_arch == "x64") { |
| 159 sources = libvpx_srcs_x86_64_ssse3 |
| 160 } |
| 161 } |
| 162 |
| 163 static_library("libvpx_intrinsics_sse4_1") { |
| 164 configs += [ ":libvpx_config" ] |
| 165 cflags = [ "-msse4.1" ] |
| 166 if (cpu_arch == "x86") { |
| 167 sources = libvpx_srcs_x86_sse4_1 |
| 168 } else if (cpu_arch == "x64") { |
| 169 sources = libvpx_srcs_x86_64_sse4_1 |
| 170 } |
| 171 } |
| 172 |
| 173 static_library("libvpx_intrinsics_neon") { |
| 174 configs += [ ":libvpx_config" ] |
| 175 cflags = [ "-mfpu=neon", "-mfloat-abi=softfp" ] |
| 176 sources = libvpx_srcs_arm_neon_cpu_detect_neon |
| 177 } |
| 178 |
| 179 static_library("libvpx") { |
| 180 if (!is_debug && is_win && is_official_build) { |
| 181 configs -= [ "//build/config/compiler:optimize" ] |
| 182 configs += [ "//build/config/compiler:optimize_max" ] |
| 183 } |
| 184 |
| 185 if (cpu_arch == "x86") { |
| 186 sources = libvpx_srcs_x86 |
| 187 } else if (cpu_arch == "x64") { |
| 188 if (is_msan) { |
| 189 sources = libvpx_srcs_generic |
| 190 } else { |
| 191 sources = libvpx_srcs_x86_64 |
| 192 } |
| 193 } else if (cpu_arch == "mipsel") { |
| 194 sources = libvpx_srcs_generic |
| 195 } else if (cpu_arch == "arm") { |
| 196 if (arm_use_neon) { |
| 197 sources = libvpx_srcs_arm_neon |
| 198 } else if (is_android) { |
| 199 sources = libvpx_srcs_arm_neon_cpu_detect |
| 200 } else { |
| 201 sources = libvpx_srcs_arm |
| 202 } |
| 203 } else if (cpu_arch == "arm64") { |
| 204 sources = libvpx_srcs_arm64 |
| 205 } |
| 206 |
| 207 deps = [ |
| 208 ":gen_asm_offsets_vp8", |
| 209 ] |
| 210 configs += [ ":libvpx_config" ] |
| 211 if (cpu_arch == "x86" || (cpu_arch == "x64" && !is_msan)) { |
| 212 deps += [ |
| 213 ":libvpx_yasm", |
| 214 ":libvpx_intrinsics_mmx", |
| 215 ":libvpx_intrinsics_sse2", |
| 216 ":libvpx_intrinsics_ssse3", |
| 217 ":libvpx_intrinsics_sse4_1", |
| 218 ] |
| 219 } |
| 220 if (is_android) { |
| 221 if (cpu_arch == "arm") { |
| 222 deps += [ |
| 223 # TODO(hclam): GN build doesn't compile NEON intrinsics because |
| 224 # -mfpu=vfpv3-d16 needs to be removed. |
| 225 # ":libvpx_intrinsics_neon" |
| 226 ] |
| 227 } |
| 228 deps += [ "//third_party/android_tools:cpu_features" ] |
| 229 } |
| 230 } |
OLD | NEW |