| # Copyright 2019 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| # Note this leads to "$root_out_dir/obj/ABS_PATH/..." files in the build. |
| zstd = "$zx/../third_party/zstd" |
| |
| config("zstd-config") { |
| visibility = [ ":*" ] |
| |
| include_dirs = [ |
| "$zstd/contrib/seekable_format", |
| "$zstd/lib", |
| "$zstd/lib/common", |
| "$zstd/lib/compress", |
| "$zstd/lib/dictBuilder", |
| ] |
| |
| configs = [ "$zx_build/public/gn/config:visibility_hidden" ] |
| defines = [ |
| "ZDICTLIB_VISIBILITY=", |
| "ZSTDERRORLIB_VISIBILITY=", |
| "ZSTDLIB_VISIBILITY=", |
| "XXH_NAMESPACE=ZSTD_", |
| ] |
| |
| if (is_host) { |
| defines += [ "ZSTD_MULTITHREAD" ] |
| } |
| |
| # TODO(41757): UBSan has found an instance of undefined behavior in this target. |
| # Disable UBSan for this target temporarily until it is migrated into CI/CQ. |
| configs += |
| [ "$zx_build/public/gn/config:temporarily_disable_ubsan_do_not_use" ] |
| } |
| |
| zx_library("zstd") { |
| host = true |
| |
| # Exported as a static library as the config above cannot be conveyed via the |
| # exporting mechanism but is absolutely necessary in order to properly compile |
| # this library. |
| sdk = "static" |
| sdk_headers = [ "zstd/zstd.h" ] |
| |
| sources = [ |
| "$zstd/lib/common/debug.c", |
| "$zstd/lib/common/entropy_common.c", |
| "$zstd/lib/common/error_private.c", |
| "$zstd/lib/common/fse_decompress.c", |
| "$zstd/lib/common/pool.c", |
| "$zstd/lib/common/threading.c", |
| "$zstd/lib/common/xxhash.c", |
| "$zstd/lib/common/zstd_common.c", |
| "$zstd/lib/compress/fse_compress.c", |
| "$zstd/lib/compress/hist.c", |
| "$zstd/lib/compress/huf_compress.c", |
| "$zstd/lib/compress/zstd_compress.c", |
| "$zstd/lib/compress/zstd_compress_literals.c", |
| "$zstd/lib/compress/zstd_compress_sequences.c", |
| "$zstd/lib/compress/zstd_double_fast.c", |
| "$zstd/lib/compress/zstd_fast.c", |
| "$zstd/lib/compress/zstd_lazy.c", |
| "$zstd/lib/compress/zstd_ldm.c", |
| "$zstd/lib/compress/zstd_opt.c", |
| "$zstd/lib/compress/zstdmt_compress.c", |
| "$zstd/lib/decompress/huf_decompress.c", |
| "$zstd/lib/decompress/zstd_ddict.c", |
| "$zstd/lib/decompress/zstd_decompress.c", |
| "$zstd/lib/decompress/zstd_decompress_block.c", |
| "$zstd/lib/dictBuilder/cover.c", |
| "$zstd/lib/dictBuilder/divsufsort.c", |
| "$zstd/lib/dictBuilder/fastcover.c", |
| "$zstd/lib/dictBuilder/zdict.c", |
| ] |
| |
| configs += [ ":zstd-config" ] |
| |
| # This code doesn't use the annotation attribute. |
| configs -= [ "$zx_build/public/gn/config:warn-implicit-fallthrough" ] |
| } |
| |
| config("zstd-seekable-config") { |
| visibility = [ ":*" ] |
| |
| # TODO(markdittmer): Upstream fixes to uninitialized variables in zstd. |
| if (is_gcc) { |
| cflags = [ "-Wno-maybe-uninitialized" ] |
| } else { |
| cflags = [ "-Wno-sometimes-uninitialized" ] |
| } |
| } |
| |
| config("zstd-seekable-public-config") { |
| visibility = [ ":*" ] |
| |
| # Seekable library expects |
| # #include "zstd.h" |
| # to load zstd's lib/zstd.h. |
| include_dirs = [ "$zstd/lib" ] |
| } |
| |
| zx_library("zstdseek") { |
| host = true |
| sources = [ |
| "$zstd/contrib/seekable_format/zstdseek_compress.c", |
| "$zstd/contrib/seekable_format/zstdseek_decompress.c", |
| ] |
| |
| public_deps = [ ":zstd" ] |
| |
| # Compilation units loading seekable must incorporate its config's include_dirs. |
| public_configs = [ ":zstd-seekable-public-config" ] |
| |
| configs += [ |
| ":zstd-config", |
| ":zstd-seekable-config", |
| ] |
| |
| # This code doesn't use the annotation attribute. |
| configs -= [ "$zx_build/public/gn/config:warn-implicit-fallthrough" ] |
| } |
| |
| zx_host_tool("zstdcli") { |
| output_name = "zstd" |
| sources = [ |
| "$zstd/programs/benchfn.c", |
| "$zstd/programs/benchzstd.c", |
| "$zstd/programs/datagen.c", |
| "$zstd/programs/dibio.c", |
| "$zstd/programs/fileio.c", |
| "$zstd/programs/timefn.c", |
| "$zstd/programs/util.c", |
| "$zstd/programs/zstdcli.c", |
| ] |
| deps = [ ":zstd" ] |
| configs += [ ":zstd-config" ] |
| } |