media/webrtc/trunk/webrtc/build/secondary/third_party/libjpeg_turbo/BUILD.gn
author Daniel Varga <dvarga@mozilla.com>
Fri, 09 Nov 2018 12:22:53 +0200
changeset 445390 981eb3885ff2d2edc9408d44dab9610594a930f7
parent 444311 media/webrtc/trunk/build/secondary/third_party/libjpeg_turbo/BUILD.gn@ef27c14b46bf58f710753ae6bb6d2c01a8c3631f
parent 445272 media/webrtc/trunk/build/secondary/third_party/libjpeg_turbo/BUILD.gn@4989aa9ad7e01e986b90a86f875a23e445564ddd
permissions -rw-r--r--
Merge mozilla-central to autoland. a=merge

# 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")

if (current_cpu == "x86" || current_cpu == "x64") {
  import("//third_party/yasm/yasm_assemble.gni")

  yasm_assemble("simd_asm") {
    defines = []

    if (current_cpu == "x86") {
      sources = [
        "simd/jccolor-mmx.asm",
        "simd/jccolor-sse2.asm",
        "simd/jcgray-mmx.asm",
        "simd/jcgray-sse2.asm",
        "simd/jchuff-sse2.asm",
        "simd/jcsample-mmx.asm",
        "simd/jcsample-sse2.asm",
        "simd/jdcolor-mmx.asm",
        "simd/jdcolor-sse2.asm",
        "simd/jdmerge-mmx.asm",
        "simd/jdmerge-sse2.asm",
        "simd/jdsample-mmx.asm",
        "simd/jdsample-sse2.asm",
        "simd/jfdctflt-3dn.asm",
        "simd/jfdctflt-sse.asm",
        "simd/jfdctfst-mmx.asm",
        "simd/jfdctfst-sse2.asm",
        "simd/jfdctint-mmx.asm",
        "simd/jfdctint-sse2.asm",
        "simd/jidctflt-3dn.asm",
        "simd/jidctflt-sse.asm",
        "simd/jidctflt-sse2.asm",
        "simd/jidctfst-mmx.asm",
        "simd/jidctfst-sse2.asm",
        "simd/jidctint-mmx.asm",
        "simd/jidctint-sse2.asm",
        "simd/jidctred-mmx.asm",
        "simd/jidctred-sse2.asm",
        "simd/jquant-3dn.asm",
        "simd/jquant-mmx.asm",
        "simd/jquant-sse.asm",
        "simd/jquantf-sse2.asm",
        "simd/jquanti-sse2.asm",
        "simd/jsimdcpu.asm",
      ]
      defines += [
        "__x86__",
        "PIC",
      ]
    } else if (current_cpu == "x64") {
      sources = [
        "simd/jccolor-sse2-64.asm",
        "simd/jcgray-sse2-64.asm",
        "simd/jchuff-sse2-64.asm",
        "simd/jcsample-sse2-64.asm",
        "simd/jdcolor-sse2-64.asm",
        "simd/jdmerge-sse2-64.asm",
        "simd/jdsample-sse2-64.asm",
        "simd/jfdctflt-sse-64.asm",
        "simd/jfdctfst-sse2-64.asm",
        "simd/jfdctint-sse2-64.asm",
        "simd/jidctflt-sse2-64.asm",
        "simd/jidctfst-sse2-64.asm",
        "simd/jidctint-sse2-64.asm",
        "simd/jidctred-sse2-64.asm",
        "simd/jquantf-sse2-64.asm",
        "simd/jquanti-sse2-64.asm",
      ]
      defines += [
        "__x86_64__",
        "PIC",
      ]
    }

    if (is_win) {
      defines += [ "MSVC" ]
      include_dirs = [ "win" ]
      if (current_cpu == "x86") {
        defines += [ "WIN32" ]
      } else {
        defines += [ "WIN64" ]
      }
    } else if (is_mac || is_ios) {
      defines += [ "MACHO" ]
      include_dirs = [ "mac" ]
    } else if (is_linux || is_android) {
      defines += [ "ELF" ]
      include_dirs = [ "linux" ]
    }
  }
}

static_library("simd") {
  if (current_cpu == "x86") {
    deps = [
      ":simd_asm",
    ]
    sources = [
      "simd/jsimd_i386.c",
    ]
  } else if (current_cpu == "x64") {
    deps = [
      ":simd_asm",
    ]
    sources = [
      "simd/jsimd_x86_64.c",
    ]
  } else if (current_cpu == "arm" && arm_version >= 7 &&
             (arm_use_neon || arm_optionally_use_neon)) {
    sources = [
      "simd/jsimd_arm.c",
      "simd/jsimd_arm_neon.S",
    ]
  } else if (current_cpu == "arm64") {
    sources = [
      "simd/jsimd_arm64.c",
      "simd/jsimd_arm64_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",
    "jcinit.c",
    "jcmainct.c",
    "jcmarker.c",
    "jcmaster.c",
    "jcomapi.c",
    "jconfig.h",
    "jcparam.c",
    "jcphuff.c",
    "jcprepct.c",
    "jcsample.c",
    "jdapimin.c",
    "jdapistd.c",
    "jdatadst.c",
    "jdatasrc.c",
    "jdcoefct.c",
    "jdcolor.c",
    "jdct.h",
    "jddctmgr.c",
    "jdhuff.c",
    "jdhuff.h",
    "jdinput.c",
    "jdmainct.c",
    "jdmarker.c",
    "jdmaster.c",
    "jdmerge.c",
    "jdphuff.c",
    "jdpostct.c",
    "jdsample.c",
    "jerror.c",
    "jerror.h",
    "jfdctflt.c",
    "jfdctfst.c",
    "jfdctint.c",
    "jidctflt.c",
    "jidctfst.c",
    "jidctint.c",
    "jidctred.c",
    "jinclude.h",
    "jmemmgr.c",
    "jmemnobs.c",
    "jmemsys.h",
    "jmorecfg.h",
    "jpegint.h",
    "jpeglib.h",
    "jpeglibmangler.h",
    "jquant1.c",
    "jquant2.c",
    "jutils.c",
    "jversion.h",
  ]

  defines = [
    "WITH_SIMD",
    "NO_GETENV",
  ]

  configs += [ ":libjpeg_config" ]

  public_configs = [ ":libjpeg_config" ]

  # MemorySanitizer doesn't support assembly code, so keep it disabled in
  # MSan builds for now.
  if (is_msan) {
    sources += [ "jsimd_none.c" ]
  } else {
    deps = [
      ":simd",
    ]
  }
}