# Copyright 2016 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. # Configuration. Ordinarily, all of these features are enabled, and # "small" is disabled. For Chromium's purposes, enable "small" and disable # nearly everything else to save about 36kB in the lzma_decompress # library, which will be distributed with updates. This also translates to # a 25kB savings in the compressed disk image that will contain the # update. _check_crc32 = true _check_crc64 = false _check_sha256 = false _coder_lzma1 = false _coder_lzma2 = true _coder_delta = false _coder_bcj_arm = false _coder_bcj_armthumb = false _coder_bcj_ia64 = false _coder_bcj_powerpc = false _coder_bcj_sparc = false _coder_bcj_x86 = true _coder_simple = _coder_bcj_arm || _coder_bcj_armthumb || _coder_bcj_ia64 || _coder_bcj_powerpc || _coder_bcj_sparc || _coder_bcj_x86 _small = true config("common_config") { visibility = [ ":*" ] defines = [ "HAVE_CONFIG_H" ] include_dirs = [ "config/$host_os", "xz/src/common", "xz/src/liblzma/api", "xz/src/liblzma/check", "xz/src/liblzma/common", "xz/src/liblzma/delta", "xz/src/liblzma/lz", "xz/src/liblzma/lzma", "xz/src/liblzma/rangecoder", "xz/src/liblzma/simple", ] if (_small) { defines += [ "HAVE_SMALL=1" ] } if (_check_crc32) { defines += [ "HAVE_CHECK_CRC32=1" ] } if (_check_crc64) { defines += [ "HAVE_CHECK_CRC64=1" ] } if (_check_sha256) { defines += [ "HAVE_CHECK_SHA256=1" ] } } config("decompress_config") { visibility = [ ":*" ] defines = [] if (_coder_lzma1) { defines += [ "HAVE_DECODER_LZMA1=1" ] } if (_coder_lzma2) { defines += [ "HAVE_DECODER_LZMA2=1" ] } if (_coder_delta) { defines += [ "HAVE_DECODER_DELTA=1" ] } if (_coder_bcj_arm) { defines += [ "HAVE_DECODER_ARM=1" ] } if (_coder_bcj_armthumb) { defines += [ "HAVE_DECODER_ARMTHUMB=1" ] } if (_coder_bcj_ia64) { defines += [ "HAVE_DECODER_IA64=1" ] } if (_coder_bcj_powerpc) { defines += [ "HAVE_DECODER_POWERPC=1" ] } if (_coder_bcj_sparc) { defines += [ "HAVE_DECODER_SPARC=1" ] } if (_coder_bcj_x86) { defines += [ "HAVE_DECODER_X86=1" ] } } config("compress_config") { visibility = [ ":*" ] defines = [] if (_coder_lzma1) { defines += [ "HAVE_ENCODER_LZMA1=1" ] } if (_coder_lzma2) { defines += [ "HAVE_ENCODER_LZMA2=1" ] } if (_coder_delta) { defines += [ "HAVE_ENCODER_DELTA=1" ] } if (_coder_bcj_arm) { defines += [ "HAVE_ENCODER_ARM=1" ] } if (_coder_bcj_armthumb) { defines += [ "HAVE_ENCODER_ARMTHUMB=1" ] } if (_coder_bcj_ia64) { defines += [ "HAVE_ENCODER_IA64=1" ] } if (_coder_bcj_powerpc) { defines += [ "HAVE_ENCODER_POWERPC=1" ] } if (_coder_bcj_sparc) { defines += [ "HAVE_ENCODER_SPARC=1" ] } if (_coder_bcj_x86) { defines += [ "HAVE_ENCODER_X86=1" ] } } source_set("common") { visibility = [ ":*" ] configs += [ ":common_config", ":compress_config", ":decompress_config", ] sources = [ "xz/src/common/tuklib_physmem.c", "xz/src/liblzma/check/check.c", "xz/src/liblzma/common/block_util.c", "xz/src/liblzma/common/common.c", "xz/src/liblzma/common/easy_preset.c", "xz/src/liblzma/common/filter_common.c", "xz/src/liblzma/common/hardware_physmem.c", "xz/src/liblzma/common/index.c", "xz/src/liblzma/common/stream_flags_common.c", "xz/src/liblzma/common/vli_size.c", "xz/src/liblzma/lzma/lzma_encoder_presets.c", "xz/src/liblzma/rangecoder/price_table.c", ] if (_small) { sources += [ # CRC-32 must be compiled for header integrity checks, even if it is # not enabled for payload integrity checks. "xz/src/liblzma/check/crc32_small.c", ] if (_check_crc64) { sources += [ "xz/src/liblzma/check/crc64_small.c" ] } } else { sources += [ # CRC-32 must be compiled for header integrity checks, even if it is # not enabled for payload integrity checks. # # Use the "fast" implementation instead of the "x86" one for # architecture independence. Both require the "table." "xz/src/liblzma/check/crc32_fast.c", "xz/src/liblzma/check/crc32_table.c", # "xz/src/liblzma/check/crc32_x86.S", ] if (_check_crc64) { sources += [ # Use the "fast" implementation instead of the "x86" one for # architecture independence. Both require the "table." "xz/src/liblzma/check/crc64_fast.c", "xz/src/liblzma/check/crc64_table.c", # "xz/src/liblzma/check/crc64_x86.S", ] } } if (_check_sha256) { sources += [ "xz/src/liblzma/check/sha256.c" ] } if (_coder_delta) { sources += [ "xz/src/liblzma/delta/delta_common.c" ] } if (_coder_bcj_arm) { sources += [ "xz/src/liblzma/simple/arm.c" ] } if (_coder_bcj_armthumb) { sources += [ "xz/src/liblzma/simple/armthumb.c" ] } if (_coder_bcj_ia64) { sources += [ "xz/src/liblzma/simple/ia64.c" ] } if (_coder_bcj_powerpc) { sources += [ "xz/src/liblzma/simple/powerpc.c" ] } if (_coder_bcj_sparc) { sources += [ "xz/src/liblzma/simple/sparc.c" ] } if (_coder_bcj_x86) { sources += [ "xz/src/liblzma/simple/x86.c" ] } if (_coder_simple) { sources += [ "xz/src/liblzma/simple/simple_coder.c" ] } } source_set("decompress") { visibility = [ ":*" ] configs += [ ":common_config", ":decompress_config", ] sources = [ "xz/src/liblzma/common/alone_decoder.c", "xz/src/liblzma/common/auto_decoder.c", "xz/src/liblzma/common/block_buffer_decoder.c", "xz/src/liblzma/common/block_decoder.c", "xz/src/liblzma/common/block_header_decoder.c", "xz/src/liblzma/common/easy_decoder_memusage.c", "xz/src/liblzma/common/filter_buffer_decoder.c", "xz/src/liblzma/common/filter_decoder.c", "xz/src/liblzma/common/filter_flags_decoder.c", "xz/src/liblzma/common/index_decoder.c", "xz/src/liblzma/common/index_hash.c", "xz/src/liblzma/common/stream_buffer_decoder.c", "xz/src/liblzma/common/stream_decoder.c", "xz/src/liblzma/common/stream_flags_decoder.c", "xz/src/liblzma/common/vli_decoder.c", "xz/src/liblzma/lz/lz_decoder.c", "xz/src/liblzma/lzma/lzma_decoder.c", ] if (_coder_lzma2) { sources += [ "xz/src/liblzma/lzma/lzma2_decoder.c" ] } if (_coder_delta) { sources += [ "xz/src/liblzma/delta/delta_decoder.c" ] } if (_coder_simple) { sources += [ "xz/src/liblzma/simple/simple_decoder.c" ] } cflags = [ # Use -Os to minimize the size of the installer tools. "-Os", ] } source_set("compress") { visibility = [ ":*" ] configs += [ ":common_config", ":compress_config", ] sources = [ "xz/src/liblzma/common/alone_encoder.c", "xz/src/liblzma/common/block_buffer_encoder.c", "xz/src/liblzma/common/block_encoder.c", "xz/src/liblzma/common/block_header_encoder.c", "xz/src/liblzma/common/easy_buffer_encoder.c", "xz/src/liblzma/common/easy_encoder.c", "xz/src/liblzma/common/easy_encoder_memusage.c", "xz/src/liblzma/common/filter_buffer_encoder.c", "xz/src/liblzma/common/filter_encoder.c", "xz/src/liblzma/common/filter_flags_encoder.c", "xz/src/liblzma/common/index_encoder.c", "xz/src/liblzma/common/stream_buffer_encoder.c", "xz/src/liblzma/common/stream_encoder.c", "xz/src/liblzma/common/stream_flags_encoder.c", "xz/src/liblzma/common/vli_encoder.c", "xz/src/liblzma/lz/lz_encoder.c", "xz/src/liblzma/lz/lz_encoder_mf.c", "xz/src/liblzma/lzma/lzma_encoder.c", "xz/src/liblzma/lzma/lzma_encoder_optimum_fast.c", "xz/src/liblzma/lzma/lzma_encoder_optimum_normal.c", ] if (!_small) { sources += [ "xz/src/liblzma/lzma/fastpos_table.c" ] } if (_coder_lzma2) { sources += [ "xz/src/liblzma/lzma/lzma2_encoder.c" ] } if (_coder_delta) { sources += [ "xz/src/liblzma/delta/delta_encoder.c" ] } if (_coder_simple) { sources += [ "xz/src/liblzma/simple/simple_encoder.c" ] } } config("lzma_decompress_config") { include_dirs = [ "xz/src/liblzma/api" ] } source_set("lzma") { deps = [ ":common", ":compress", ":decompress", ] configs += [ ":common_config", ":decompress_config", ":compress_config", ] public_configs = [ ":lzma_decompress_config" ] } # Always build as a shared library to promote code sharing. This library # is distributed in Google Chrome update disk images and is used by more # than one tool. shared_library("lzma_decompress") { configs += [ ":common_config", ":decompress_config", ] public_configs = [ ":lzma_decompress_config" ] deps = [ ":common", ":decompress", ] ldflags = [ # The library will reside in the same directory as executables linked # against it. "-Wl,-install_name,@loader_path/lib$target_name.dylib", # Trim the list of exported symbols to just those needed by # dependents. This limits the set of "roots" seen during dead-code # stripping and reduces the size of the library. "-Wl,-exported_symbols_list," + rebase_path("lzma_decompress.export", root_build_dir), ] } executable("xz") { configs += [ ":common_config", ":decompress_config", ":compress_config", ] sources = [ "xz/src/common/tuklib_cpucores.c", "xz/src/common/tuklib_exit.c", "xz/src/common/tuklib_mbstr_fw.c", "xz/src/common/tuklib_mbstr_width.c", "xz/src/common/tuklib_open_stdxxx.c", "xz/src/common/tuklib_progname.c", "xz/src/xz/args.c", "xz/src/xz/coder.c", "xz/src/xz/file_io.c", "xz/src/xz/hardware.c", "xz/src/xz/list.c", "xz/src/xz/main.c", "xz/src/xz/message.c", "xz/src/xz/options.c", "xz/src/xz/signals.c", "xz/src/xz/suffix.c", "xz/src/xz/util.c", ] deps = [ ":lzma", ] include_dirs = [ "config/$host_os", "xz/src/common", ] } executable("xzdec") { configs += [ ":common_config", ":decompress_config", ] sources = [ "xz/src/common/tuklib_exit.c", "xz/src/common/tuklib_progname.c", "xz/src/xzdec/xzdec.c", ] deps = [ ":lzma_decompress", ] include_dirs = [ "config/$host_os", "xz/src/common", ] cflags = [ # Use -Os to minimize the size of the installer tools. "-Os", ] }