diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2023-06-10 16:07:21 -0400 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2024-02-26 10:03:52 -0500 |
commit | 114e032e6a27d0eb9ef5de1a811ce7b0461c3efc (patch) | |
tree | f20b3b240b4cb32ba54644bd7388e97038311dfc /test cases | |
parent | d075bdb3ca39a077994fa65e7fafb98cdebf5da6 (diff) | |
download | meson-114e032e6a27d0eb9ef5de1a811ce7b0461c3efc.zip meson-114e032e6a27d0eb9ef5de1a811ce7b0461c3efc.tar.gz meson-114e032e6a27d0eb9ef5de1a811ce7b0461c3efc.tar.bz2 |
cargo: Expose features as Meson boolean options
Diffstat (limited to 'test cases')
6 files changed, 53 insertions, 2 deletions
diff --git a/test cases/rust/22 cargo subproject/subprojects/bar-rs/Cargo.toml b/test cases/rust/22 cargo subproject/subprojects/bar-rs/Cargo.toml index 232b4d7..d60a5d8 100644 --- a/test cases/rust/22 cargo subproject/subprojects/bar-rs/Cargo.toml +++ b/test cases/rust/22 cargo subproject/subprojects/bar-rs/Cargo.toml @@ -1,3 +1,14 @@ [package] name = "bar" version = "0.1" + +# This dependency does not exist, it is required by default but this subproject +# is called with default-features=false. +[dependencies.notfound] +optional = true +version = "1.0" + +[features] +default = ["f2"] +f1 = [] +f2 = ["notfound"] diff --git a/test cases/rust/22 cargo subproject/subprojects/extra-dep-rs/lib.c b/test cases/rust/22 cargo subproject/subprojects/extra-dep-rs/lib.c new file mode 100644 index 0000000..c2a0777 --- /dev/null +++ b/test cases/rust/22 cargo subproject/subprojects/extra-dep-rs/lib.c @@ -0,0 +1,4 @@ +int extra_func(void) +{ + return 0; +} diff --git a/test cases/rust/22 cargo subproject/subprojects/extra-dep-rs/meson.build b/test cases/rust/22 cargo subproject/subprojects/extra-dep-rs/meson.build new file mode 100644 index 0000000..3ba7852 --- /dev/null +++ b/test cases/rust/22 cargo subproject/subprojects/extra-dep-rs/meson.build @@ -0,0 +1,10 @@ +project('extra dep', 'c', version: '1.0') + +assert(get_option('feature-default') == true) + +l = static_library('extra-dep', 'lib.c') +d = declare_dependency(link_with: l, + variables: { + 'features': 'default', + }) +meson.override_dependency('extra-dep-rs', d) diff --git a/test cases/rust/22 cargo subproject/subprojects/extra-dep-rs/meson_options.txt b/test cases/rust/22 cargo subproject/subprojects/extra-dep-rs/meson_options.txt new file mode 100644 index 0000000..9311d9e --- /dev/null +++ b/test cases/rust/22 cargo subproject/subprojects/extra-dep-rs/meson_options.txt @@ -0,0 +1 @@ +option('feature-default', type: 'boolean', value: true) diff --git a/test cases/rust/22 cargo subproject/subprojects/foo-rs/Cargo.toml b/test cases/rust/22 cargo subproject/subprojects/foo-rs/Cargo.toml index 214c327..796548d 100644 --- a/test cases/rust/22 cargo subproject/subprojects/foo-rs/Cargo.toml +++ b/test cases/rust/22 cargo subproject/subprojects/foo-rs/Cargo.toml @@ -6,5 +6,22 @@ edition = "2021" [lib] crate-type = ["cdylib"] +# This dependency does not exist, verify optional works. +[dependencies.notfound] +optional = true +version = "1.0" + +# This dependency is optional but required for f3 which is on by default. +[dependencies.extra-dep] +optional = true +version = "1.0" + [dependencies] -mybar = { version = "0.1", package = "bar" } +mybar = { version = "0.1", package = "bar", default-features = false } + +[features] +default = ["f1"] +f1 = ["f2", "f3"] +f2 = ["f1"] +f3 = ["mybar/f1", "dep:extra-dep", "notfound?/invalid"] +f4 = ["dep:notfound"] diff --git a/test cases/rust/22 cargo subproject/subprojects/foo-rs/src/lib.rs b/test cases/rust/22 cargo subproject/subprojects/foo-rs/src/lib.rs index 732d7d2..4f0a310 100644 --- a/test cases/rust/22 cargo subproject/subprojects/foo-rs/src/lib.rs +++ b/test cases/rust/22 cargo subproject/subprojects/foo-rs/src/lib.rs @@ -1,4 +1,12 @@ +extern "C" { + fn extra_func() -> i32; +} + #[no_mangle] pub extern "C" fn rust_func() -> i32 { - mybar::VALUE + let v: i32; + unsafe { + v = extra_func(); + }; + mybar::VALUE + v } |