Skip to content

Commit

Permalink
Merge gfx-rs#169
Browse files Browse the repository at this point in the history
169: Add Windows/glfw3 to CI r=kvark a=grovesNL



Co-authored-by: Joshua Groves <[email protected]>
  • Loading branch information
bors[bot] and grovesNL committed Jun 5, 2019
2 parents 8574087 + 7e7a88b commit b1d9de0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
21 changes: 16 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ matrix:
# Windows 64bit
- os: windows
rust: stable
- os: windows
rust: nightly

# macOS 64bit
- env: MACOSX_DEPLOYMENT_TARGET=10.9
Expand Down Expand Up @@ -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
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ EXCLUDES:=
FEATURE_RUST:=
FEATURE_NATIVE:=

GENERATOR_PLATFORM:=

FFI_DIR:=ffi
BUILD_DIR:=build
CLEAN_FFI_DIR:=
Expand All @@ -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
Expand Down Expand Up @@ -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 .
11 changes: 6 additions & 5 deletions examples/hello_triangle_c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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})

0 comments on commit b1d9de0

Please sign in to comment.