parent
94a896cfdd
commit
fc9b07c8f4
3 changed files with 112 additions and 47 deletions
@ -0,0 +1,31 @@ |
||||
diff --git a/c/common/platform.h b/c/common/platform.h
|
||||
index f5ca4435..7e5807da 100644
|
||||
--- a/c/common/platform.h
|
||||
+++ b/c/common/platform.h
|
||||
@@ -40,7 +40,7 @@
|
||||
#define BROTLI_X_BIG_ENDIAN BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
-#if BROTLI_MSVC_VERSION_CHECK(12, 0, 0)
|
||||
+#if BROTLI_MSVC_VERSION_CHECK(18, 0, 0)
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
|
||||
@@ -529,7 +529,7 @@ BROTLI_MIN_MAX(size_t) BROTLI_MIN_MAX(uint32_t) BROTLI_MIN_MAX(uint8_t)
|
||||
#if BROTLI_GNUC_HAS_BUILTIN(__builtin_ctzll, 3, 4, 0) || \
|
||||
BROTLI_INTEL_VERSION_CHECK(16, 0, 0)
|
||||
#define BROTLI_TZCNT64 __builtin_ctzll
|
||||
-#elif BROTLI_MSVC_VERSION_CHECK(12, 0, 0)
|
||||
+#elif BROTLI_MSVC_VERSION_CHECK(18, 0, 0)
|
||||
#if defined(BROTLI_TARGET_X64)
|
||||
#define BROTLI_TZCNT64 _tzcnt_u64
|
||||
#else /* BROTLI_TARGET_X64 */
|
||||
@@ -546,7 +546,7 @@ static BROTLI_INLINE uint32_t BrotliBsf64Msvc(uint64_t x) {
|
||||
#if BROTLI_GNUC_HAS_BUILTIN(__builtin_clz, 3, 4, 0) || \
|
||||
BROTLI_INTEL_VERSION_CHECK(16, 0, 0)
|
||||
#define BROTLI_BSR32(x) (31u ^ (uint32_t)__builtin_clz(x))
|
||||
-#elif BROTLI_MSVC_VERSION_CHECK(12, 0, 0)
|
||||
+#elif BROTLI_MSVC_VERSION_CHECK(18, 0, 0)
|
||||
static BROTLI_INLINE uint32_t BrotliBsr32Msvc(uint32_t x) {
|
||||
unsigned long msb;
|
||||
_BitScanReverse(&msb, x);
|
@ -0,0 +1,21 @@ |
||||
diff --git a/c/tools/brotli.c b/c/tools/brotli.c
|
||||
index 7c678d3..8f55f2f 100644
|
||||
--- a/c/tools/brotli.c
|
||||
+++ b/c/tools/brotli.c
|
||||
@@ -876,6 +876,7 @@ static void PrintFileProcessingProgress(Context* context) {
|
||||
}
|
||||
|
||||
static BROTLI_BOOL DecompressFile(Context* context, BrotliDecoderState* s) {
|
||||
+ int has_more_input;
|
||||
BrotliDecoderResult result = BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT;
|
||||
InitializeBuffers(context);
|
||||
for (;;) {
|
||||
@@ -890,7 +891,7 @@ static BROTLI_BOOL DecompressFile(Context* context, BrotliDecoderState* s) {
|
||||
if (!ProvideOutput(context)) return BROTLI_FALSE;
|
||||
} else if (result == BROTLI_DECODER_RESULT_SUCCESS) {
|
||||
if (!FlushOutput(context)) return BROTLI_FALSE;
|
||||
- int has_more_input =
|
||||
+ has_more_input =
|
||||
(context->available_in != 0) || (fgetc(context->fin) != EOF);
|
||||
if (has_more_input) {
|
||||
fprintf(stderr, "corrupt input [%s]\n",
|
@ -1,47 +1,60 @@ |
||||
package("brotli") |
||||
|
||||
set_homepage("https://github.com/google/brotli") |
||||
set_description("Brotli compression format.") |
||||
|
||||
set_urls("https://github.com/google/brotli/archive/v$(version).tar.gz", |
||||
"https://github.com/google/brotli.git") |
||||
|
||||
add_versions("1.0.9", "f9e8d81d0405ba66d181529af42a3354f838c939095ff99930da6aa9cdf6fe46") |
||||
|
||||
add_deps("cmake") |
||||
|
||||
on_load("linux", function (package) |
||||
if package:config("shared") then |
||||
package:add("links", "brotlidec", "brotlienc", "brotlicommon") |
||||
else |
||||
package:add("links", "brotlidec-static", "brotlienc-static", "brotlicommon-static") |
||||
end |
||||
end) |
||||
|
||||
on_install("linux", "macosx", "windows", function(package) |
||||
local configs = {"-DBUILD_TESTING=OFF"} |
||||
-- NOTE: BUILD_SHARED_LIBS not supported now, may be added in future. |
||||
-- table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) |
||||
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) |
||||
import("package.tools.cmake").install(package, configs, {buildir = "builddir"}) |
||||
os.cp("builddir/install/bin", package:installdir()) |
||||
if package:config("shared") then |
||||
os.rm(path.join(package:installdir("lib"), "*-static.*")) |
||||
else |
||||
for _, name in ipairs({"brotlicommon", "brotlienc", "brotlidec"}) do |
||||
os.rm(path.join(package:installdir("lib"), "*" .. name .. ".*")) |
||||
os.rm(path.join(package:installdir("bin"), name .. ".dll")) |
||||
end |
||||
end |
||||
package:addenv("PATH", "bin") |
||||
end) |
||||
|
||||
on_test(function(package) |
||||
os.vrun("brotli --version") |
||||
assert(package:check_csnippets([[ |
||||
void test() { |
||||
BrotliEncoderState* s = BrotliEncoderCreateInstance(NULL, NULL, NULL); |
||||
BrotliEncoderDestroyInstance(s); |
||||
} |
||||
]], {includes = "brotli/encode.h"})) |
||||
end) |
||||
package("brotli") |
||||
|
||||
set_homepage("https://github.com/google/brotli") |
||||
set_description("Brotli compression format.") |
||||
|
||||
set_urls("https://github.com/google/brotli/archive/v$(version).tar.gz", |
||||
"https://github.com/google/brotli.git") |
||||
|
||||
add_versions("1.0.9", "f9e8d81d0405ba66d181529af42a3354f838c939095ff99930da6aa9cdf6fe46") |
||||
|
||||
-- Fix VC C++ 12.0 BROTLI_MSVC_VERSION_CHECK calls |
||||
-- VC <= 2012 build failed |
||||
if is_plat("windows") then |
||||
add_patches("1.0.9", path.join(os.scriptdir(), "patches", "1.0.9", "common_platform.patch"), |
||||
"5d7363a6ed1f9a504dc7af08920cd184f0d04d1ad12d25d657364cf0a2dae6bb") |
||||
add_patches("1.0.9", path.join(os.scriptdir(), "patches", "1.0.9", "tool_brotli.patch"), |
||||
"333e2a0306cf33f2fac381aa6b81afd3d1237e7511e5cc8fe7fb760d16d01ca1") |
||||
end |
||||
|
||||
on_load(function (package) |
||||
package:addenv("PATH", "bin") |
||||
end) |
||||
|
||||
on_install(function (package) |
||||
io.writefile("xmake.lua", [[ |
||||
add_rules("mode.debug", "mode.release") |
||||
target("brotli") |
||||
set_kind("$(kind)") |
||||
add_includedirs("c/include", {public = true}) |
||||
add_files("c/common/*.c", "c/dec/*.c", "c/enc/*.c") |
||||
if is_kind("shared") and is_plat("windows") then |
||||
add_defines("BROTLI_SHARED_COMPILATION", |
||||
"BROTLICOMMON_SHARED_COMPILATION", |
||||
"BROTLIENC_SHARED_COMPILATION", |
||||
"BROTLIDEC_SHARED_COMPILATION") |
||||
end |
||||
add_headerfiles("c/include/(brotli/*.h)") |
||||
target("brotlibin") |
||||
set_kind("binary") |
||||
add_files("c/tools/brotli.c") |
||||
add_deps("brotli") |
||||
]]) |
||||
local configs = {buildir = "xbuild"} |
||||
if package:config("shared") then |
||||
configs.kind = "shared" |
||||
end |
||||
import("package.tools.xmake").install(package, configs) |
||||
end) |
||||
|
||||
on_test(function(package) |
||||
if package:is_plat(os.host()) then |
||||
os.vrun("brotlibin --version") |
||||
end |
||||
assert(package:check_csnippets([[ |
||||
void test() { |
||||
BrotliEncoderState* s = BrotliEncoderCreateInstance(NULL, NULL, NULL); |
||||
BrotliEncoderDestroyInstance(s); |
||||
} |
||||
]], {includes = "brotli/encode.h"})) |
||||
end) |
Loading…
Reference in new issue