Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 110 additions & 56 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,123 @@ name: Build
on: [push, pull_request]

jobs:
build:
name: Build
strategy:
matrix:
os: [ubuntu, macos, windows]

build-linux-x11-clang:
name: X11 (Linux, Clang)
runs-on: ubuntu-latest
env:
CC: clang
CFLAGS: -Werror
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: |
sudo apt update
sudo apt install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev
runs-on: ${{ matrix.os }}-latest

- name: Tests
run: cargo test
env:
CARGO_TERM_VERBOSE: true # for better logs if something goes wrong

build-linux-wayland-clang:
name: Wayland (Linux, Clang)
runs-on: ubuntu-latest
env:
CC: clang
CFLAGS: -Werror
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: |
sudo apt update
sudo apt install wayland-protocols libwayland-dev libxkbcommon-dev extra-cmake-modules
steps:
- uses: actions/checkout@v4
with:
submodules: true # for glfw submodule

- name: Tests
run: cargo test --features wayland
- 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 libegl-dev

build-macos-cocoa-clang:
name: Cocoa (macOS, Clang)
runs-on: macos-latest
env:
CFLAGS: -Werror
MACOSX_DEPLOYMENT_TARGET: 10.8
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
# To check vulkan bindings.
- name: Prepare Vulkan SDK
uses: humbletim/setup-vulkan-sdk@v1.2.1
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

- uses: dtolnay/rust-toolchain@stable
- name: Tests
run: cargo test
- 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

build-windows-win32-vs2019:
name: Win32 (Windows, VS2019)
runs-on: windows-latest
- 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:
CFLAGS: /WX
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
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

- uses: dtolnay/rust-toolchain@stable
- name: Tests
run: cargo test
# 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


38 changes: 31 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,46 @@
[package]
name = "glfw-sys"
version = "5.0.0+3.3.9"
version = "6.0.0"
authors = ["Camilla Berglund <elmindreda@elmindreda.org>"]
description = "An Open Source, multi-platform library for creating windows with OpenGL contexts and receiving input and events"
documentation = "http://www.glfw.org/documentation.html"
homepage = "http://www.glfw.org/"
repository = "https://github.com/PistonDevelopers/glfw-sys"
readme = "README.md"
license = "Zlib"
edition = "2021"
build = "build.rs"
links = "glfw"

[lib]
name = "glfw_sys"
path = "lib.rs"

[build-dependencies]
cmake = "0.1"

[features]
default = ["all"]
all = ["x11", "wayland", "native-handles", "native-gl", "native-egl", "vulkan"]
bindgen = ["dep:bindgen"]
# build from source, instead of using prebuilt libraries.
src-build = ["dep:cmake"]
prebuilt-libs = []

static-link = [] # static link (if on linux, src-build must also be enabled)
vulkan = []
wayland = []
x11 = []
native-handles = []
native-gl = []
native-egl = []
osmesa = []


[dependencies]

[build-dependencies]
bindgen = { version = "0.71", optional = true }
cmake = { version = "0.1", optional = true }
pkg-config = "0.3"

[dev-dependencies]
glow = {version = "0.16"}

# lets skip building glfw on docs.rs builds
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "wasm32-unknown-emscripten"]
Loading