Simplify build-system further

Remove Fragile from the list of dependencies

It is not necessary for building 'gio' anymore,
since the upgrade to 'glib v2_58'.

Remove "online" and "reset_lock" Meson-options

Building Squeekboard should work offline.

Use a single "Cargo.toml"-file instead of splitting it into parts

and putting it back together when building.

Part-of: <https://gitlab.gnome.org/World/Phosh/squeekboard/-/merge_requests/623>
This commit is contained in:
MoonlightWave-12
2024-03-11 10:40:54 +01:00
parent 9cb6817da9
commit 5806b14628
8 changed files with 36 additions and 91 deletions

View File

@ -1,4 +0,0 @@
# Dependencies which are only used with online, crates.io builds.
[patch.crates-io]
# Dependency was yanked, but gio 0.7 needs it.
fragile = { git = "https://source.puri.sm/dorota.czaplejewicz/fragile.git", tag = "0.3.0" }

View File

@ -1,11 +1,38 @@
# Dependencies and tools which change based on build flags
# For the newer-than-Byzantium config
[package]
name = "rs"
version = "0.1.0"
edition = "2021"
[lib]
name = "rs"
path = "@path@/src/lib.rs"
crate-type = ["staticlib", "rlib"]
# Cargo can't do autodiscovery if Cargo.toml is not in the root.
[[bin]]
name = "test_layout"
path = "@path@/src/bin/test_layout.rs"
[[example]]
name = "test_layout"
path = "@path@/examples/test_layout.rs"
[[example]]
name = "find_orphan_layouts"
path = "@path@/examples/find_orphan_layouts.rs"
[features]
zbus_v1_5 = []
clap_v4 = []
[dependencies]
maplit = "1.0.*"
serde = { version = "1.0.*", features = ["derive"] }
serde_yaml = "0.8.*"
bitflags = "1.3.*"
clap = { version = "4.4.*", features=["std"], default-features = false }
zbus = "1.9.*"
zvariant = "2.10.*"
# Newer versions seem to confuse the version of Cargo on Debian Bullseye
zvariant_derive = "2.10.*"
xkbcommon = { version = "0.5.*", features = ["wayland"] }

View File

@ -1,33 +0,0 @@
[package]
name = "rs"
version = "0.1.0"
edition = "2021"
[lib]
name = "rs"
path = "@path@/src/lib.rs"
crate-type = ["staticlib", "rlib"]
# Cargo can't do autodiscovery if Cargo.toml is not in the root.
[[bin]]
name = "test_layout"
path = "@path@/src/bin/test_layout.rs"
[[example]]
name = "test_layout"
path = "@path@/examples/test_layout.rs"
[[example]]
name = "find_orphan_layouts"
path = "@path@/examples/find_orphan_layouts.rs"
[features]
zbus_v1_5 = []
clap_v4 = []
# Dependencies which don't change based on build flags
[dependencies]
maplit = "1.0.*"
serde = { version = "1.0.*", features = ["derive"] }
serde_yaml = "0.8.*"
# Here is inserted the Cargo.deps file

4
debian/rules vendored
View File

@ -29,7 +29,3 @@ export RUSTFLAGS = --remap-path-prefix=$(CURDIR)=/remap-pwd $(xgot)
# The Debian version of linked-hash-map doesn't provide any hash,
# causing Cargo to refuse to build with a crates.io copy
override_dh_auto_configure:
dh_auto_configure -- -Donline=false
override_dh_autoreconf:

View File

@ -85,45 +85,15 @@ summary = [
]
message('\n'.join(summary))
# Rust deps are changing, depending on compile flags. Cargo can't handle it alone.
# As a side effect, Cargo.toml never gets used.
cargo_toml_in = files('Cargo.toml.in')
path_data = configuration_data()
path_data.set('path', meson.source_root())
cargo_toml_base = configure_file(
input: 'Cargo.toml.in',
output: 'Cargo.toml.base',
cargo_toml = configure_file(
input: 'Cargo.toml',
output: 'Cargo.toml',
configuration: path_data,
)
cargo_patch = []
cargo_build_flags += ['--features', 'zbus_v1_5,clap_v4']
cargo_deps = files('Cargo.deps')
cargo_lock = files('Cargo.lock')
if get_option('online') == true
cargo_patch = [files('Cargo.deps.online')]
endif
cat = find_program('cat')
cargo_toml = custom_target(
'Cargo.toml',
output: 'Cargo.toml',
command: [cat, cargo_toml_base, cargo_deps] + cargo_patch,
capture: true,
)
cargo_deps = [cargo_toml]
if get_option('online') == true and get_option('reset_lock') == true
cargo_lock = custom_target(
'Cargo.lock',
output: 'Cargo.lock',
command: [cat, cargo_lock],
capture: true,
)
cargo_deps += [cargo_lock]
endif
dep_cargo = find_program('cargo')
cargo_script = find_program('cargo.sh')

View File

@ -11,14 +11,6 @@ option('find_orphans',
type: 'boolean', value: false,
description: 'Check if all present layout files are included in resources.')
option('online',
type: 'boolean', value: true,
description: 'Pull packages from the internet while building, as opposed to a local registry.')
option('reset_lock',
type: 'boolean', value: false,
description: 'Resets Cargo.lock to the one found in the source repo. Does not affect builds with online == false.')
option('strict',
type: 'boolean', value: true,
description: 'Turn more warnings into errors')

View File

@ -52,7 +52,6 @@ deps = [
cc.find_library('rt'),
cc.find_library('dl'),
cc.find_library('pthread'),
# dependency('libxklavier'), # FIXME remove
]
rslibs = custom_target(
@ -63,7 +62,6 @@ rslibs = custom_target(
install: false,
console: true,
command: [cargo_build] + ['@OUTPUT@', '--lib'] + cargo_build_flags,
depends: cargo_deps,
)
build_rstests = custom_target(
@ -78,7 +76,7 @@ build_rstests = custom_target(
install: false,
console: true,
command: [cargo_script, 'test', '--no-run'] + cargo_build_flags,
depends: [rslibs, cargo_deps], # no point building tests if the code itself fails
depends: [rslibs], # no point building tests if the code itself fails
)
test(
@ -86,9 +84,9 @@ test(
cargo_script,
args: ['test'] + cargo_build_flags,
env: ['SOURCE_DIR=' + meson.source_root()],
# this is a whole Carg-based test suite, let it run for a while
# This is a whole Cargo-based test suite, let it run for a while
timeout: 900,
depends: [build_rstests, cargo_deps],
depends: [build_rstests],
)
libsqueekboard = static_library('libsqueekboard',

View File

@ -16,5 +16,4 @@ test_layout = custom_target('squeekboard-test-layout',
+ cargo_build_flags,
install: true,
install_dir: bindir,
depends: cargo_deps,
)