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

WIP: cargo: Support building multiple versions of the same crate #12363

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

xclaesse
Copy link
Member

@xclaesse xclaesse commented Oct 11, 2023

cargo: Add support for system-deps dependencies
rust: recursively pull proc-macro dependencies as well
cargo: Abort if project has build-dependencies
cargo: Set CARGO_PKG_* in env when building and running build.rs
cargo: Only build one crate type at a time
cargo: Fix error when defining options on build-dependencies
rust: Add rust.cargo_cfg() module method
rust: Add get_target_triplet() method
cargo: Split function that adds a single dependency
cargo: builder: Add elseblock support
cargo: Fix cfg() parsing
cargo: Add patch_directory into generated wrap if available
cargo: Generate .wrap file from crates.io dependencies
cargo: Add API version into dependency name
cargo: Ensure Dependency.package always has a value
modules: Add helper to add project/global arguments
compilers: Allow setting env and workdir for run checks
compilers: Do not dump File content in log for compiler checks.
compilers: Every compiler can run code
build: Warning message was not telling which target it links to.

I've split this PR into smaller ones:

mesonbuild/modules/rust.py Fixed Show fixed Hide fixed
@xclaesse xclaesse force-pushed the cargo-multiver branch 2 times, most recently from de93962 to 7900636 Compare November 24, 2023 20:58
@xclaesse xclaesse force-pushed the cargo-multiver branch 2 times, most recently from 55f111e to b068532 Compare February 26, 2024 19:48
@xclaesse xclaesse changed the title WIP: cargo: Add API version into dependency name and generate .wrap files automatically WIP: cargo: Support building multiple versions of the same crate Feb 26, 2024
Copy link
Contributor

@alyssais alyssais left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cargo forces the build.rs to be panic=unwind. It would probably make sense to do the same here?

Compiling and linking code is part of the Compiler base class, there is
no reason it cannot also run executables.
When doing a compiler check with a File object, there is no need to dump
the file into logs, we can just print the path. The file could
potentially be big.
This is not exposed in API, but will be used internally.
Add cfg token to be able to parse the top level cfg() function.

Fix parser which was creating a new iterator when recursing which causer
the caller function's iterator to not have advanced when recursing
function returns.
That function will be reused to add target dependencies as well.
This returns --target value from rustc command line, or the native
target.
It compiles and run build.rs to return a list of a configs for cargo
projects.
We are not using them yet, but we should already at least declare its
options dictionary. This avoid crashing when generated code adds
features into that dict that was not yet declared.
xclaesse and others added 3 commits February 28, 2024 10:20
In that case build.rs cannot be used and must be ported manually.
When the proc-macro rlib is in a different subdir, it would miss the
needed -L argument and rustc would not find it. Meson was assuming that
proc-macros are only needed when building libraries that uses it, but it
turns out that was wrong, as show by the unit test.
@@ -188,6 +188,8 @@

members: T.List[str]
exclude: T.List[str]
package: Package
dependencies: T.Dict[str, DependencyV],

Check failure

Code scanning / CodeQL

Syntax error Error

Syntax Error (in Python 3).
@@ -20,8 +20,12 @@
import collections
import typing as T

from functools import lru_cache

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'lru_cache' is not used.
If dependency name does not match the package name, we have to rename
the crate name to the dependency name. Yes, that makes 3 different names
for the same dependency, good job cargo! For example:
- package name: cairo-sys-rs
- crate name: cairo-sys
- dependency name: ffi
sdroege added a commit to sdroege/mandelbrot that referenced this pull request Mar 4, 2024
@sdroege
Copy link
Contributor

sdroege commented Mar 4, 2024

FTR, the latest changes here make it possible to build a GTK4 Rust application successfully: sdroege/mandelbrot@3ea3548

sdroege added a commit to sdroege/mandelbrot that referenced this pull request Mar 4, 2024
@xclaesse
Copy link
Member Author

xclaesse commented Mar 6, 2024

I started to split this PR in smaller parts to make it easier to review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants