blob: 72785cc0edf715c266db9b1dc83bd00b0179b093 [file] [log] [blame]
# Copyright (c) 2017 The WebM project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
import("//build/config/arm.gni")
import("//third_party/libvpx/libvpx_srcs.gni")
import("//third_party/yasm/yasm_assemble.gni")
# Sets the architecture name for building libvpx.
cpu_arch_full = current_cpu
platform_include_dir = "//third_party/libvpx/config/fuchsia/$cpu_arch_full"
config("libvpx_config") {
include_dirs = [
"//third_party/libvpx/config",
platform_include_dir,
"//third_party/libvpx",
"$root_gen_dir/third_party/libvpx", # Provides vpx_rtcd.h.
]
}
# gn orders flags on a target before flags from configs. The default config
# adds -Wall, and these flags have to be after -Wall -- so they need to come
# from a config and can't be on the target directly.
config("libvpx_warnings") {
if (is_clang) {
cflags = [
# libvpx heavily relies on implicit enum casting.
"-Wno-conversion",
# libvpx does `if ((a == b))` in some places.
"-Wno-parentheses-equality",
# libvpx has many static functions in header, which trigger this warning.
"-Wno-unused-function",
]
} else {
cflags = [
"-Wno-unused-function",
"-Wno-sign-compare",
]
}
}
# This config is applied to targets that depend on libvpx.
config("libvpx_external_config") {
include_dirs = [ "//third_party/libvpx" ]
}
if (current_cpu == "x64") {
yasm_assemble("libvpx_yasm") {
sources = libvpx_srcs_x86_64_assembly
defines = [ "CHROMIUM" ]
include_dirs = [
platform_include_dir,
"//third_party/libvpx/config",
"//third_party/libvpx",
target_gen_dir,
]
}
}
if (current_cpu == "x64") {
# The following targets are deliberately source_set rather than
# static_library. The :libvpx target exposes these intrinsic implementations
# via global function pointer symbols, which hides the object dependency at
# link time. On Mac, this results in undefined references to the intrinsic
# symbols.
source_set("libvpx_intrinsics_mmx") {
configs += [ ":libvpx_config" ]
configs += [ ":libvpx_warnings" ]
cflags = [ "-mmmx" ]
sources = libvpx_srcs_x86_64_mmx
}
source_set("libvpx_intrinsics_sse2") {
configs += [ ":libvpx_config" ]
configs += [ ":libvpx_warnings" ]
cflags = [ "-msse2" ]
sources = libvpx_srcs_x86_64_sse2
}
source_set("libvpx_intrinsics_ssse3") {
configs += [ ":libvpx_config" ]
configs += [ ":libvpx_warnings" ]
cflags = [ "-mssse3" ]
sources = libvpx_srcs_x86_64_ssse3
}
source_set("libvpx_intrinsics_sse4_1") {
configs += [ ":libvpx_config" ]
configs += [ ":libvpx_warnings" ]
cflags = [ "-msse4.1" ]
sources = libvpx_srcs_x86_64_sse4_1
}
source_set("libvpx_intrinsics_avx") {
configs += [ ":libvpx_config" ]
configs += [ ":libvpx_warnings" ]
cflags = [ "-mavx" ]
sources = libvpx_srcs_x86_64_avx
}
source_set("libvpx_intrinsics_avx2") {
configs += [ ":libvpx_config" ]
configs += [ ":libvpx_warnings" ]
cflags = [ "-mavx2" ]
sources = libvpx_srcs_x86_64_avx2
}
}
static_library("libvpx") {
if (current_cpu == "x64") {
sources = libvpx_srcs_x86_64
} else if (current_cpu == "arm64") {
sources = libvpx_srcs_arm64
}
configs += [ ":libvpx_config" ]
configs += [ ":libvpx_warnings" ]
deps = [
":libvpx_intrinsics_avx",
":libvpx_intrinsics_avx2",
":libvpx_intrinsics_mmx",
":libvpx_intrinsics_sse2",
":libvpx_intrinsics_sse4_1",
":libvpx_intrinsics_ssse3",
":libvpx_yasm",
]
public_configs = [ ":libvpx_external_config" ]
}