| # Copyright 2021 The Cobalt Authors. All Rights Reserved. | 
 | # | 
 | # Licensed under the Apache License, Version 2.0 (the "License"); | 
 | # you may not use this file except in compliance with the License. | 
 | # You may obtain a copy of the License at | 
 | # | 
 | #     http://www.apache.org/licenses/LICENSE-2.0 | 
 | # | 
 | # Unless required by applicable law or agreed to in writing, software | 
 | # distributed under the License is distributed on an "AS IS" BASIS, | 
 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
 | # See the License for the specific language governing permissions and | 
 | # limitations under the License. | 
 |  | 
 | import("//third_party/libwebp/libwebp.gni") | 
 | if (current_cpu == "arm" || current_cpu == "arm64") { | 
 |   import("//build/config/arm.gni") | 
 | } | 
 |  | 
 | template("libwebp_lib") { | 
 |   static_library(target_name) { | 
 |     forward_variables_from(invoker, "*") | 
 |     configs -= [ "//starboard/build/config:size" ] | 
 |     configs += [ | 
 |       "//starboard/build/config:speed", | 
 |       ":libwebp_direct_config", | 
 |     ] | 
 |     if (is_win) { | 
 |       cflags_c = [ "/wd4312" ]  # warning C4312: 'type cast': conversion from 'int' to 'int *' | 
 |     } else { | 
 |       cflags_c = [ | 
 |         "-Wno-implicit-function-declaration", | 
 |         "-Wno-int-to-pointer-cast", | 
 |       ] | 
 |     } | 
 |   } | 
 | } | 
 |  | 
 | libwebp_lib("libwebp_dec") { | 
 |   sources = libwebp_dec_sources | 
 | } | 
 |  | 
 | libwebp_lib("libwebp_demux") { | 
 |   sources = libwebp_demux_sources | 
 | } | 
 |  | 
 | libwebp_lib("libwebp_dsp_dec_common") { | 
 |   sources = libwebp_dsp_dec_common_sources | 
 |   deps = [ | 
 |     ":libwebp_dsp_dec_mips32", | 
 |     ":libwebp_dsp_dec_mips_dsp_r2", | 
 |     ":libwebp_dsp_dec_msa", | 
 |     ":libwebp_dsp_dec_neon", | 
 |     ":libwebp_dsp_dec_sse2", | 
 |     ":libwebp_dsp_dec_sse41", | 
 |   ] | 
 |   if (is_starboard) { | 
 |     deps += [ "//starboard:starboard_headers_only" ] | 
 |   } | 
 | } | 
 |  | 
 | libwebp_lib("libwebp_dsp_dec_msa") { | 
 |   sources = libwebp_dsp_dec_msa_sources | 
 | } | 
 |  | 
 | libwebp_lib("libwebp_dsp_dec_neon") { | 
 |   sources = libwebp_dsp_dec_neon_sources | 
 | } | 
 |  | 
 | libwebp_lib("libwebp_dsp_dec_sse2") { | 
 |   sources = libwebp_dsp_dec_sse2_sources | 
 | } | 
 |  | 
 | libwebp_lib("libwebp_dsp_dec_sse41") { | 
 |   sources = libwebp_dsp_dec_sse41_sources | 
 | } | 
 |  | 
 | libwebp_lib("libwebp_dsp_dec_mips32") { | 
 |   sources = libwebp_dsp_dec_mips32_sources | 
 | } | 
 |  | 
 | libwebp_lib("libwebp_dsp_dec_mips_dsp_r2") { | 
 |   sources = libwebp_dsp_dec_mips_dsp_r2_sources | 
 | } | 
 |  | 
 | libwebp_lib("libwebp_utils_dec") { | 
 |   sources = libwebp_utils_dec_sources | 
 | } | 
 |  | 
 | libwebp_lib("libwebp_enc") { | 
 |   sources = libwebp_enc_sources | 
 | } | 
 |  | 
 | libwebp_lib("libwebp_sharpyuv") { | 
 |   sources = libwebp_sharpyuv_sources | 
 |   deps = [ ":libwebp_dsp_dec_common" ] | 
 | } | 
 |  | 
 | libwebp_lib("libwebp_dsp_enc") { | 
 |   sources = libwebp_dsp_enc_sources | 
 | } | 
 |  | 
 | libwebp_lib("libwebp_utils_enc") { | 
 |   sources = libwebp_utils_enc_sources | 
 | } | 
 |  | 
 | config("libwebp_direct_config") { | 
 |   include_dirs = [ "." ] | 
 |   if (is_starboard && (target_os == "android" || target_os == "linux")) { | 
 |     if (current_cpu == "x64" || current_cpu == "x86") { | 
 |       cflags = [ | 
 |         "-msse2", | 
 |         "-msse4.1", | 
 |       ] | 
 |       defines = [ | 
 |         "WEBP_HAVE_SSE2", | 
 |         "WEBP_HAVE_SSE41", | 
 |       ] | 
 |     } | 
 |  | 
 |     # This crashes on x86/Atom, enable on 64-bit only. | 
 |     if (current_cpu == "x64") { | 
 |       cflags += [ | 
 |         "-mavx", | 
 |         "-mavx2", | 
 |       ] | 
 |       defines += [ "WEBP_HAVE_AVX2" ] | 
 |     } | 
 |     if ((current_cpu == "arm" || current_cpu == "arm64") && arm_use_neon ) { | 
 |       defines = [ "WEBP_HAVE_NEON" ] | 
 |       cflags = [ "-mfpu=neon" ] | 
 |     } | 
 |   } | 
 | } | 
 |  | 
 | group("libwebp") { | 
 |   public_configs = [ ":libwebp_direct_config" ] | 
 |   deps = [ | 
 |     ":libwebp_dec", | 
 |     ":libwebp_demux", | 
 |     ":libwebp_dsp_dec_common", | 
 |     ":libwebp_dsp_enc", | 
 |     ":libwebp_enc", | 
 |     ":libwebp_sharpyuv", | 
 |     ":libwebp_utils_dec", | 
 |     ":libwebp_utils_enc", | 
 |   ] | 
 | } |