diff mbox series

[PoCv2,15/15] rust: use vendored-sources

Message ID 20201011203513.1621355-16-marcandre.lureau@redhat.com
State New
Headers show
Series Rust binding for QAPI (qemu-ga only, for now) | expand

Commit Message

Marc-André Lureau Oct. 11, 2020, 8:35 p.m. UTC
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.

"cargo vendor" makes that simple.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 .cargo/config            | 5 +++++
 .gitmodules              | 3 +++
 configure                | 8 ++++++++
 rust/vendored            | 1 +
 scripts/cargo_wrapper.py | 1 +
 5 files changed, 18 insertions(+)
 create mode 100644 .cargo/config
 create mode 160000 rust/vendored
diff mbox series

Patch

diff --git a/.cargo/config b/.cargo/config
new file mode 100644
index 0000000000..a8c55940d5
--- /dev/null
+++ b/.cargo/config
@@ -0,0 +1,5 @@ 
+[source.crates-io]
+replace-with = "vendored-sources"
+
+[source.vendored-sources]
+directory = "rust/vendored"
diff --git a/.gitmodules b/.gitmodules
index 2bdeeacef8..62a2be12b9 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -64,3 +64,6 @@ 
 [submodule "roms/vbootrom"]
 	path = roms/vbootrom
 	url = https://git.qemu.org/git/vbootrom.git
+[submodule "rust/vendored"]
+	path = rust/vendored
+	url = https://github.com/elmarco/qemu-rust-vendored.git
diff --git a/configure b/configure
index 7945ceac63..702546d87f 100755
--- a/configure
+++ b/configure
@@ -1932,6 +1932,14 @@  if test "$with_rust" = auto && has cargo; then
     with_rust=yes
 fi
 
+case "$with_rust" in
+  yes)
+    if test -e "${source_path}/.git" && test $git_update = 'yes' ; 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/rust/vendored b/rust/vendored
new file mode 160000
index 0000000000..71ee65d042
--- /dev/null
+++ b/rust/vendored
@@ -0,0 +1 @@ 
+Subproject commit 71ee65d042606d18de3175d67f9e4e4b78a1f865
diff --git a/scripts/cargo_wrapper.py b/scripts/cargo_wrapper.py
index 164fad5123..4a0673407b 100644
--- a/scripts/cargo_wrapper.py
+++ b/scripts/cargo_wrapper.py
@@ -51,6 +51,7 @@  def build_lib(args: argparse.Namespace) -> None:
         target_dir,
         "--manifest-path",
         manifest_path,
+        "--offline",
     ]
     if args.target_triple:
         cargo_cmd += ["--target", args.target_triple]