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
Open
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4e03af5
build: Warning message was not telling which target it links to.
xclaesse Nov 23, 2023
b30f6e3
compilers: Every compiler can run code
xclaesse Nov 3, 2023
e48ba1c
compilers: Do not dump File content in log for compiler checks.
xclaesse Nov 6, 2023
84e2002
compilers: Allow setting env and workdir for run checks
xclaesse Nov 6, 2023
f7c9b9a
modules: Add helper to add project/global arguments
xclaesse Nov 3, 2023
6ede467
cargo: Ensure Dependency.package always has a value
xclaesse Oct 11, 2023
fd1cd06
cargo: Add API version into dependency name
xclaesse Oct 11, 2023
2455524
cargo: Generate .wrap file from crates.io dependencies
xclaesse Oct 11, 2023
11d0f66
cargo: Add patch_directory into generated wrap if available
xclaesse Oct 11, 2023
4372383
cargo: Fix cfg() parsing
xclaesse Nov 1, 2023
8ffa42d
cargo: builder: Add elseblock support
xclaesse Nov 1, 2023
ffa0a19
cargo: Split function that adds a single dependency
xclaesse Nov 1, 2023
b22d37c
rust: Add get_target_triplet() method
xclaesse Nov 6, 2023
06ba9b7
rust: Add rust.cargo_cfg() module method
xclaesse Nov 1, 2023
65a079f
cargo: Fix error when defining options on build-dependencies
xclaesse Nov 22, 2023
2137f45
cargo: Only build one crate type at a time
xclaesse Nov 24, 2023
37df695
cargo: Set CARGO_PKG_* in env when building and running build.rs
xclaesse Nov 24, 2023
a6dd090
cargo: Warn if project has build-dependencies
xclaesse Feb 23, 2024
ad49e05
rust: recursively pull proc-macro dependencies as well
xclaesse Feb 27, 2024
600d1e6
cargo: Add support for `system-deps` dependencies
thiblahute Apr 22, 2023
18bd1ec
WIP: workspace support and fixes
xclaesse Mar 4, 2024
f7621ee
cargo: Override cargo provided dependencies with latest version
xclaesse Mar 4, 2024
cf0224b
cargo: A dependency is required if a feature with same name is enabled
xclaesse Mar 4, 2024
6a3f030
cargo: Fix crate name VS package name VS dependency name confusion
xclaesse Mar 4, 2024
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
Prev Previous commit
Next Next commit
cargo: Fix error when defining options on build-dependencies
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.
  • Loading branch information
xclaesse committed Feb 28, 2024
commit 65a079fd7fd1f1267dcc3d6a060a8de421b7a6db
18 changes: 10 additions & 8 deletions mesonbuild/cargo/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,14 @@ def _create_project(cargo: Manifest, build: builder.Builder) -> T.List[mparser.B
return [build.function('project', args, kwargs)]


def _all_dependencies(cargo: Manifest) -> T.Iterable[T.Tuple[str, Dependency]]:
yield from cargo.dependencies.items()
yield from cargo.dev_dependencies.items()
yield from cargo.build_dependencies.items()
for deps in cargo.target.values():
yield from deps.items()


def _process_feature(cargo: Manifest, feature: str) -> T.Tuple[T.Set[str], T.Dict[str, T.Set[str]], T.Set[str]]:
# Set of features that must also be enabled if this feature is enabled.
features: T.Set[str] = set()
Expand Down Expand Up @@ -475,7 +483,7 @@ def _create_features(cargo: Manifest, build: builder.Builder) -> T.List[mparser.
# and one per dependency.
ast: T.List[mparser.BaseNode] = []
ast.append(build.assign(build.dict({}), 'features'))
for depname in itertools.chain.from_iterable([cargo.dependencies] + [deps for deps in cargo.target.values()]):
for depname, _ in _all_dependencies(cargo):
ast.append(build.assign(build.dict({}), _options_varname(depname)))

# Declare a dict that map required dependencies to true
Expand Down Expand Up @@ -768,13 +776,7 @@ def dependencies(source_dir: str) -> T.Dict[str, Dependency]:
deps: T.Dict[str, Dependency] = {}
manifests = _load_manifests(source_dir)
for cargo in manifests.values():
deps_i = [
cargo.dependencies.values(),
cargo.dev_dependencies.values(),
cargo.build_dependencies.values(),
]
deps_i += [deps.values() for deps in cargo.target.values()]
for dep in itertools.chain.from_iterable(deps_i):
for _, dep in _all_dependencies(cargo):
depname = _dependency_name(dep.package, dep.api)
deps[depname] = dep
return deps