aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Nemerson <evan@nemerson.com>2016-07-28 13:31:09 -0700
committerEvan Nemerson <evan@nemerson.com>2016-07-28 19:32:33 -0700
commit03657e8089d9022bbc8950b32d2c7fe07585572b (patch)
tree3940d2ecee2df486c854facc512a27cc11355c0e
parentbd3a5ada1a76841555411c597731a144f1a4eed4 (diff)
downloadbrotli-03657e8089d9022bbc8950b32d2c7fe07585572b.zip
brotli-03657e8089d9022bbc8950b32d2c7fe07585572b.tar.gz
brotli-03657e8089d9022bbc8950b32d2c7fe07585572b.tar.bz2
Add mingw support.
-rwxr-xr-x.travis.sh6
-rw-r--r--.travis.yml20
-rw-r--r--CMakeLists.txt24
-rw-r--r--common/types.h2
-rw-r--r--tests/run-compatibility-test.cmake2
-rw-r--r--tests/run-roundtrip-test.cmake13
-rw-r--r--tools/bro.c3
7 files changed, 59 insertions, 11 deletions
diff --git a/.travis.sh b/.travis.sh
index 2e8c2af..33cfe75 100755
--- a/.travis.sh
+++ b/.travis.sh
@@ -27,7 +27,11 @@ case "$1" in
case "${BUILD_SYSTEM}" in
"cmake")
mkdir builddir && cd builddir
- cmake -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" -DENABLE_SANITIZER="${SANITIZER}" -DCMAKE_C_FLAGS="${CFLAGS}" ..
+ CMAKE_FLAGS=
+ if [ "${CROSS_COMPILE}" = "yes" ]; then
+ CMAKE_FLAGS="-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RC_COMPILER=${RC_COMPILER}"
+ fi
+ cmake ${CMAKE_FLAGS} -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" -DENABLE_SANITIZER="${SANITIZER}" -DCMAKE_C_FLAGS="${CFLAGS}" ..
make VERBOSE=1
ctest -V
;;
diff --git a/.travis.yml b/.travis.yml
index 563e368..5f58531 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -204,6 +204,26 @@ matrix:
packages:
- clang-3.8
+ ###
+ ## mingw
+ ###
+ - os: linux
+ env: BUILD_SYSTEM=cmake C_COMPILER=x86_64-w64-mingw32-gcc CXX_COMPILER=x86_64-w64-mingw32-g++ RC_COMPILER=x86_64-w64-mingw32-windres CROSS_COMPILE=yes
+ addons:
+ apt:
+ sources:
+ - ubuntu-toolchain-r-test
+ - george-edison55-precise-backports
+ packages:
+ - binutils-mingw-w64-x86-64
+ - g++-mingw-w64-x86-64
+ - gcc-mingw-w64-x86-64
+ - binutils-mingw-w64-x86-64
+ - wine
+ # Because 2.8.6 passes -rdynamic to the linker, which breaks the build.
+ - cmake
+ - cmake-data
+
before_install:
###
## If we use the matrix to set CC/CXX Travis, overwrites the values,
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9d55711..0004461 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -113,6 +113,20 @@ if(NOT BROTLI_BUNDLE_MODE)
endif()
# Tests
+
+# If we're targeting Windows but not running on Windows, we need Wine
+# to run the tests...
+if(NOT BROTLI_DISABLE_TESTS)
+ if(WIN32 AND NOT CMAKE_HOST_WIN32)
+ find_program(BROTLI_WINE NAMES wine)
+ endif()
+
+ if(NOT BROTLI_WINE AND NOT BROTLI_WINEPATH)
+ message("wine not found, disabling tests")
+ set(BROTLI_DISABLE_TESTS TRUE)
+ endif()
+endif()
+
if(NOT BROTLI_DISABLE_TESTS)
include(CTest)
enable_testing()
@@ -127,12 +141,19 @@ if(NOT BROTLI_DISABLE_TESTS)
dec/decode.c)
foreach(INPUT ${ROUNDTRIP_INPUTS})
+ get_filename_component(OUTPUT_NAME "${INPUT}" NAME)
+
+ set(OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}")
+ set(INPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}")
+
foreach(quality 1 6 9 11)
add_test(NAME "${BROTLI_TEST_PREFIX}roundtrip/${INPUT}/${quality}"
COMMAND "${CMAKE_COMMAND}"
+ -DBROTLI_WRAPPER=${BROTLI_WINE}
-DBROTLI_CLI=$<TARGET_FILE:bro>
-DQUALITY=${quality}
- -DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}
+ -DINPUT=${INPUT_FILE}
+ -DOUTPUT=${OUTPUT_FILE}.${quality}
-P ${CMAKE_CURRENT_SOURCE_DIR}/tests/run-roundtrip-test.cmake)
endforeach()
endforeach()
@@ -145,6 +166,7 @@ if(NOT BROTLI_DISABLE_TESTS)
foreach(INPUT ${COMPATIBILITY_INPUTS})
add_test(NAME "${BROTLI_TEST_PREFIX}compatibility/${INPUT}"
COMMAND "${CMAKE_COMMAND}"
+ -DBROTLI_WRAPPER=${BROTLI_WINE}
-DBROTLI_CLI=$<TARGET_FILE:bro>
-DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}
-P ${CMAKE_CURRENT_SOURCE_DIR}/tests/run-compatibility-test.cmake)
diff --git a/common/types.h b/common/types.h
index 4b050af..2e9135a 100644
--- a/common/types.h
+++ b/common/types.h
@@ -25,7 +25,7 @@ typedef __int64 int64_t;
#endif /* defined(_MSC_VER) && (_MSC_VER < 1600) */
#if (!defined(_MSC_VER) || (_MSC_VER >= 1800)) && \
- (defined(__cplusplus) || __STDC_VERSION__ >= 199901L)
+ (defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L))
#include <stdbool.h>
#define BROTLI_BOOL bool
#define BROTLI_TRUE true
diff --git a/tests/run-compatibility-test.cmake b/tests/run-compatibility-test.cmake
index 9e7461b..0cc14d2 100644
--- a/tests/run-compatibility-test.cmake
+++ b/tests/run-compatibility-test.cmake
@@ -3,7 +3,7 @@ get_filename_component(OUTPUT_NAME "${REFERENCE_DATA}" NAME)
execute_process(
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
- COMMAND ${BROTLI_CLI} -f -d -i "${INPUT}" -o "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.unbro"
+ COMMAND ${BROTLI_WRAPPER} ${BROTLI_CLI} --force --decompress --input ${INPUT} --output ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.unbro
RESULT_VARIABLE result)
if(result)
message(FATAL_ERROR "Decompression failed")
diff --git a/tests/run-roundtrip-test.cmake b/tests/run-roundtrip-test.cmake
index 6cbd906..fbbd406 100644
--- a/tests/run-roundtrip-test.cmake
+++ b/tests/run-roundtrip-test.cmake
@@ -1,16 +1,15 @@
-get_filename_component(OUTPUT_NAME "${INPUT}" NAME)
-
execute_process(
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
- COMMAND ${BROTLI_CLI} -f -q ${QUALITY} -i "${INPUT}" -o "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.bro"
- RESULT_VARIABLE result)
+ COMMAND ${BROTLI_WRAPPER} ${BROTLI_CLI} --force --quality ${QUALITY} --input ${INPUT} --output ${OUTPUT}.bro
+ RESULT_VARIABLE result
+ ERROR_VARIABLE result_stderr)
if(result)
- message(FATAL_ERROR "Compression failed")
+ message(FATAL_ERROR "Compression failed: ${result_stderr}")
endif()
execute_process(
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
- COMMAND ${BROTLI_CLI} -f -d -i "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.bro" -o "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.unbro"
+ COMMAND ${BROTLI_WRAPPER} ${BROTLI_CLI} --force --decompress --input ${OUTPUT}.bro --output ${OUTPUT}.unbro
RESULT_VARIABLE result)
if(result)
message(FATAL_ERROR "Decompression failed")
@@ -32,4 +31,4 @@ function(test_file_equality f1 f2)
endif()
endfunction()
-test_file_equality("${INPUT}" "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.unbro")
+test_file_equality("${INPUT}" "${OUTPUT}.unbro")
diff --git a/tools/bro.c b/tools/bro.c
index 016808e..426c573 100644
--- a/tools/bro.c
+++ b/tools/bro.c
@@ -24,10 +24,13 @@
#include <share.h>
#define MAKE_BINARY(FILENO) (_setmode((FILENO), _O_BINARY), (FILENO))
+
+#if !defined(__MINGW32__)
#define STDIN_FILENO MAKE_BINARY(_fileno(stdin))
#define STDOUT_FILENO MAKE_BINARY(_fileno(stdout))
#define S_IRUSR S_IREAD
#define S_IWUSR S_IWRITE
+#endif
#define fdopen _fdopen
#define unlink _unlink