Created
March 24, 2026 09:07
-
-
Save bonzini/b9a985a5dae2008c89f1265ca7e2bf25 to your computer and use it in GitHub Desktop.
fc-cargo.patch
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
| diff --git a/Cargo.toml b/Cargo.toml | |
| index 0b7468de..faa0c123 100644 | |
| --- a/Cargo.toml | |
| +++ b/Cargo.toml | |
| @@ -15,4 +15,9 @@ bytemuck_derive = "1" | |
| [lib] | |
| +crate-type = ["staticlib"] | |
| path = "fc-fontations/mod.rs" | |
| + | |
| +[lints.rust] | |
| +unsafe_op_in_unsafe_fn = "deny" | |
| +warnings = "deny" | |
| diff --git a/fc-fontations/meson.build b/fc-fontations/meson.build | |
| index 7dbb5764..9533b1ee 100644 | |
| --- a/fc-fontations/meson.build | |
| +++ b/fc-fontations/meson.build | |
| @@ -2,6 +2,7 @@ fontations = get_option('fontations') | |
| if (fontations.enabled()) | |
| rust = import('rust') | |
| + cargo = rust.workspace() | |
| generated_fontconfig = rust.bindgen( | |
| input: fontconfig_h, | |
| @@ -34,18 +35,17 @@ if (fontations.enabled()) | |
| c_args: ['-DBINDGEN_IGNORE_VISIBILITY=1', '-DFC_NO_MT=1'], | |
| ) | |
| - fontations_bindings_lib = static_library( | |
| - 'fontconfig_bindings', | |
| - sources: [generated_fontconfig], | |
| - rust_abi: 'rust', | |
| - ) | |
| + fontconfig_bindings_pkg = cargo.package('fontconfig-bindings') | |
| + fontconfig_bindings_lib = fontconfig_bindings_pkg.library( | |
| + structured_sources(generated_fontconfig)) | |
| + fontconfig_bindings_pkg.override_dependency( | |
| + declare_dependency(link_with: fontconfig_bindings_lib)) | |
| - fcint_bindings_lib = static_library( | |
| - 'fcint_bindings', | |
| - sources: [generated_fcint], | |
| - rust_abi: 'rust', | |
| - link_with: [fontations_bindings_lib], | |
| - ) | |
| + fcint_bindings_pkg = cargo.package('fcint-bindings') | |
| + fcint_bindings_lib = fcint_bindings_pkg.library( | |
| + structured_sources(generated_fcint)) | |
| + fcint_bindings_pkg.override_dependency( | |
| + declare_dependency(link_with: fcint_bindings_lib)) | |
| fontations_query_lib = static_library( | |
| 'fc_fontations_query', | |
| @@ -53,25 +53,11 @@ if (fontations.enabled()) | |
| sources: ['../src/fcfontations.c', fcstdint_h, fclang_h, alias_headers], | |
| ) | |
| - fc_fontations = static_library( | |
| - 'fc_fontations', | |
| - sources: ['mod.rs'], | |
| + fc_fontations = cargo.package().library( | |
| link_with: [ | |
| - fontations_bindings_lib, | |
| - fcint_bindings_lib, | |
| pattern_lib, | |
| fontations_query_lib, | |
| ], | |
| - rust_args: ['-Dunsafe-op-in-unsafe-fn', '-Dwarnings'], | |
| - rust_abi: 'c', | |
| - dependencies: [ | |
| - dependency('skrifa-0.39-rs'), | |
| - dependency('read-fonts-0.36-rs'), | |
| - dependency('font-types-0.10-rs'), | |
| - dependency('libc-0.2-rs'), | |
| - ], | |
| install: true, | |
| - | |
| ) | |
| - | |
| -endif | |
| \ No newline at end of file | |
| +endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, we have good Rust support in GN. For FontConfig that's here:
https://source.chromium.org/chromium/chromium/src/+/main:third_party/fontconfig/BUILD.gn
The reason FC is not shipping the Rust code to distros yet is rather a few missing features than particular build system support issues, I believe.