Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cargo: support lib.path in Cargo.toml #12919

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions mesonbuild/cargo/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class Library(BuildTarget):

doctest: bool = True
doc: bool = True
path: str = os.path.join('src', 'lib.rs')
proc_macro: bool = False
crate_type: T.List[manifest.CRATE_TYPE] = dataclasses.field(default_factory=lambda: ['lib'])
doc_scrape_examples: bool = True
Expand Down Expand Up @@ -606,7 +607,7 @@ def _create_lib(cargo: Manifest, build: builder.Builder, crate_type: manifest.CR

posargs: T.List[mparser.BaseNode] = [
build.string(fixup_meson_varname(cargo.package.name)),
build.string(os.path.join('src', 'lib.rs')),
build.string(cargo.lib.path),
]

kwargs: T.Dict[str, mparser.BaseNode] = {
Expand Down Expand Up @@ -696,7 +697,7 @@ def interpret(subp_name: str, subdir: str, env: Environment) -> T.Tuple[mparser.

# Libs are always auto-discovered and there's no other way to handle them,
# which is unfortunate for reproducability
if os.path.exists(os.path.join(env.source_dir, cargo.subdir, cargo.path, 'src', 'lib.rs')):
if os.path.exists(os.path.join(env.source_dir, cargo.subdir, cargo.path, cargo.lib.path)):
for crate_type in cargo.lib.crate_type:
ast.extend(_create_lib(cargo, build, crate_type))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition = "2021"

[lib]
crate-type = ["cdylib"]
path = "lib.rs"

# This dependency does not exist, verify optional works.
[dependencies.notfound]
Expand Down
Loading