[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v3 13/32] rust: use vendored-sources
From: |
marcandre . lureau |
Subject: |
[RFC v3 13/32] rust: use vendored-sources |
Date: |
Tue, 7 Sep 2021 16:19:24 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Most likely, QEMU will want tighter control over the sources, rather
than relying on crates.io downloading, use a git submodule with all the
dependencies. However, cargo --offline was added in 1.36.
"cargo vendor" helps gathering and updating the dependencies.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
configure | 8 ++++++++
meson.build | 7 ++++++-
.cargo/config.toml.in | 5 +++++
.cargo/meson.build | 5 +++++
.gitmodules | 4 ++++
rust/vendored | 1 +
scripts/archive-source.sh | 2 +-
scripts/cargo_wrapper.py | 1 +
8 files changed, 31 insertions(+), 2 deletions(-)
create mode 100644 .cargo/config.toml.in
create mode 100644 .cargo/meson.build
create mode 160000 rust/vendored
diff --git a/configure b/configure
index 470b90543f..82a94ab93b 100755
--- a/configure
+++ b/configure
@@ -2068,6 +2068,14 @@ if test -z "$ninja"; then
fi
fi
+case "$with_rust" in
+ auto|enabled)
+ if test -e "${source_path}/.git"; then
+ git_submodules="${git_submodules} rust/vendored"
+ fi
+ ;;
+esac
+
# Check that the C compiler works. Doing this here before testing
# the host CPU ensures that we had a valid CC to autodetect the
# $cpu var (and we should bail right here if that's not the case).
diff --git a/meson.build b/meson.build
index a21c70d77f..29d218d35a 100644
--- a/meson.build
+++ b/meson.build
@@ -108,7 +108,11 @@ endif
bzip2 = find_program('bzip2', required: install_edk2_blobs)
-cargo = find_program('cargo', required: get_option('with_rust'))
+cargo = find_program('cargo',
+ required: get_option('with_rust'),
+ # require --offline support (1.36), but fixed (1.42)
+ version: '>= 1.42')
+
with_rust = cargo.found()
cargo_wrapper = [
find_program('scripts/cargo_wrapper.py'),
@@ -126,6 +130,7 @@ if with_rust
error('cross-compiling, but no Rust target-triple defined.')
endif
endif
+ subdir('.cargo')
endif
config_host_data.set('CONFIG_WITH_RUST', with_rust)
diff --git a/.cargo/config.toml.in b/.cargo/config.toml.in
new file mode 100644
index 0000000000..d1531aa52a
--- /dev/null
+++ b/.cargo/config.toml.in
@@ -0,0 +1,5 @@
+[source.crates-io]
+replace-with = "vendored-sources"
+
+[source.vendored-sources]
+directory = "@vendored_directory@"
diff --git a/.cargo/meson.build b/.cargo/meson.build
new file mode 100644
index 0000000000..4e7c296ab0
--- /dev/null
+++ b/.cargo/meson.build
@@ -0,0 +1,5 @@
+configure_file(output: 'config.toml',
+ input: 'config.toml.in',
+ configuration: {
+ 'vendored_directory': meson.source_root() / 'rust/vendored'
+ })
diff --git a/.gitmodules b/.gitmodules
index 08b1b48a09..f767a4f386 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -64,3 +64,7 @@
[submodule "roms/vbootrom"]
path = roms/vbootrom
url = https://gitlab.com/qemu-project/vbootrom.git
+[submodule "rust/vendored"]
+ path = rust/vendored
+ #url = https://gitlab.com/qemu-project/qemu-rust-vendored.git
+ url = https://github.com/elmarco/qemu-rust-vendored.git
diff --git a/rust/vendored b/rust/vendored
new file mode 160000
index 0000000000..7077bbbd11
--- /dev/null
+++ b/rust/vendored
@@ -0,0 +1 @@
+Subproject commit 7077bbbd11a67d60062a9483f996113a349a4ca1
diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh
index c6169db69f..03afcee8b9 100755
--- a/scripts/archive-source.sh
+++ b/scripts/archive-source.sh
@@ -26,7 +26,7 @@ sub_file="${sub_tdir}/submodule.tar"
# independent of what the developer currently has initialized
# in their checkout, because the build environment is completely
# different to the host OS.
-submodules="dtc slirp meson ui/keycodemapdb"
+submodules="dtc slirp meson ui/keycodemapdb rust/vendored"
submodules="$submodules tests/fp/berkeley-softfloat-3
tests/fp/berkeley-testfloat-3"
sub_deinit=""
diff --git a/scripts/cargo_wrapper.py b/scripts/cargo_wrapper.py
index 75518e8c02..c07f51494b 100644
--- a/scripts/cargo_wrapper.py
+++ b/scripts/cargo_wrapper.py
@@ -78,6 +78,7 @@ def get_cargo_rustc(
target_dir,
"--manifest-path",
manifest_path,
+ "--offline",
]
cargo_cmd += cargo_rustc_args
if args.target_triple:
--
2.33.0.113.g6c40894d24
- Re: [RFC v3 09/32] build-sys: add i686 cpu target, (continued)
- [RFC v3 10/32] build-sys: add --with-rust{-target} & basic build infrastructure, marcandre . lureau, 2021/09/07
- [RFC v3 11/32] build-sys: add a cargo-wrapper script, marcandre . lureau, 2021/09/07
- [RFC v3 12/32] rust: provide a common crate for QEMU, marcandre . lureau, 2021/09/07
- [RFC v3 13/32] rust: use vendored-sources,
marcandre . lureau <=
- Re: [RFC v3 13/32] rust: use vendored-sources, Ian Jackson, 2021/09/08
- Re: [RFC v3 13/32] rust: use vendored-sources, Marc-André Lureau, 2021/09/08
- Re: [RFC v3 13/32] rust: use vendored-sources, Ian Jackson, 2021/09/08
- Re: [RFC v3 13/32] rust: use vendored-sources, Marc-André Lureau, 2021/09/08
- Re: [RFC v3 13/32] rust: use vendored-sources, Peter Maydell, 2021/09/08
- Re: [RFC v3 13/32] rust: use vendored-sources, Ian Jackson, 2021/09/08
- Re: [RFC v3 13/32] rust: use vendored-sources, Marc-André Lureau, 2021/09/08
- Re: [RFC v3 13/32] rust: use vendored-sources, Ian Jackson, 2021/09/08
- Re: [RFC v3 13/32] rust: use vendored-sources, Marc-André Lureau, 2021/09/08
- Re: [RFC v3 13/32] rust: use vendored-sources, Ian Jackson, 2021/09/08