Hash :
c25fddba
Author :
Date :
2025-05-05T15:50:16
[harfruzz] Add basic harfRuzz shaper
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
rust = import('unstable-rust')
hb_rs = rust.bindgen(
input : '../hb.h',
output : 'hb.rs',
include_directories: incsrc,
args : ['--allowlist-function=hb_.*',
'--allowlist-type=hb_.*',
'--no-copy=hb_.*',
],
)
cargo = find_program('cargo')
rustfmt = find_program('rustfmt')
rust_flags = ''
cargo_args = [
'--package', 'harfbuzz_rust',
'--lib',
'--target-dir', meson.current_build_dir(),
'--manifest-path', meson.current_source_dir() / 'Cargo.toml',
'-Z', 'build-std=std,panic_abort',
'-Z', 'build-std-features=panic_immediate_abort',
]
features = []
if conf.get('HAVE_FONTATIONS', 0) == 1
features += ['font']
endif
if conf.get('HAVE_HARFRUZZ', 0) == 1
features += ['shape']
endif
if features.length() > 0
cargo_args += ['--features', ','.join(features)]
endif
buildtype = get_option('buildtype')
if buildtype == 'release' or buildtype == 'debugoptimized'
cargo_args += ['--profile', buildtype]
endif
opt_level = get_option('optimization')
rust_flags += ' -C opt-level=' + opt_level
sources = [
'lib.rs',
'font.rs',
'shape.rs',
]
harfbuzz_rust = custom_target(
'harfbuzz_rust',
input: sources + ['Cargo.toml', 'Cargo.lock'],
output: ['libharfbuzz_rust.a'],
depends: [hb_rs],
env: ['OUT_DIR=' + meson.current_build_dir(),
'RUSTFLAGS=' + rust_flags,
],
command: [
cargo, 'build',
] + cargo_args + [
'-Z', 'unstable-options',
'--artifact-dir', meson.current_build_dir(),
],
install: true,
install_dir: join_paths(get_option('prefix'), 'lib'),
)
harfbuzz_rust_dep = declare_dependency(
link_with: harfbuzz_rust,
)
clippy_fix = run_target(
'clippy-fix',
env: ['OUT_DIR=' + meson.current_build_dir()],
depends: [hb_rs, harfbuzz_rust],
command: [
cargo, 'clippy',
] + cargo_args + [
'--allow-dirty', '--fix',
],
)
if get_option('tests').enabled() and cargo.found()
test(
'clippy',
cargo,
env: ['OUT_DIR=' + meson.current_build_dir()],
depends: [hb_rs, harfbuzz_rust],
args: [
'clippy',
] + cargo_args + [
'--', '-D', 'warnings',
],
timeout: 120,
)
endif
# Convert source files in their src dir by transforming the `sources` list.
sources_in_source_dir = []
foreach s : sources
sources_in_source_dir += meson.current_source_dir() / s
endforeach
rustfmt_fix = run_target(
'rustfmt-fix',
env: ['OUT_DIR=' + meson.current_build_dir()],
depends: [hb_rs],
command: [
rustfmt,
'--edition', '2021',
'--',
sources_in_source_dir,
],
)
if get_option('tests').enabled() and rustfmt.found()
test(
'rustfmt',
rustfmt,
env: ['OUT_DIR=' + meson.current_build_dir()],
depends: [hb_rs],
args: [
'--check',
'--edition', '2021',
'--',
sources_in_source_dir,
],
)
endif