rust: switch to cargo subprojects
Let Meson parse Cargo.lock and Cargo.toml and figure out the set
of Rust build dependencies. For now, the only change is that
subprojects are retrieved with "cargo_ws.subproject('NAME')"
instead of "subproject('NAME-API-rs')". However, just calling
"import('rust').workspace()" enables extra functionality that
operates by parsing Cargo.toml; it will be introduced a step
at a time in subsequent commits.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
1 parent
015306dec4
commit
6d28fc6089
23 files changed
+40
-52
No files matched your search
@@ -55,7 +55,7 @@ check-rust-tools-nightly:
|
||||
- source scripts/ci/gitlab-ci-section
|
||||
- section_start test "Running Rust code checks"
|
||||
- cd build
|
||||
- pyvenv/bin/meson devenv -w ../rust ${CARGO-cargo} fmt --check
|
||||
- pyvenv/bin/meson devenv -w ../ ${CARGO-cargo} fmt --check
|
||||
- make clippy
|
||||
- make rustdoc
|
||||
- section_end test
|
||||
@@ -69,7 +69,7 @@ check-rust-tools-nightly:
|
||||
when: on_success
|
||||
expire_in: 2 days
|
||||
paths:
|
||||
- rust/target/doc
|
||||
- target/doc
|
||||
|
||||
check-build-units:
|
||||
extends: .base_job_template
|
||||
|
||||
Generated
File renamed without changes.
@@ -1,9 +1,9 @@
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
members = [
|
||||
"hw/char/pl011",
|
||||
"hw/timer/hpet",
|
||||
"tests",
|
||||
"rust/hw/char/pl011",
|
||||
"rust/hw/timer/hpet",
|
||||
"rust/tests",
|
||||
]
|
||||
|
||||
[workspace.package]
|
||||
+4
-4
@@ -26,14 +26,14 @@ are accustomed to the more "normal" Cargo-based development workflow.
|
||||
In particular:
|
||||
|
||||
* the set of warnings and lints that are used to build QEMU always
|
||||
comes from the ``rust/Cargo.toml`` workspace file
|
||||
comes from the ``Cargo.toml`` workspace file
|
||||
|
||||
* it is also possible to use ``cargo`` for common Rust-specific coding
|
||||
tasks, in particular to invoke ``clippy``, ``rustfmt`` and ``rustdoc``.
|
||||
|
||||
To this end, QEMU includes a ``build.rs`` build script that picks up
|
||||
generated sources from QEMU's build directory and puts it in Cargo's
|
||||
output directory (typically ``rust/target/``). A vanilla invocation
|
||||
output directory (typically ``target/``). A vanilla invocation
|
||||
of Cargo will complain that it cannot find the generated sources,
|
||||
which can be fixed in different ways:
|
||||
|
||||
@@ -475,8 +475,8 @@ files, it is still highly experimental and is therefore not used.
|
||||
|
||||
Therefore, external crates must be added as subprojects for Meson to
|
||||
learn how to build them, as well as to the relevant ``Cargo.toml`` files.
|
||||
The versions specified in ``rust/Cargo.lock`` must be the same as the
|
||||
subprojects; note that the ``rust/`` directory forms a Cargo `workspace`__,
|
||||
The versions specified in ``Cargo.lock`` must be the same as the
|
||||
subprojects; note that the QEMU source tree forms a Cargo `workspace`__,
|
||||
and therefore there is a single lock file for the whole build.
|
||||
|
||||
__ https://doc.rust-lang.org/cargo/reference/workspaces.html#virtual-workspace
|
||||
|
||||
+2
-1
@@ -130,7 +130,8 @@ endif
|
||||
if have_rust
|
||||
rustc_args = [find_program('scripts/rust/rustc_args.py'),
|
||||
'--rustc-version', rustc.version(),
|
||||
'--workspace', meson.project_source_root() / 'rust']
|
||||
'--workspace', meson.project_source_root()]
|
||||
|
||||
rustfmt = find_program('rustfmt', required: false)
|
||||
|
||||
rustc_lint_args = run_command(rustc_args, '--lints',
|
||||
|
||||
+12
-25
@@ -4,31 +4,18 @@ else
|
||||
message('Rust enabled but it is only used by system emulators.')
|
||||
endif
|
||||
|
||||
subproject('anyhow-1-rs', required: true)
|
||||
subproject('bilge-0.2-rs', required: true)
|
||||
subproject('bilge-impl-0.2-rs', required: true)
|
||||
subproject('foreign-0.3-rs', required: true)
|
||||
subproject('glib-sys-0.21-rs', required: true)
|
||||
subproject('libc-0.2-rs', required: true)
|
||||
subproject('probe-0.5-rs', required: true)
|
||||
|
||||
anyhow_rs = dependency('anyhow-1-rs')
|
||||
bilge_rs = dependency('bilge-0.2-rs')
|
||||
bilge_impl_rs = dependency('bilge-impl-0.2-rs')
|
||||
foreign_rs = dependency('foreign-0.3-rs')
|
||||
glib_sys_rs = dependency('glib-sys-0.21-rs')
|
||||
libc_rs = dependency('libc-0.2-rs')
|
||||
probe_rs = dependency('probe-0.5-rs')
|
||||
|
||||
subproject('proc-macro2-1-rs', required: true)
|
||||
subproject('quote-1-rs', required: true)
|
||||
subproject('syn-2-rs', required: true)
|
||||
subproject('attrs-0.2-rs', required: true)
|
||||
|
||||
quote_rs_native = dependency('quote-1-rs', native: true)
|
||||
syn_rs_native = dependency('syn-2-rs', native: true)
|
||||
proc_macro2_rs_native = dependency('proc-macro2-1-rs', native: true)
|
||||
attrs_rs_native = dependency('attrs-0.2-rs', native: true)
|
||||
cargo_ws = import('rust').workspace()
|
||||
anyhow_rs = cargo_ws.subproject('anyhow').dependency()
|
||||
bilge_rs = cargo_ws.subproject('bilge').dependency()
|
||||
bilge_impl_rs = cargo_ws.subproject('bilge-impl').dependency()
|
||||
foreign_rs = cargo_ws.subproject('foreign').dependency()
|
||||
glib_sys_rs = cargo_ws.subproject('glib-sys').dependency()
|
||||
libc_rs = cargo_ws.subproject('libc').dependency()
|
||||
probe_rs = cargo_ws.subproject('probe').dependency()
|
||||
quote_rs_native = cargo_ws.subproject('quote').dependency()
|
||||
syn_rs_native = cargo_ws.subproject('syn').dependency()
|
||||
proc_macro2_rs_native = cargo_ws.subproject('proc-macro2').dependency()
|
||||
attrs_rs_native = cargo_ws.subproject('attrs').dependency()
|
||||
|
||||
genrs = []
|
||||
|
||||
|
||||
@@ -3,5 +3,5 @@ directory = anyhow-1.0.98
|
||||
source_url = https://crates.io/api/v1/crates/anyhow/1.0.98/download
|
||||
source_filename = anyhow-1.0.98.tar.gz
|
||||
source_hash = e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487
|
||||
#method = cargo
|
||||
method = cargo
|
||||
patch_directory = anyhow-1-rs
|
||||
@@ -3,7 +3,7 @@ directory = arbitrary-int-1.2.7
|
||||
source_url = https://crates.io/api/v1/crates/arbitrary-int/1.2.7/download
|
||||
source_filename = arbitrary-int-1.2.7.tar.gz
|
||||
source_hash = c84fc003e338a6f69fbd4f7fe9f92b535ff13e9af8997f3b14b6ddff8b1df46d
|
||||
#method = cargo
|
||||
method = cargo
|
||||
patch_directory = arbitrary-int-1-rs
|
||||
|
||||
# bump this version number on every change to meson.build or the patches:
|
||||
|
||||
@@ -3,5 +3,5 @@ directory = attrs-0.2.9
|
||||
source_url = https://crates.io/api/v1/crates/attrs/0.2.9/download
|
||||
source_filename = attrs-0.2.9.tar.gz
|
||||
source_hash = 2a207d40f43de65285f3de0509bb6cb16bc46098864fce957122bbacce327e5f
|
||||
#method = cargo
|
||||
method = cargo
|
||||
patch_directory = attrs-0.2-rs
|
||||
@@ -3,7 +3,7 @@ directory = bilge-0.2.0
|
||||
source_url = https://crates.io/api/v1/crates/bilge/0.2.0/download
|
||||
source_filename = bilge-0.2.0.tar.gz
|
||||
source_hash = dc707ed8ebf81de5cd6c7f48f54b4c8621760926cdf35a57000747c512e67b57
|
||||
#method = cargo
|
||||
method = cargo
|
||||
patch_directory = bilge-0.2-rs
|
||||
|
||||
# bump this version number on every change to meson.build or the patches:
|
||||
|
||||
@@ -3,7 +3,7 @@ directory = bilge-impl-0.2.0
|
||||
source_url = https://crates.io/api/v1/crates/bilge-impl/0.2.0/download
|
||||
source_filename = bilge-impl-0.2.0.tar.gz
|
||||
source_hash = feb11e002038ad243af39c2068c8a72bcf147acf05025dcdb916fcc000adb2d8
|
||||
#method = cargo
|
||||
method = cargo
|
||||
patch_directory = bilge-impl-0.2-rs
|
||||
|
||||
# bump this version number on every change to meson.build or the patches:
|
||||
|
||||
@@ -3,7 +3,7 @@ directory = either-1.12.0
|
||||
source_url = https://crates.io/api/v1/crates/either/1.12.0/download
|
||||
source_filename = either-1.12.0.tar.gz
|
||||
source_hash = 3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b
|
||||
#method = cargo
|
||||
method = cargo
|
||||
patch_directory = either-1-rs
|
||||
|
||||
# bump this version number on every change to meson.build or the patches:
|
||||
|
||||
@@ -3,5 +3,5 @@ directory = foreign-0.3.1
|
||||
source_url = https://crates.io/api/v1/crates/foreign/0.3.1/download
|
||||
source_filename = foreign-0.3.1.tar.gz
|
||||
source_hash = 17ca1b5be8c9d320daf386f1809c7acc0cb09accbae795c2001953fa50585846
|
||||
#method = cargo
|
||||
method = cargo
|
||||
patch_directory = foreign-0.3-rs
|
||||
@@ -3,5 +3,5 @@ directory = glib-sys-0.21.2
|
||||
source_url = https://crates.io/api/v1/crates/glib-sys/0.21.2/download
|
||||
source_filename = glib-sys-0.21.2.tar.gz
|
||||
source_hash = d09d3d0fddf7239521674e57b0465dfbd844632fec54f059f7f56112e3f927e1
|
||||
#method = cargo
|
||||
method = cargo
|
||||
patch_directory = glib-sys-0.21-rs
|
||||
@@ -3,7 +3,7 @@ directory = itertools-0.11.0
|
||||
source_url = https://crates.io/api/v1/crates/itertools/0.11.0/download
|
||||
source_filename = itertools-0.11.0.tar.gz
|
||||
source_hash = b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57
|
||||
#method = cargo
|
||||
method = cargo
|
||||
patch_directory = itertools-0.11-rs
|
||||
|
||||
# bump this version number on every change to meson.build or the patches:
|
||||
|
||||
@@ -3,5 +3,5 @@ directory = libc-0.2.162
|
||||
source_url = https://crates.io/api/v1/crates/libc/0.2.162/download
|
||||
source_filename = libc-0.2.162.tar.gz
|
||||
source_hash = 18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398
|
||||
#method = cargo
|
||||
method = cargo
|
||||
patch_directory = libc-0.2-rs
|
||||
@@ -3,5 +3,5 @@ directory = probe-0.5.2
|
||||
source_url = https://crates.io/api/v1/crates/probe/0.5.2/download
|
||||
source_filename = probe-0.5.2.tar.gz
|
||||
source_hash = 136558b6e1ebaecc92755d0ffaf9421f519531bed30cc2ad23b22cb00965cc5e
|
||||
#method = cargo
|
||||
method = cargo
|
||||
patch_directory = probe-0.5-rs
|
||||
@@ -3,7 +3,7 @@ directory = proc-macro-error-1.0.4
|
||||
source_url = https://crates.io/api/v1/crates/proc-macro-error/1.0.4/download
|
||||
source_filename = proc-macro-error-1.0.4.tar.gz
|
||||
source_hash = da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c
|
||||
#method = cargo
|
||||
method = cargo
|
||||
patch_directory = proc-macro-error-1-rs
|
||||
|
||||
# bump this version number on every change to meson.build or the patches:
|
||||
|
||||
@@ -3,7 +3,7 @@ directory = proc-macro-error-attr-1.0.4
|
||||
source_url = https://crates.io/api/v1/crates/proc-macro-error-attr/1.0.4/download
|
||||
source_filename = proc-macro-error-attr-1.0.4.tar.gz
|
||||
source_hash = a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869
|
||||
#method = cargo
|
||||
method = cargo
|
||||
patch_directory = proc-macro-error-attr-1-rs
|
||||
|
||||
# bump this version number on every change to meson.build or the patches:
|
||||
|
||||
@@ -3,7 +3,7 @@ directory = proc-macro2-1.0.95
|
||||
source_url = https://crates.io/api/v1/crates/proc-macro2/1.0.95/download
|
||||
source_filename = proc-macro2-1.0.95.0.tar.gz
|
||||
source_hash = 02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778
|
||||
#method = cargo
|
||||
method = cargo
|
||||
patch_directory = proc-macro2-1-rs
|
||||
|
||||
# bump this version number on every change to meson.build or the patches:
|
||||
|
||||
@@ -3,7 +3,7 @@ directory = quote-1.0.36
|
||||
source_url = https://crates.io/api/v1/crates/quote/1.0.36/download
|
||||
source_filename = quote-1.0.36.0.tar.gz
|
||||
source_hash = 0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7
|
||||
#method = cargo
|
||||
method = cargo
|
||||
patch_directory = quote-1-rs
|
||||
|
||||
# bump this version number on every change to meson.build or the patches:
|
||||
|
||||
@@ -3,7 +3,7 @@ directory = syn-2.0.104
|
||||
source_url = https://crates.io/api/v1/crates/syn/2.0.104/download
|
||||
source_filename = syn-2.0.104.0.tar.gz
|
||||
source_hash = 17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40
|
||||
#method = cargo
|
||||
method = cargo
|
||||
patch_directory = syn-2-rs
|
||||
|
||||
# bump this version number on every change to meson.build or the patches:
|
||||
|
||||
@@ -3,7 +3,7 @@ directory = unicode-ident-1.0.12
|
||||
source_url = https://crates.io/api/v1/crates/unicode-ident/1.0.12/download
|
||||
source_filename = unicode-ident-1.0.12.tar.gz
|
||||
source_hash = 3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b
|
||||
#method = cargo
|
||||
method = cargo
|
||||
patch_directory = unicode-ident-1-rs
|
||||
|
||||
# bump this version number on every change to meson.build or the patches:
|
||||
|
||||
Reference in new issue
Block a user