You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- skip layout tests in pre-generated bindings to avoid errors on emscripten
- Test more build configuratioions in github CI
- support using pkg-config to find glfw libs
- properly document features/linker flags.
Copy file name to clipboardExpand all lines: README.md
+33-20Lines changed: 33 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,40 +5,52 @@ This repo contains `glfw-sys` crate that provides FFI bindings to [glfw](https:/
5
5
## Design
6
6
This library has two main purposes:
7
7
1. provide FFI bindings to glfw: pre-generated (fast compile times) and build-time generation (slower).
8
-
2. link to glfw library: source builds (using cmake) and [pre-built official glfw libs](https://github.com/glfw/glfw/releases).
8
+
2. link to glfw library: system builds (using `pkg-config`), source builds (using `cmake`) and [pre-built official glfw libs](https://github.com/glfw/glfw/releases) (only for windows and mac).
9
9
10
10
11
11
For normal applications, you only need to care about 2 features:
12
12
1.`src_build` - if you want to build from source. adds around 10 seconds of build time.
13
13
2.`static_link` - if you want to link statically. On linux, this requires `src_build` too, so prefer dynamic linking during development for faster compile times.
14
14
15
15
### Features
16
-
*`static_link` - statically link glfw. not available for linux if `src_build` is disabled.
17
-
*`src_build` - build glfw from source. If disabled, we download pre-built glfw libs using system's curl + unzip/tar and link them.
18
-
*`x11` and `wayland` - enables support for x11/wayland. Enable both and you can choose which one to use during initialization.
19
-
*`vulkan` - enables some vulkan convenience functions (eg: surface creation).
20
-
*`native_handles` - enable APIs to get platform specific window handles or display connections. useful for raw-window-handle support.
21
-
*`native_gl` - enable APIs for getting platform specific gl contexts (wgl, egl, glx, nsgl etc..)
22
-
*`native_egl` - enable egl API even for x11 builds
23
-
*`osmesa` - I have no idea. Ignore this unless you know what you are doing.
24
-
*`bindgen` - generate glfw FFI bindings at build time from headers. See [Below](#bindgen)
25
16
26
-
### Source Builds
27
-
if `src_build` feature is enabled, we will build glfw from scratch.
28
-
This requires `cmake` to be installed on your system and any other required dependencies.
17
+
#### Building And Linking
18
+
19
+
> NOTE: For emscripten, none of these features apply. We just pass the necessary flags like `-sUSE_GLFW=3` to linker and simply let emscripten take care of things.
20
+
21
+
-`static_link` - statically link glfw. If disabled, we will dynamically link glfw.
22
+
23
+
We try to build glfw in this order:
24
+
-`src_build` - If enabled, build glfw from source (sources are included with crate). Ensure `cmake` is installed and any other required dependencies.
25
+
-`prebuilt_libs` (only for windows/macos. ignored on other platforms) - If enabled, we download and link pre-built glfw libs from <https://github.com/glfw/glfw/releases/>.
26
+
27
+
> NOTE: We use curl + tar (unzip on macos) to download and extract pre-built libs. mac/win10+ will have these by default.
29
28
30
-
### Prebuilt-libs builds
31
-
If `src_build` feature is disabled, we will link with prebuilt glfw libraries.
32
-
On windows and mac, we download the official libraries from <https://github.com/glfw/glfw/releases/>
33
-
On linux, we expect user to have installed glfw library for linking (eg: `libglfw3-dev` on ubuntu). For static linking, you may probably require src_build, as most distros don't provide static libs.
29
+
Finally, if neither `src_build` nor `prebuilt_libs` feature is enabled, we will try to use `pkg-config` to find and link to system glfw libs.
34
30
35
-
> NOTE: We use curl + tar (unzip on unix) to download and extract pre-built libs. mac/win10+/linux will have these by default.
31
+
#### Platform Backends (non-mac and non-windows only)
32
+
*`x11` and `wayland` - enables support for x11/wayland. Enable both and you can choose which one to use during initialization. `x11/wayland` are ignored on windows/macos platforms.
33
+
34
+
#### Vulkan
35
+
-`vulkan` enables some vulkan convenience functions (eg: `glfwVulkanSupported`).
36
+
- Only enable this if you need vulkan support.
37
+
38
+
#### Native Handles
39
+
These features expose native "HWND"/"NSWindow"/"X11Connection" etc.. handles.
40
+
Unless you are using `wgpu`-like libs that need raw-window-handles, these features can be ignored.
41
+
-`native_handles` - enable APIs to get platform specific window handles or display connections or monitor ids. useful for raw-window-handle support.
42
+
-`native_gl` - enable APIs for getting platform specific gl contexts (`wgl`, `egl`, `glx`, `nsgl` etc..). Most users should ignore this.
43
+
-`native_egl` - enable egl API even for x11 builds, if you plan to use `egl` contexts with x11 windows. Most users should ignore this.
44
+
45
+
#### Miscellaneous
46
+
*`osmesa` - I have no idea. Ignore this unless you know what you are doing.
47
+
*`bindgen` - generate glfw FFI bindings at build time from headers. See [Below](#bindgen)
36
48
37
49
38
50
### Pre-Generated bindings
39
51
We generate FFI bindings at `src/sys/pregenerated.rs` and include them with the crate to keep the compile times fast. These are used when `bindgen` feature is disabled.
40
52
41
-
This generates core bindings, but skips platform specific bindings (eg: window handles or other platform specific API). Because generating them requires platform headers (eg: `windows.h`) and we can't provide headers for *all* platforms at once.
53
+
This contains core bindings, but skips platform specific bindings (eg: window handles or other platform specific API). Because generating them requires platform headers (eg: `windows.h`) and we can't provide headers for *all* platforms at once.
42
54
43
55
So, platform specific bindings are manually maintained by hand in `src/sys/manual.rs`.
44
56
@@ -52,5 +64,6 @@ These features will influence the bindings generated.
52
64
53
65
### Release Check List
54
66
* When updating glfw version, make sure to checkout the submodule and commit it.
55
-
* When updating glfw version, don't forget to change the url link build.rs to download the pre-built libs of the correct version.
67
+
* When updating glfw version, don't forget to change the url link in build.rs to download the pre-built libs of the correct version.
68
+
* When updating glfw version, don't forget to update the pkg-config `atleast_version` argument.
56
69
* Check that the bindings generated are the same on all platforms by checking the CI logs for the `gen_bindings.sh` step.
0 commit comments