blob: bc43a7a187ca69927f44ed339f301a697404bd74 [file] [log] [blame]
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Do not use the targets in this file unless you need a certain libjpeg
# implementation. Use the meta target //third_party:jpeg instead.
import("//build/config/sanitizers/sanitizers.gni")
if (current_cpu == "arm") {
import("//build/config/arm.gni")
}
assert(!is_ios, "This is not used on iOS, don't drag it in unintentionally")
source_set("libjpeg_headers") {
sources = [
"jconfig.h",
"jdct.h",
"jinclude.h",
"jmorecfg.h",
"jpeglib.h",
"jpeglibmangler.h",
]
}
if (current_cpu == "x86" || current_cpu == "x64") {
import("//third_party/yasm/yasm_assemble.gni")
yasm_assemble("simd_asm") {
defines = []
include_dirs = [ "simd/nasm/" ]
if (current_cpu == "x86") {
sources = [
"simd/i386/jccolor-avx2.asm",
"simd/i386/jccolor-mmx.asm",
"simd/i386/jccolor-sse2.asm",
"simd/i386/jcgray-avx2.asm",
"simd/i386/jcgray-mmx.asm",
"simd/i386/jcgray-sse2.asm",
"simd/i386/jchuff-sse2.asm",
"simd/i386/jcphuff-sse2.asm",
"simd/i386/jcsample-avx2.asm",
"simd/i386/jcsample-mmx.asm",
"simd/i386/jcsample-sse2.asm",
"simd/i386/jdcolor-avx2.asm",
"simd/i386/jdcolor-mmx.asm",
"simd/i386/jdcolor-sse2.asm",
"simd/i386/jdmerge-avx2.asm",
"simd/i386/jdmerge-mmx.asm",
"simd/i386/jdmerge-sse2.asm",
"simd/i386/jdsample-avx2.asm",
"simd/i386/jdsample-mmx.asm",
"simd/i386/jdsample-sse2.asm",
"simd/i386/jfdctflt-3dn.asm",
"simd/i386/jfdctflt-sse.asm",
"simd/i386/jfdctfst-mmx.asm",
"simd/i386/jfdctfst-sse2.asm",
"simd/i386/jfdctint-avx2.asm",
"simd/i386/jfdctint-mmx.asm",
"simd/i386/jfdctint-sse2.asm",
"simd/i386/jidctflt-3dn.asm",
"simd/i386/jidctflt-sse.asm",
"simd/i386/jidctflt-sse2.asm",
"simd/i386/jidctfst-mmx.asm",
"simd/i386/jidctfst-sse2.asm",
"simd/i386/jidctint-avx2.asm",
"simd/i386/jidctint-mmx.asm",
"simd/i386/jidctint-sse2.asm",
"simd/i386/jidctred-mmx.asm",
"simd/i386/jidctred-sse2.asm",
"simd/i386/jquant-3dn.asm",
"simd/i386/jquant-mmx.asm",
"simd/i386/jquant-sse.asm",
"simd/i386/jquantf-sse2.asm",
"simd/i386/jquanti-avx2.asm",
"simd/i386/jquanti-sse2.asm",
"simd/i386/jsimdcpu.asm",
]
defines += [
"__x86__",
"PIC",
]
} else if (current_cpu == "x64") {
sources = [
"simd/x86_64/jccolor-avx2.asm",
"simd/x86_64/jccolor-sse2.asm",
"simd/x86_64/jcgray-avx2.asm",
"simd/x86_64/jcgray-sse2.asm",
"simd/x86_64/jchuff-sse2.asm",
"simd/x86_64/jcphuff-sse2.asm",
"simd/x86_64/jcsample-avx2.asm",
"simd/x86_64/jcsample-sse2.asm",
"simd/x86_64/jdcolor-avx2.asm",
"simd/x86_64/jdcolor-sse2.asm",
"simd/x86_64/jdmerge-avx2.asm",
"simd/x86_64/jdmerge-sse2.asm",
"simd/x86_64/jdsample-avx2.asm",
"simd/x86_64/jdsample-sse2.asm",
"simd/x86_64/jfdctflt-sse.asm",
"simd/x86_64/jfdctfst-sse2.asm",
"simd/x86_64/jfdctint-avx2.asm",
"simd/x86_64/jfdctint-sse2.asm",
"simd/x86_64/jidctflt-sse2.asm",
"simd/x86_64/jidctfst-sse2.asm",
"simd/x86_64/jidctint-avx2.asm",
"simd/x86_64/jidctint-sse2.asm",
"simd/x86_64/jidctred-sse2.asm",
"simd/x86_64/jquantf-sse2.asm",
"simd/x86_64/jquanti-avx2.asm",
"simd/x86_64/jquanti-sse2.asm",
"simd/x86_64/jsimdcpu.asm",
]
defines += [
"__x86_64__",
"PIC",
]
}
if (is_win) {
defines += [ "MSVC" ]
if (current_cpu == "x86") {
defines += [ "WIN32" ]
} else {
defines += [ "WIN64" ]
}
} else if (is_mac || is_ios) {
defines += [ "MACHO" ]
} else if (is_linux || is_android || is_fuchsia) {
defines += [ "ELF" ]
}
}
}
static_library("simd") {
include_dirs = [ "." ]
deps = [
":libjpeg_headers",
]
if (current_cpu == "x86") {
deps += [ ":simd_asm" ]
sources = [
"simd/i386/jsimd.c",
]
} else if (current_cpu == "x64") {
deps += [ ":simd_asm" ]
sources = [
"simd/x86_64/jsimd.c",
]
} else if (current_cpu == "arm" && arm_version >= 7 &&
(arm_use_neon || arm_optionally_use_neon)) {
sources = [
"simd/arm/jsimd.c",
"simd/arm/jsimd_neon.S",
]
} else if (current_cpu == "arm64") {
sources = [
"simd/arm64/jsimd.c",
"simd/arm64/jsimd_neon.S",
]
} else {
sources = [
"jsimd_none.c",
]
}
if (is_win) {
cflags = [ "/wd4245" ]
}
}
config("libjpeg_config") {
include_dirs = [ "." ]
}
static_library("libjpeg") {
sources = [
"jcapimin.c",
"jcapistd.c",
"jccoefct.c",
"jccolor.c",
"jcdctmgr.c",
"jchuff.c",
"jchuff.h",
"jcicc.c",
"jcinit.c",
"jcmainct.c",
"jcmarker.c",
"jcmaster.c",
"jcomapi.c",
"jcparam.c",
"jcphuff.c",
"jcprepct.c",
"jcsample.c",
"jctrans.c",
"jdapimin.c",
"jdapistd.c",
"jdatadst.c",
"jdatasrc.c",
"jdcoefct.c",
"jdcolor.c",
"jddctmgr.c",
"jdhuff.c",
"jdhuff.h",
"jdicc.c",
"jdinput.c",
"jdmainct.c",
"jdmarker.c",
"jdmaster.c",
"jdmerge.c",
"jdphuff.c",
"jdpostct.c",
"jdsample.c",
"jdtrans.c",
"jerror.c",
"jerror.h",
"jfdctflt.c",
"jfdctfst.c",
"jfdctint.c",
"jidctflt.c",
"jidctfst.c",
"jidctint.c",
"jidctred.c",
"jmemmgr.c",
"jmemnobs.c",
"jmemsys.h",
"jpegint.h",
"jquant1.c",
"jquant2.c",
"jutils.c",
"jversion.h",
]
defines = [
"WITH_SIMD",
"NO_GETENV",
]
configs += [ ":libjpeg_config" ]
public_configs = [ ":libjpeg_config" ]
public_deps = [
":libjpeg_headers",
]
# MemorySanitizer doesn't support assembly code, so keep it disabled in
# MSan builds for now.
if (is_msan) {
sources += [ "jsimd_none.c" ]
} else {
public_deps += [ ":simd" ]
}
}