From 7e7a88b831579bd3c7d7b1afd83b727833f3e178 Mon Sep 17 00:00:00 2001 From: Joshua Groves Date: Tue, 4 Jun 2019 22:09:58 -0230 Subject: [PATCH] Add Windows/glfw3 to CI --- .travis.yml | 21 ++++++++++++++++----- Makefile | 7 +++++-- examples/hello_triangle_c/CMakeLists.txt | 11 ++++++----- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index d8595dae7..c696c59c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,8 @@ matrix: # Windows 64bit - os: windows rust: stable + - os: windows + rust: nightly # macOS 64bit - env: MACOSX_DEPLOYMENT_TARGET=10.9 @@ -45,19 +47,28 @@ addons: packages: - cmake - glfw3 - choco: - packages: - - make branches: except: - staging.tmp before_install: - - if [[ $TRAVIS_OS_NAME == "windows" ]]; then choco install make; fi +- if [[ $TRAVIS_OS_NAME == "windows" ]]; then choco install make; fi script: - cargo test - - if [[ $TRAVIS_RUST_VERSION == "nightly" ]]; then cargo +nightly install cbindgen && make VERBOSE=1; fi + - if [[ $TRAVIS_RUST_VERSION == "nightly" ]] && [[ $TRAVIS_OS_NAME == "windows" ]]; then + wget -nc -O glfw.zip https://github.com/glfw/glfw/archive/3.3.zip && + 7z x glfw.zip -oglfw && + cd glfw/glfw-3.3 && + export GLFW3_INCLUDE_DIR=`pwd`/include && + export GLFW3_INSTALL_DIR=`pwd`/install && + cmake . -DCMAKE_INSTALL_PREFIX=$GLFW3_INSTALL_DIR -DCMAKE_GENERATOR_PLATFORM=x64 && + cmake --build . --target install && + cd ../.. && + export CMAKE_PREFIX_PATH=$GLFW3_INSTALL_DIR && + make examples-native VERBOSE=1; + fi + - if [[ $TRAVIS_RUST_VERSION == "nightly" ]] && [[ $TRAVIS_OS_NAME != "windows" ]]; then cargo +nightly install cbindgen && make VERBOSE=1; fi # TODO: Temporarily only test building the gl backend, properly test when it is usable from C - if [[ $TRAVIS_OS_NAME == "linux" ]]; then cd wgpu-native && cargo build --features local,gfx-backend-gl; fi diff --git a/Makefile b/Makefile index 49afab0e6..008824a61 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,8 @@ EXCLUDES:= FEATURE_RUST:= FEATURE_NATIVE:= +GENERATOR_PLATFORM:= + FFI_DIR:=ffi BUILD_DIR:=build CLEAN_FFI_DIR:= @@ -17,6 +19,7 @@ endif ifeq ($(OS),Windows_NT) CLEAN_FFI_DIR=del $(FFI_DIR)\*.* /Q /S CREATE_BUILD_DIR=mkdir $(BUILD_DIR) + GENERATOR_PLATFORM=-DCMAKE_GENERATOR_PLATFORM=x64 ifeq ($(TARGET),x86_64-pc-windows-gnu) FEATURE_RUST=vulkan @@ -71,7 +74,7 @@ ffi/wgpu-remote.h: wgpu-remote/cbindgen.toml $(wildcard wgpu-native/**/*.rs wgp rustup run nightly cbindgen wgpu-remote >$(FFI_DIR)/wgpu-remote.h examples-native: lib-native $(FFI_DIR)/wgpu.h examples/hello_triangle_c/main.c - cd examples/hello_triangle_c && $(CREATE_BUILD_DIR) && cd build && cmake .. -DBACKEND=$(FEATURE_RUST) && make + cd examples/hello_triangle_c && $(CREATE_BUILD_DIR) && cd build && cmake .. -DBACKEND=$(FEATURE_RUST) $(GENERATOR_PLATFORM) && cmake --build . examples-remote: lib-remote $(FFI_DIR)/wgpu-remote.h examples/hello_remote_c/main.c - cd examples/hello_remote_c && $(CREATE_BUILD_DIR) && cd build && cmake .. && make + cd examples/hello_remote_c && $(CREATE_BUILD_DIR) && cd build && cmake .. && cmake --build . diff --git a/examples/hello_triangle_c/CMakeLists.txt b/examples/hello_triangle_c/CMakeLists.txt index 5bd2d247f..950f90bea 100644 --- a/examples/hello_triangle_c/CMakeLists.txt +++ b/examples/hello_triangle_c/CMakeLists.txt @@ -23,7 +23,6 @@ add_executable(hello_triangle main.c) if(MSVC) add_definitions(-DWGPU_TARGET=WGPU_TARGET_WINDOWS) target_compile_options(${TARGET_NAME} PRIVATE /W4) - set(GLFW_LIBRARY glfw3) set(OS_LIBRARIES "userenv" "ws2_32" "Dwmapi" "dbghelp") if("${BACKEND}" STREQUAL "${BACKEND_DX11}") list(APPEND OS_LIBRARIES "d3dcompiler" "D3D11" "DXGI") @@ -34,17 +33,19 @@ elseif(APPLE) add_definitions(-DWGPU_TARGET=WGPU_TARGET_MACOS) set(OS_LIBRARIES "-framework Cocoa" "-framework CoreVideo" "-framework IOKit" "-framework QuartzCore") target_compile_options(${TARGET_NAME} PRIVATE -x objective-c) - set(GLFW_LIBRARY glfw) else(MSVC) add_definitions(-DWGPU_TARGET=WGPU_TARGET_LINUX) target_compile_options(${TARGET_NAME} PRIVATE -Wall -Wextra -pedantic) - set(GLFW_LIBRARY glfw) endif(MSVC) -find_package(glfw3 REQUIRED) +find_package(glfw3 3.3 REQUIRED + HINTS "$ENV{GLFW3_INSTALL_DIR}" +) find_library(WGPU_LIBRARY wgpu_native HINTS "${CMAKE_CURRENT_SOURCE_DIR}/../../target/debug" ) -target_link_libraries(${TARGET_NAME} ${GLFW_LIBRARY} ${WGPU_LIBRARY} ${OS_LIBRARIES}) +target_include_directories(${TARGET_NAME} PUBLIC $ENV{GLFW3_INCLUDE_DIR}) + +target_link_libraries(${TARGET_NAME} glfw ${WGPU_LIBRARY} ${OS_LIBRARIES})