Fixes a lot of issues and upgrades to 3.4 #34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: [push, pull_request] | |
jobs: | |
build: | |
name: Build | |
strategy: | |
matrix: | |
os: [ubuntu, macos, windows] | |
runs-on: ${{ matrix.os }}-latest | |
env: | |
CARGO_TERM_VERBOSE: true # for better logs if something goes wrong | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true # for glfw submodule | |
- name: Install dependencies (Linux) | |
if: matrix.os == 'ubuntu' | |
run: | | |
sudo apt update | |
sudo apt install libwayland-dev libxkbcommon-dev xorg-dev libgl-dev libx11-dev libxkbfile-dev libglx-dev libinput-dev | |
# To check vulkan bindings. | |
- name: Prepare Vulkan SDK | |
uses: humbletim/[email protected] | |
with: | |
vulkan-query-version: latest | |
vulkan-components: Vulkan-Headers | |
vulkan-use-cache: true | |
- name: Source build with static link | |
shell: bash | |
run: cargo clean && cargo run -vv --example=version --features=src_build,static_link | |
- name: Source build with shared link | |
shell: bash | |
run: cargo clean && cargo run -vv --example=version --features=src_build | |
- name: Prebuilt libs with static link (Non-Linux) | |
shell: bash | |
# linux pre-built static libs are not provided, so, static linkign requires src_build. | |
if: matrix.os != 'ubuntu' | |
run: cargo clean && cargo run -vv --example=version --features=static_link,prebuilt_libs | |
- name: Prebuilt libs with shared link | |
shell: bash | |
if: matrix.os != 'ubuntu' | |
run: cargo clean && cargo run -vv --example=version --features=prebuilt_libs | |
- name: Install Glfw Packages (MacOs) | |
if: matrix.os == 'macos' | |
shell: bash | |
run: brew install glfw | |
- name: PkgConfig build with static linking (MacOs) | |
if: matrix.os == 'macos' | |
shell: bash | |
run: cargo clean && cargo run -vv --example=version --features=static_link | |
- name: PkgConfig build with shared linking (MacOs) | |
if: matrix.os == 'macos' | |
shell: bash | |
run: cargo clean && cargo run -vv --example=version | |
# ubuntu 24.04 doesn't have glfw 3.4 yet (as of 26th April 2025) | |
# so, we must build from source for glfw binaries | |
# We build and store the binaries in build_shared and build_static directories | |
- name: Build Glfw Package for Linux | |
if: matrix.os == 'ubuntu' | |
shell: bash | |
run: | | |
export COMMON_OPTIONS="-DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_DOCS=OFF -DCMAKE_BUILD_TYPE=Debug -DGLFW_BUILD_WAYLAND=ON -DGLFW_BUILD_X11=ON" | |
cmake -S glfw -B build_shared -DGLFW_LIBRARY_TYPE=SHARED -DCMAKE_INSTALL_PREFIX=$PWD/build_shared $COMMON_OPTIONS | |
cmake --build build_shared | |
cmake --install build_shared | |
cmake -S glfw -B build_static -DGLFW_LIBRARY_TYPE=STATIC -DCMAKE_INSTALL_PREFIX=$PWD/build_static $COMMON_OPTIONS | |
cmake --build build_static | |
cmake --install build_static | |
- name: PkgConfig build with static linking (Linux) | |
if: matrix.os == 'ubuntu' | |
shell: bash | |
env: | |
PKG_CONFIG_PATH: ${{github.workspace}}/build_static/lib/pkgconfig | |
run: cargo clean && cargo run -vv --example=version --features=static_link | |
- name: PkgConfig build with shared linking (Linux) | |
if: matrix.os == 'ubuntu' | |
shell: bash | |
env: | |
PKG_CONFIG_PATH: ${{github.workspace}}/build_shared/lib/pkgconfig | |
LD_LIBRARY_PATH: ${{github.workspace}}/build_shared/lib | |
run: cargo clean && cargo run -vv --example=version | |
# We don't pass --no-default-features, so, this generates bindings for | |
# vulkan and native_gl/egl + other handles too by including system headers. | |
- name: Generate Bindings | |
shell: bash | |
run: cargo clean && cargo run -vv --example=version --features=bindgen,src_build | |
# Just to make sure that the script works on all platforms. | |
- name: Check gen_bindings.sh script | |
shell: bash | |
run: | | |
# bindgen-cli binary is not available for windows for some reason | |
if [ "$RUNNER_OS" == "Windows" ]; then | |
cargo install bindgen-cli | |
else | |
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/rust-lang/rust-bindgen/releases/download/v0.71.1/bindgen-cli-installer.sh | sh | |
fi | |
./gen_bindings.sh ./bindings.rs | |
# lets log any differences between what is committed and what is generated. | |
# the "|| true" part is to avoid failing the build if there's any differences | |
diff -ub ./src/sys/pregenerated.rs ./bindings.rs || true | |