Skip to content

Generated meson.build from Cargo crate references undefined variable #13855

Open
@2xsaiko

Description

@2xsaiko

Describe the bug
Meson's cargo importer generates a meson.build that is referencing an undefined variable for the crate libflate_lz77, which is a transitive dependency of the crate I'm trying to import.

Might be related to these two crates depending on each other, or dev-dependencies: libflate depends on libflate_lz77 and libflate_lz77 has libflate in its dev-dependencies.

Executing subproject matfile:libflate-2-rs:libflate_lz77-2-rs method cargo

libflate_lz77-2-rs| Generated Meson AST: /Users/saiko/Src/test/build/subprojects/libflate_lz77-2.1.0/meson.build
libflate_lz77-2-rs| Project name: libflate_lz77
libflate_lz77-2-rs| Project version: 2.1.0
libflate_lz77-2-rs| Rust compiler for the host machine: rustc -C linker=cc (rustc 1.82.0)
libflate_lz77-2-rs| Rust linker for the host machine: rustc -C linker=cc ld.lld 19.1.2

subprojects/libflate_lz77-2.1.0/meson.build:25:-1: ERROR: Unknown variable "libflate_options".

The first couple lines from the meson.build in question (note libflate_options not being defined unlike the others):

project(
  'libflate_lz77',
  'rust',
  version : '2.1.0',
  meson_version : '>= 1.6.0',
  default_options : ['rust_std=2021'],
  license : 'MIT'
)
rust = import('rust')
features = {}
core2_options = {}
hashbrown_options = {}
rle_decode_fast_options = {}
required_deps = {}
if get_option('feature-default')
  required_deps += {'core2' : true, 'libflate' : true}
  features += {'std' : true, 'default' : true}
  core2_options += {'feature-std' : true}
  libflate_options += {'feature-std' : true}
endif
if get_option('feature-std')
  required_deps += {'core2' : true, 'libflate' : true}
  features += {'std' : true}
  core2_options += {'feature-std' : true}
  libflate_options += {'feature-std' : true}
endif

To Reproduce
meson.build:

project(
    'test',
    'rust',
    default_options: {'rust_std': '2021'},
    meson_version: '1.6.0',
)

matfile_proj = subproject('matfile')

matfile.wrap:

[wrap-file]
method = cargo
directory = matfile-0.5.0

source_url = https://crates.io/api/v1/crates/matfile/0.5.0/download
source_filename = matfile-0.5.0.tar.gz
source_hash = b22724209845c600f095bca5be902d636b4fc4f0b27fe5bb5d8314b5c117d0d6

[provide]
dependency_names = matfile

Expected behavior
The generated meson.build for libflate_lz77 does not reference an undefined variable.

system parameters

  • Is this a cross build or just a plain native build (for the same computer)? Native build
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.) Gentoo Linux
  • what Python version are you using? 3.12.7
  • what meson --version 1.6.0 (with patch from 5769074)
  • what ninja --version if it's a Ninja build? 1.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions