Skip to content
Snippets Groups Projects
Commit 5bce4a62 authored by Vicki Pfau's avatar Vicki Pfau
Browse files

travis: Add Windows build

parent 6ec364e7
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,11 @@ services: ...@@ -15,6 +15,11 @@ services:
- docker - docker
osx_image: xcode8 osx_image: xcode8
matrix:
include:
- os: linux
env: CROSS=win64
before_script: before_script:
- mkdir -p $HOME/roms - mkdir -p $HOME/roms
script: script:
...@@ -22,6 +27,7 @@ script: ...@@ -22,6 +27,7 @@ script:
if [ "$TRAVIS_OS_NAME" == "linux" ]; then if [ "$TRAVIS_OS_NAME" == "linux" ]; then
docker run docker run
--env PYVER="$PYVER" --env PYVER="$PYVER"
--env CROSS="$CROSS"
--env TRAVIS_OS_NAME="$TRAVIS_OS_NAME" --env TRAVIS_OS_NAME="$TRAVIS_OS_NAME"
--env TRAVIS_TAG="$TRAVIS_TAG" --env TRAVIS_TAG="$TRAVIS_TAG"
--env TRAVIS_BRANCH="$TRAVIS_BRANCH" --env TRAVIS_BRANCH="$TRAVIS_BRANCH"
......
...@@ -3,11 +3,6 @@ if(POLICY CMP0048) ...@@ -3,11 +3,6 @@ if(POLICY CMP0048)
cmake_policy(SET CMP0048 NEW) cmake_policy(SET CMP0048 NEW)
endif() endif()
if(NOT WIN32)
set(BUILD_PYTHON ON CACHE BOOL "Build Python module")
mark_as_advanced(BUILD_PYTHON)
endif()
find_package(Git QUIET) find_package(Git QUIET)
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/third-party/pybind11/include) if(NOT EXISTS ${CMAKE_SOURCE_DIR}/third-party/pybind11/include)
message(STATUS "Submodules seem to be missing. Attempting to clone now.") message(STATUS "Submodules seem to be missing. Attempting to clone now.")
...@@ -20,9 +15,7 @@ if(NOT EXISTS ${CMAKE_SOURCE_DIR}/third-party/pybind11/include) ...@@ -20,9 +15,7 @@ if(NOT EXISTS ${CMAKE_SOURCE_DIR}/third-party/pybind11/include)
unset(SUCCESS) unset(SUCCESS)
endif() endif()
if(BUILD_PYTHON) find_package(PythonInterp REQUIRED)
find_package(PythonInterp REQUIRED)
endif()
file(READ "${CMAKE_SOURCE_DIR}/VERSION" PROJECT_VERSION) file(READ "${CMAKE_SOURCE_DIR}/VERSION" PROJECT_VERSION)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "$CMAKE_SOURCE_DIR}/VERSION") set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "$CMAKE_SOURCE_DIR}/VERSION")
...@@ -37,9 +30,17 @@ if(NOT CMAKE_BUILD_TYPE) ...@@ -37,9 +30,17 @@ if(NOT CMAKE_BUILD_TYPE)
endif() endif()
option(BUILD_TESTS "Should tests be built" ON) option(BUILD_TESTS "Should tests be built" ON)
if(NOT WIN32)
set(BUILD_PYTHON ON CACHE BOOL "Build Python module")
mark_as_advanced(BUILD_PYTHON)
endif()
if(BUILD_PYTHON) if(BUILD_PYTHON)
find_package(PythonLibs REQUIRED) find_package(PythonLibs REQUIRED)
endif() endif()
if(WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif()
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
find_package(PkgConfig) find_package(PkgConfig)
...@@ -127,11 +128,13 @@ add_custom_target(clean-cores DEPENDS ${CLEAN_CORES}) ...@@ -127,11 +128,13 @@ add_custom_target(clean-cores DEPENDS ${CLEAN_CORES})
add_custom_target(cores DEPENDS ${CORE_TARGETS}) add_custom_target(cores DEPENDS ${CORE_TARGETS})
unset(CLEAN_CORES) unset(CLEAN_CORES)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
set(BUILD_STATIC_LIBS ON CACHE BOOL "" FORCE)
if(LIBZIP_FOUND) if(LIBZIP_FOUND)
include_directories(${LIBZIP_INCLUDE_DIRS}) include_directories(${LIBZIP_INCLUDE_DIRS})
link_directories(${LIBZIP_LIBRARY_DIRS}) link_directories(${LIBZIP_LIBRARY_DIRS})
else() else()
set(BUILD_SHARED_LIBS OFF)
set(LIBZIP_LIBRARIES zip) set(LIBZIP_LIBRARIES zip)
add_subdirectory(third-party/libzip) add_subdirectory(third-party/libzip)
include_directories(third-party/libzip third-party/libzip/lib) include_directories(third-party/libzip third-party/libzip/lib)
......
...@@ -4,11 +4,13 @@ SHELL ["/bin/bash", "-c"] ...@@ -4,11 +4,13 @@ SHELL ["/bin/bash", "-c"]
ENV PYVER=3.5 ENV PYVER=3.5
RUN apt-get update && \ RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential ccache cmake git libffi-dev libgit2-dev pkg-config \ build-essential ccache cmake git libffi-dev \
software-properties-common unzip && \ libz-mingw-w64-dev mingw-w64 pkg-config software-properties-common \
unzip zip && \
apt-get clean apt-get clean
RUN add-apt-repository -y ppa:deadsnakes/ppa && \ RUN apt-add-repository -y ppa:deadsnakes/ppa && \
apt-add-repository -y ppa:tobydox/mingw-w64 && \
apt-get update && \ apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
libpython3.5-dev python3.5-venv \ libpython3.5-dev python3.5-venv \
...@@ -18,12 +20,19 @@ RUN add-apt-repository -y ppa:deadsnakes/ppa && \ ...@@ -18,12 +20,19 @@ RUN add-apt-repository -y ppa:deadsnakes/ppa && \
RUN python3.5 -m venv ~/venv3.5 && \ RUN python3.5 -m venv ~/venv3.5 && \
. ~/venv3.5/bin/activate && \ . ~/venv3.5/bin/activate && \
pip install wheel && \ pip install wheel && \
pip install google-cloud google-resumable-media matplotlib pygit2==0.24.2 pytest requests && \ pip install google-cloud google-resumable-media pytest requests && \
python3.6 -m venv ~/venv3.6 && \ python3.6 -m venv ~/venv3.6 && \
. ~/venv3.6/bin/activate && \ . ~/venv3.6/bin/activate && \
pip install wheel && \ pip install wheel && \
pip install google-cloud google-resumable-media pytest requests && \ pip install google-cloud google-resumable-media pytest requests && \
rm -rf ~/.cache && \ rm -rf ~/.cache && \
ln -s ~/venv3.5 ~/venv && \
echo "source /root/venv\$PYVER/bin/activate" > ~/.bash_profile echo "source /root/venv\$PYVER/bin/activate" > ~/.bash_profile
WORKDIR /root
COPY scripts scripts
COPY cmake cmake
COPY third-party/libzip libzip
RUN CROSS=win64 ROOT=/usr/x86_64-w64-mingw32 ./scripts/build_deps.sh
ENTRYPOINT ["bash", "-lc", "exec $0 $@"] ENTRYPOINT ["bash", "-lc", "exec $0 $@"]
set(CMAKE_SYSTEM_NAME Windows CACHE INTERNAL "system name")
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
set(CMAKE_PREFIX_PATH /usr/x86_64-w64-mingw32/)
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32/)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(cross_prefix x86_64-w64-mingw32-)
set(link_flags "-static-libgcc -static-libstdc++")
set(CMAKE_EXE_LINKER_FLAGS ${link_flags} CACHE INTERNAL "exe link flags")
set(CMAKE_MODULE_LINKER_FLAGS ${link_flags} CACHE INTERNAL "module link flags")
set(CMAKE_SHARED_LINKER_FLAGS "${link_flags} -Wl,--export-all-symbols" CACHE INTERNAL "shared link flags")
...@@ -63,39 +63,53 @@ def plot_history(): ...@@ -63,39 +63,53 @@ def plot_history():
def main(): def main():
os_name = os.environ['TRAVIS_OS_NAME'] os_name = os.environ['TRAVIS_OS_NAME']
cross = os.environ.get('CROSS')
with Fold('script.deps', 'Installing dependencies'): with Fold('script.deps', 'Installing dependencies'):
if os_name != 'osx':
os.environ['PATH'] = '/usr/lib/ccache:' + os.environ['PATH']
if os_name == 'osx': if os_name == 'osx':
# update brew first, which should install the correct version of ruby # update brew first, which should install the correct version of ruby
# and avoid the error "Homebrew must be run under Ruby 2.3" # and avoid the error "Homebrew must be run under Ruby 2.3"
call(['brew', 'update']) call(['brew', 'update'])
call(['brew', 'install', 'lua@5.1', 'ccache']) call(['brew', 'install', 'lua@5.1', 'ccache'])
cmake_options = []
elif os_name == 'linux': elif os_name == 'linux':
cmake_options = [] cmake_options = []
os.environ['PATH'] = '/usr/lib/ccache:' + os.environ['PATH'] if cross in ('win32', 'win64'):
cmake_options = ['-DCMAKE_TOOLCHAIN_FILE=cmake/%s.cmake' % cross]
else:
raise Exception('unrecognized os name')
with Fold('script.build', 'Building'): with Fold('script.build', 'Building'):
call(['cmake', '.', '-DBUILD_TESTS=ON']) call(['cmake', '.', '-DBUILD_TESTS=ON'] + cmake_options)
call(['python', 'setup.py', '-q', 'build_ext', '-i', '-j3']) if os_name not in ('win64', 'win32'):
call(['pip', 'install', '-e', '.']) call(['python', 'setup.py', '-q', 'build_ext', '-i', '-j3'])
call(['pip', 'install', '-e', '.'])
call(['make', '-j3']) call(['make', '-j3'])
if os.environ['TRAVIS_PULL_REQUEST'] == 'false': if os.environ['TRAVIS_PULL_REQUEST'] == 'false':
with Fold('script.package', 'Packaging binaries'): with Fold('script.package', 'Packaging binaries'):
call(['python', 'setup.py', '-q', 'bdist_wheel']) if cross not in ('win64', 'win32'):
call(['python', 'setup.py', '-q', 'bdist_wheel'])
if os.environ['TRAVIS_BRANCH'] == 'master': if os.environ['TRAVIS_BRANCH'] == 'master':
upload_dir = 'builds' upload_dir = 'builds'
else: else:
upload_dir = 'builds/%s' % os.environ['TRAVIS_BRANCH'] upload_dir = 'builds/%s' % os.environ['TRAVIS_BRANCH']
upload_to_gcs(['dist/*.whl'], upload_dir) if cross not in ('win64', 'win32'):
upload_to_gcs(['dist/*.whl'], upload_dir)
with Fold('script.test', 'Running tests'): if cross not in ('win64', 'win32'):
call(['ctest', '--verbose', '-E', '\.test']) # Exclude libzip tests with Fold('script.test', 'Running tests'):
call(['ctest', '--verbose', '-E', '\.test']) # Exclude libzip tests
if os_name == 'linux': if os_name == 'linux' and not cross:
passed = test() try:
assert passed passed = test()
assert passed
except ImportError:
pass
if __name__ == '__main__': if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment