# 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. import("//build/config/arm.gni") import("//build/config/sanitizers/sanitizers.gni") config("libwebp_config") { include_dirs = [ "./src" ] } set_opt_level = !is_debug && is_posix && (current_cpu == "arm" || current_cpu == "arm64") # webp's dsp code can be built for all configurations. Skipping it when both # arm_use_neon and arm_optionally_use_neon are false will result in link errors # for its dsp init functions. use_dsp_neon = current_cpu == "arm64" || (current_cpu == "arm" && arm_version >= 7) source_set("libwebp_webp") { sources = [ "src/webp/decode.h", "src/webp/demux.h", "src/webp/encode.h", "src/webp/format_constants.h", "src/webp/mux.h", "src/webp/mux_types.h", "src/webp/types.h", ] } static_library("libwebp_dec") { sources = [ "src/dec/alpha_dec.c", "src/dec/alphai_dec.h", "src/dec/buffer_dec.c", "src/dec/common_dec.h", "src/dec/frame_dec.c", "src/dec/idec_dec.c", "src/dec/io_dec.c", "src/dec/quant_dec.c", "src/dec/tree_dec.c", "src/dec/vp8_dec.c", "src/dec/vp8_dec.h", "src/dec/vp8i_dec.h", "src/dec/vp8l_dec.c", "src/dec/vp8li_dec.h", "src/dec/webp_dec.c", "src/dec/webpi_dec.h", ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] if (set_opt_level) { configs -= [ "//build/config/compiler:default_optimization" ] configs += [ "//build/config/compiler:optimize_max" ] } deps = [ ":libwebp_dsp", ":libwebp_utils", ":libwebp_webp", ] all_dependent_configs = [ ":libwebp_config" ] if (use_dsp_neon) { deps += [ ":libwebp_dsp_neon" ] } } static_library("libwebp_demux") { sources = [ "src/demux/demux.c", ] all_dependent_configs = [ ":libwebp_config" ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] deps = [ ":libwebp_utils", ":libwebp_webp", ] } static_library("libwebp_mux") { sources = [ "src/mux/anim_encode.c", "src/mux/animi.h", "src/mux/muxedit.c", "src/mux/muxi.h", "src/mux/muxinternal.c", "src/mux/muxread.c", ] all_dependent_configs = [ ":libwebp_config" ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] deps = [ ":libwebp_utils", ":libwebp_webp", ] } static_library("libwebp_dsp") { sources = [ "src/dsp/alpha_processing.c", "src/dsp/alpha_processing_mips_dsp_r2.c", "src/dsp/argb.c", "src/dsp/argb_mips_dsp_r2.c", "src/dsp/common_sse2.h", "src/dsp/cost.c", "src/dsp/cost_mips32.c", "src/dsp/cost_mips_dsp_r2.c", "src/dsp/cpu.c", "src/dsp/dec.c", "src/dsp/dec_clip_tables.c", "src/dsp/dec_mips32.c", "src/dsp/dec_mips_dsp_r2.c", "src/dsp/dec_msa.c", "src/dsp/dsp.h", "src/dsp/enc.c", "src/dsp/enc_avx2.c", "src/dsp/enc_mips32.c", "src/dsp/enc_mips_dsp_r2.c", "src/dsp/enc_msa.c", "src/dsp/filters.c", "src/dsp/filters_mips_dsp_r2.c", "src/dsp/filters_msa.c", "src/dsp/lossless.c", "src/dsp/lossless.h", "src/dsp/lossless_common.h", "src/dsp/lossless_enc.c", "src/dsp/lossless_enc_mips32.c", "src/dsp/lossless_enc_mips_dsp_r2.c", "src/dsp/lossless_enc_msa.c", "src/dsp/lossless_mips_dsp_r2.c", "src/dsp/lossless_msa.c", "src/dsp/neon.h", "src/dsp/rescaler.c", "src/dsp/rescaler_mips32.c", "src/dsp/rescaler_mips_dsp_r2.c", "src/dsp/rescaler_msa.c", "src/dsp/upsampling.c", "src/dsp/upsampling_mips_dsp_r2.c", "src/dsp/upsampling_msa.c", "src/dsp/yuv.c", "src/dsp/yuv.h", "src/dsp/yuv_mips32.c", "src/dsp/yuv_mips_dsp_r2.c", ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] if (set_opt_level) { configs -= [ "//build/config/compiler:default_optimization" ] configs += [ "//build/config/compiler:optimize_max" ] } all_dependent_configs = [ ":libwebp_config" ] deps = [ ":libwebp_dsp_sse2", ":libwebp_dsp_sse41", ":libwebp_utils", ":libwebp_webp", ] if (is_android) { deps += [ "//third_party/android_tools:cpu_features" ] configs -= [ "//build/config/android:default_cygprofile_instrumentation" ] configs += [ "//build/config/android:no_cygprofile_instrumentation" ] } if (current_cpu == "x86" || current_cpu == "x64") { defines = [ "WEBP_HAVE_SSE2", "WEBP_HAVE_SSE41", ] } } static_library("libwebp_dsp_sse41") { sources = [ "src/dsp/alpha_processing_sse41.c", "src/dsp/dec_sse41.c", "src/dsp/enc_sse41.c", "src/dsp/lossless_enc_sse41.c", ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] if (set_opt_level) { configs -= [ "//build/config/compiler:default_optimization" ] configs += [ "//build/config/compiler:optimize_max" ] } all_dependent_configs = [ ":libwebp_config" ] if (!is_msan) { if ((current_cpu == "x86" || current_cpu == "x64") && (!is_win || is_clang)) { cflags = [ "-msse4.1" ] } } } static_library("libwebp_dsp_sse2") { sources = [ "src/dsp/alpha_processing_sse2.c", "src/dsp/argb_sse2.c", "src/dsp/cost_sse2.c", "src/dsp/dec_sse2.c", "src/dsp/enc_sse2.c", "src/dsp/filters_sse2.c", "src/dsp/lossless_enc_sse2.c", "src/dsp/lossless_sse2.c", "src/dsp/rescaler_sse2.c", "src/dsp/upsampling_sse2.c", "src/dsp/yuv_sse2.c", ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] if (set_opt_level) { configs -= [ "//build/config/compiler:default_optimization" ] configs += [ "//build/config/compiler:optimize_max" ] } all_dependent_configs = [ ":libwebp_config" ] if (!is_msan) { if ((current_cpu == "x86" || current_cpu == "x64") && (!is_win || is_clang)) { cflags = [ "-msse2" ] } } } if (use_dsp_neon) { static_library("libwebp_dsp_neon") { sources = [ "src/dsp/alpha_processing_neon.c", "src/dsp/dec_neon.c", "src/dsp/enc_neon.c", "src/dsp/filters_neon.c", "src/dsp/lossless_enc_neon.c", "src/dsp/lossless_neon.c", "src/dsp/rescaler_neon.c", "src/dsp/upsampling_neon.c", ] include_dirs = [ "." ] if (set_opt_level) { configs -= [ "//build/config/compiler:default_optimization" ] configs += [ "//build/config/compiler:optimize_max" ] } if (current_cpu == "arm") { # behavior similar to *.c.neon in an Android.mk configs -= [ "//build/config/compiler:compiler_arm_fpu" ] cflags = [ "-mfpu=neon" ] } else if (current_cpu == "arm64" && !is_clang) { # avoid an ICE with gcc-4.9: b/15574841 cflags = [ "-frename-registers" ] } if (is_android) { configs -= [ "//build/config/android:default_cygprofile_instrumentation" ] configs += [ "//build/config/android:no_cygprofile_instrumentation" ] } } } # use_dsp_neon static_library("libwebp_enc") { sources = [ "src/enc/alpha_enc.c", "src/enc/analysis_enc.c", "src/enc/backward_references_enc.c", "src/enc/backward_references_enc.h", "src/enc/config_enc.c", "src/enc/cost_enc.c", "src/enc/cost_enc.h", "src/enc/delta_palettization_enc.c", "src/enc/delta_palettization_enc.h", "src/enc/filter_enc.c", "src/enc/frame_enc.c", "src/enc/histogram_enc.c", "src/enc/histogram_enc.h", "src/enc/iterator_enc.c", "src/enc/near_lossless_enc.c", "src/enc/picture_csp_enc.c", "src/enc/picture_enc.c", "src/enc/picture_psnr_enc.c", "src/enc/picture_rescale_enc.c", "src/enc/picture_tools_enc.c", "src/enc/predictor_enc.c", "src/enc/quant_enc.c", "src/enc/syntax_enc.c", "src/enc/token_enc.c", "src/enc/tree_enc.c", "src/enc/vp8i_enc.h", "src/enc/vp8l_enc.c", "src/enc/vp8li_enc.h", "src/enc/webp_enc.c", ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] if (set_opt_level) { configs -= [ "//build/config/compiler:default_optimization" ] configs += [ "//build/config/compiler:optimize_max" ] } all_dependent_configs = [ ":libwebp_config" ] deps = [ ":libwebp_utils", ":libwebp_webp", ] } config("libwebp_utils_warnings") { if (is_clang) { # See https://code.google.com/p/webp/issues/detail?id=253. cflags = [ "-Wno-incompatible-pointer-types" ] } } static_library("libwebp_utils") { sources = [ "src/utils/bit_reader_inl_utils.h", "src/utils/bit_reader_utils.c", "src/utils/bit_reader_utils.h", "src/utils/bit_writer_utils.c", "src/utils/bit_writer_utils.h", "src/utils/color_cache_utils.c", "src/utils/color_cache_utils.h", "src/utils/endian_inl_utils.h", "src/utils/filters_utils.c", "src/utils/filters_utils.h", "src/utils/huffman_encode_utils.c", "src/utils/huffman_encode_utils.h", "src/utils/huffman_utils.c", "src/utils/huffman_utils.h", "src/utils/quant_levels_dec_utils.c", "src/utils/quant_levels_dec_utils.h", "src/utils/quant_levels_utils.c", "src/utils/quant_levels_utils.h", "src/utils/random_utils.c", "src/utils/random_utils.h", "src/utils/rescaler_utils.c", "src/utils/rescaler_utils.h", "src/utils/thread_utils.c", "src/utils/thread_utils.h", "src/utils/utils.c", "src/utils/utils.h", ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] if (set_opt_level) { configs -= [ "//build/config/compiler:default_optimization" ] configs += [ "//build/config/compiler:optimize_max" ] } all_dependent_configs = [ ":libwebp_config" ] public_configs = [ ":libwebp_utils_warnings" ] } group("libwebp") { deps = [ ":libwebp_dec", ":libwebp_demux", ":libwebp_dsp", ":libwebp_enc", ":libwebp_mux", ":libwebp_utils", ] public_configs = [ ":libwebp_config" ] if (use_dsp_neon) { deps += [ ":libwebp_dsp_neon" ] } } ############################################################################### # Executables if (current_toolchain == host_toolchain) { source_set("example_util") { sources = [ "examples/example_util.c", "examples/example_util.h", ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] if (set_opt_level) { configs -= [ "//build/config/compiler:default_optimization" ] configs += [ "//build/config/compiler:optimize_max" ] } deps = [ ":libwebp_webp", ] configs += [ ":libwebp_config" ] visibility = [ ":*" ] } source_set("imageio_util") { sources = [ "imageio/imageio_util.c", "imageio/imageio_util.h", ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] if (set_opt_level) { configs -= [ "//build/config/compiler:default_optimization" ] configs += [ "//build/config/compiler:optimize_max" ] } deps = [ ":libwebp_webp", ] configs += [ ":libwebp_config" ] visibility = [ ":*" ] } source_set("imagedec") { sources = [ "imageio/image_dec.c", "imageio/image_dec.h", "imageio/jpegdec.c", "imageio/jpegdec.h", "imageio/metadata.c", "imageio/metadata.h", "imageio/pngdec.c", "imageio/pngdec.h", "imageio/tiffdec.c", "imageio/tiffdec.h", "imageio/webpdec.c", "imageio/webpdec.h", "imageio/wicdec.c", "imageio/wicdec.h", ] defines = [ "WEBP_HAVE_PNG" ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] if (set_opt_level) { configs -= [ "//build/config/compiler:default_optimization" ] configs += [ "//build/config/compiler:optimize_max" ] } deps = [ ":libwebp_webp", "//third_party/libpng", "//third_party/zlib", ] configs += [ ":libwebp_config" ] visibility = [ ":*" ] } source_set("imageenc") { sources = [ "imageio/image_enc.c", "imageio/image_enc.h", ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] if (set_opt_level) { configs -= [ "//build/config/compiler:default_optimization" ] configs += [ "//build/config/compiler:optimize_max" ] } deps = [ ":libwebp_webp", ] configs += [ ":libwebp_config" ] visibility = [ ":*" ] } executable("cwebp") { sources = [ "examples/cwebp.c", "examples/stopwatch.h", ] deps = [ ":example_util", ":imagedec", ":imageio_util", ":libwebp", "//base", "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] if (set_opt_level) { configs -= [ "//build/config/compiler:default_optimization" ] configs += [ "//build/config/compiler:optimize_max" ] } } executable("dwebp") { sources = [ "examples/dwebp.c", "examples/stopwatch.h", ] deps = [ ":example_util", ":imagedec", ":imageenc", ":imageio_util", ":libwebp", "//base", "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] if (set_opt_level) { configs -= [ "//build/config/compiler:default_optimization" ] configs += [ "//build/config/compiler:optimize_max" ] } } }