Skip to content

Commit f1bd4ae

Browse files
committed
cargo: define 'features' variable to be used in meson/meson.build
1 parent d37d46d commit f1bd4ae

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

docs/markdown/Wrap-dependency-system-manual.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ Some naming conventions need to be respected:
362362
This is typically used as `extra_args += ['--cfg', 'foo']`.
363363
- The `extra_deps` variable is pre-defined and can be used to add extra dependencies.
364364
This is typically used as `extra_deps += dependency('foo')`.
365+
- The `features` variable is pre-defined and contains the list of features enabled
366+
on this crate.
365367

366368
Since *1.5.0* Cargo wraps can also be provided with `Cargo.lock` file at the root
367369
of (sub)project source tree. Meson will automatically load that file and convert

mesonbuild/cargo/interpreter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,10 @@ def interpret_package(self, manifest: Manifest, build: builder.Builder, subdir:
129129

130130
def _create_package(self, pkg: PackageState, build: builder.Builder, subdir: str) -> T.List[mparser.BaseNode]:
131131
ast: T.List[mparser.BaseNode] = [
132+
build.assign(build.array([build.string(f) for f in pkg.features]), 'features'),
132133
build.function('message', [
133134
build.string('Enabled features:'),
134-
build.array([build.string(f) for f in pkg.features]),
135+
build.identifier('features'),
135136
]),
136137
]
137138
ast += self._create_dependencies(pkg, build)

0 commit comments

Comments
 (0)