add chromium_zlib (#1014)

* update meson

* add chromium_zlib

* fix simd instructions

* improve simd flags

* disable simd for cross platform

* fix android

* add missing file
pull/1017/head
Hoildkv 3 years ago committed by GitHub
parent d19a320e21
commit 182a7a6ad7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 95
      packages/c/chromium_zlib/port/xmake.lua
  2. 27
      packages/c/chromium_zlib/xmake.lua
  3. 1
      packages/m/meson/xmake.lua

@ -0,0 +1,95 @@
set_project("zlib")
set_languages("c++11")
add_rules("mode.debug", "mode.release")
target("zlib")
set_kind("static")
if not is_plat("windows") then
set_basename("z")
end
if is_plat("linux") then
add_syslinks("pthread")
end
add_files("adler32.c", "compress.c", "cpu_features.c", "crc32.c", "deflate.c")
add_files("gzclose.c", "gzlib.c", "gzread.c", "gzwrite.c")
add_files("infback.c", "inffast.c", "inftrees.c", "trees.c", "uncompr.c", "zutil.c")
add_headerfiles("zlib.h", "zconf.h", "chromeconf.h", "deflate.h", "inffast.h", "inffixed.h", "inflate.h", "inftrees.h", "zutil.h")
add_includedirs(".", {public = true})
-- SIMD settings
on_load(function (target)
import("core.tool.toolchain")
if is_plat("android") then
local ndk = toolchain.load("ndk"):config("ndk")
target:add("includedirs", path.join(ndk, "sources", "android", "cpufeatures"))
target:add("files", path.join(ndk, "sources", "android", "cpufeatures", "cpu-features.c"))
end
end)
if is_plat("cross") then
add_defines("CPU_NO_SIMD")
add_files("inflate.c")
elseif is_arch("x86", "x64", "x86_64") then
add_defines("CRC32_SIMD_SSE42_PCLMUL", "DEFLATE_FILL_WINDOW_SSE2")
add_files("crc32_simd.c", "crc_folding.c", "fill_window_sse.c")
add_defines("ADLER32_SIMD_SSSE3", "INFLATE_CHUNK_SIMD_SSE2")
add_files("adler32_simd.c", "contrib/optimizations/inffast_chunk.c", "contrib/optimizations/inflate.c")
if is_plat("windows") then
add_vectorexts("avx")
else
add_cflags("-msse4.2", "-mssse3", "-mpclmul")
end
add_defines(is_plat("windows") and "X86_WINDOWS" or "X86_NOT_WINDOWS")
if is_arch(".+64") then
add_defines("INFLATE_CHUNK_READ_64LE")
end
elseif is_arch("arm.*") then
add_defines("ADLER32_SIMD_NEON", "INFLATE_CHUNK_SIMD_NEON")
add_files("adler32_simd.c", "contrib/optimizations/inffast_chunk.c", "contrib/optimizations/inflate.c")
if is_arch(".+64") then
add_defines("INFLATE_CHUNK_READ_64LE")
end
if not is_plat("iphoneos") then
-- ARM v8 architecture
add_defines("CRC32_ARMV8_CRC32")
if not is_plat("windows", "android") then
add_cflags("-march=armv8-a+crc")
end
if is_plat("android") then
add_defines("ARMV8_OS_ANDROID")
elseif is_plat("linux") then
add_defines("ARMV8_OS_LINUX")
elseif is_plat("windows") then
add_defines("ARMV8_OS_WINDOWS")
elseif is_plat("macosx") then
add_defines("ARMV8_OS_MACOS")
else
os.raise("Unsupported ARM OS")
end
add_files("crc32_simd.c")
end
else
add_defines("CPU_NO_SIMD")
add_files("inflate.c")
end
target("minizip")
set_kind("static")
add_deps("zlib")
add_files("contrib/minizip/ioapi.c",
"contrib/minizip/unzip.c",
"contrib/minizip/zip.c")
add_headerfiles("contrib/minizip/ioapi.h",
"contrib/minizip/unzip.h",
"contrib/minizip/zip.h")
if is_plat("windows") then
add_files("contrib/minizip/iowin32.c")
add_headerfiles("contrib/minizip/iowin32.h")
elseif is_plat("macosx", "iphoneos") then
add_defines("USE_FILE32API")
end
target("compression_utils_portable")
set_kind("static")
add_deps("zlib")
add_files("google/compression_utils_portable.cc")
add_headerfiles("google/compression_utils_portable.h")

@ -0,0 +1,27 @@
package("chromium_zlib")
set_homepage("https://chromium.googlesource.com/chromium/src/third_party/zlib/")
set_description("zlib from chromium")
set_license("zlib")
add_urls("https://github.com/xmake-mirror/chromium_zlib.git")
add_urls("https://chromium.googlesource.com/chromium/src/third_party/zlib.git")
add_versions("2022.02.22", "6f44c22c1f003bd20011062abec283678842567c")
add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
if is_plat("linux") then
add_syslinks("pthread")
end
on_install(function (package)
for _, f in ipairs(table.join(os.files("contrib/minizip/*.c"), os.files("contrib/minizip/*.h"))) do
io.replace(f, "third_party/zlib/zlib.h", "zlib.h", {plain = true})
end
os.cp(path.join(os.scriptdir(), "port", "xmake.lua"), ".")
import("package.tools.xmake").install(package)
end)
on_test(function (package)
assert(package:has_cfuncs("inflate", {includes = "zlib.h"}))
end)

@ -7,6 +7,7 @@ package("meson")
add_urls("https://github.com/mesonbuild/meson/releases/download/$(version)/meson-$(version).tar.gz",
"https://github.com/mesonbuild/meson.git")
add_versions("0.61.2", "0233a7f8d959079318f6052b0939c27f68a5de86ba601f25c9ee6869fb5f5889")
add_versions("0.60.1", "5add789c953d984b500858b2851ee3d7add0460cf1a6f852f0a721af17384e13")
add_versions("0.59.2", "13dee549a7ba758b7e33ce7719f28d1d337a98d10d378a4779ccc996f5a2fc49")
add_versions("0.59.1", "db586a451650d46bbe10984a87b79d9bcdc1caebf38d8e189f8848f8d502356d")

Loading…
Cancel
Save