Merge pull request #399 from nemequ/master

Add mingw support.
This commit is contained in:
Eugene Kliuchnikov 2016-07-29 10:38:09 +02:00 committed by GitHub
commit 24685f9bf3
7 changed files with 60 additions and 12 deletions

View File

@ -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
;;

View File

@ -1,5 +1,5 @@
language: c
dist: trusty
sudo: false
matrix:
include:
###
@ -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,

View File

@ -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)

View File

@ -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

View File

@ -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")

View File

@ -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")

View File

@ -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