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