fontconfig: Branch 'main' - 2 commits
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Mar 12 08:17:46 UTC 2025
fc-fontations-bindgen/build.rs | 9 +++++++--
fc-fontations/mod.rs | 11 ++++++++++-
meson.build | 1 +
src/fcint.h | 2 +-
src/meson.build | 2 +-
test/meson.build | 5 +++--
6 files changed, 23 insertions(+), 7 deletions(-)
New commits:
commit 9fa8afb0245627155b86139dec6bdb894e0c0abb
Merge: 59e53da 50aa6e3
Author: Akira TAGOH <akira at tagoh.org>
Date: Wed Mar 12 08:17:44 2025 +0000
Merge branch 'rustTestLinkageBothLibs' into 'main'
[Fontations] Allow linkage to internals in tests
Closes #441
See merge request fontconfig/fontconfig!367
commit 50aa6e3685223fb644b8800d5af77e1b6cda7345
Author: Dominik Röttsches <drott at chromium.org>
Date: Mon Mar 10 13:46:56 2025 +0200
[Fontations] Allow linkage to internals in tests
This enables Fontations testing through meson test as well as cargo test.
* Build: fontconfig as both_libraries() instead of library() in order to
allow test executable to link to the static library which allows
access to internal functions.
* Modify the current dummy Rust test to test whether the internal
function PatternObjectAddBool is accessible.
* Modify Rust build.rs build script to enable `cargo test` execution.
Fixes #441.
diff --git a/fc-fontations-bindgen/build.rs b/fc-fontations-bindgen/build.rs
index 50b703d..0591cf0 100644
--- a/fc-fontations-bindgen/build.rs
+++ b/fc-fontations-bindgen/build.rs
@@ -10,6 +10,7 @@ fn main() {
meson.current_dir("../");
meson.arg("setup")
.arg(build_dir.to_str().unwrap())
+ .arg("--reconfigure")
.arg("-Dfontations=enabled");
let status = meson.status().expect("Failed to execute meson");
@@ -26,8 +27,12 @@ fn main() {
}
// Tell cargo to look for fontconfig in the build directory
- println!("cargo:rustc-link-search=native={}", build_dir.join("lib").display());
- println!("cargo:rustc-link-lib=dylib=fontconfig");
+ println!("cargo:rustc-link-search=native={}", build_dir.join("src").display());
+ println!("cargo:rustc-link-lib=static=fontconfig");
+
+ // FreeType and Expat from the system.
+ println!("cargo:rustc-link-lib=dylib=freetype");
+ println!("cargo:rustc-link-lib=dylib=expat");
// Rerun this build script if the fontconfig source code changes
println!("cargo:rerun-if-changed=src");
diff --git a/fc-fontations/mod.rs b/fc-fontations/mod.rs
index a39c814..1a9be87 100644
--- a/fc-fontations/mod.rs
+++ b/fc-fontations/mod.rs
@@ -1,6 +1,9 @@
extern crate fc_fontations_bindgen;
-use fc_fontations_bindgen::{fcint::FcPatternCreate, FcFontSet, FcFontSetAdd};
+use fc_fontations_bindgen::{
+ fcint::{FcPatternCreate, FcPatternObjectAddBool},
+ FcFontSet, FcFontSetAdd,
+};
#[no_mangle]
/// Externally called in fcfontations.c as the file scanner function
@@ -15,6 +18,12 @@ pub unsafe extern "C" fn add_patterns_to_fontset(
font_set: *mut FcFontSet,
) -> libc::c_int {
let empty_pattern = FcPatternCreate();
+ // Test call to ensure that an FcPrivate API function FcPatternObjectAddBool
+ // is accessible and can be linked to.
+ // TODO(drott): This should be FC_COLOR_OBJECT imported from fcint.h,
+ // but there's a separate bindgen issue that needs to be sorted out.
+ const COLOR_OBJECT: i32 = 46;
+ FcPatternObjectAddBool(empty_pattern, COLOR_OBJECT, 0 as i32);
if !font_set.is_null() {
FcFontSetAdd(
font_set,
diff --git a/meson.build b/meson.build
index 2e2be99..d9ed3ea 100644
--- a/meson.build
+++ b/meson.build
@@ -77,6 +77,7 @@ fontations = get_option('fontations')
if (fontations.enabled())
conf.set('ENABLE_FONTATIONS', 1)
add_languages(['rust'], native: false, required : true)
+
endif
pkgmod = import('pkgconfig')
diff --git a/src/fcint.h b/src/fcint.h
index 6d9c8f8..334cde0 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -119,7 +119,7 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA;
#define FC_MAX(a, b) ((a) > (b) ? (a) : (b))
/* slim_internal.h */
-#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) && !defined(__sun)
+#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) && !defined(__sun) && !defined(BINDGEN_IGNORE_VISIBILITY)
# define FcPrivate __attribute__ ((__visibility__ ("hidden")))
# define HAVE_GNUC_ATTRIBUTE 1
# include "fcalias.h"
diff --git a/src/meson.build b/src/meson.build
index 3c2950f..e3c518e 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -51,7 +51,7 @@ if host_machine.system() == 'windows' and get_option('default_library') in ['bot
fc_c_shared_args += '-DDLL_EXPORT'
endif
-libfontconfig = library('fontconfig',
+libfontconfig = both_libraries('fontconfig',
fc_sources, alias_headers, ft_alias_headers, fclang_h, fccase_h, fcobjshash_h, fcstdint_h,
c_shared_args: fc_c_shared_args,
include_directories: incbase,
diff --git a/test/meson.build b/test/meson.build
index 32d7714..fa16a92 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -37,16 +37,17 @@ foreach test_data : tests
exe = executable(test_name, fname,
c_args: c_args + extra_c_args,
include_directories: incbase,
- link_with: [libfontconfig],
+ link_with: [libfontconfig.get_static_lib()],
dependencies: extra_deps,
)
test(test_name, exe, timeout: 600)
endforeach
+
if get_option('fontations').enabled()
rust = import('rust')
- rust.test('fc_fontations_tests', fc_fontations)
+ rust.test('fc_fontations_rust_tests', fc_fontations, link_with: [fc_fontations, libfontconfig.get_static_lib()])
endif
fs = import('fs')
More information about the Fontconfig
mailing list