[vlc-devel] [PATCHv3 3/7] contrib: add rust rules

Thomas Guillem thomas at gllm.fr
Tue Sep 1 10:04:48 CEST 2020



On Tue, Sep 1, 2020, at 08:27, Steve Lhomme wrote:
> On 2020-08-31 13:38, Thomas Guillem wrote:
> > 
> > 
> > On Mon, Aug 31, 2020, at 09:24, Steve Lhomme wrote:
> >>
> >>
> >> On 2020-08-27 16:44, Thomas Guillem wrote:
> >>> This adds CARGO_INSTALL and CARGOC_INSTALL, using the correct cargo path (from
> >>> contribs) and using the correct install arguments.
> >>>
> >>> cf. https://doc.rust-lang.org/cargo/commands/cargo-vendor.html
> >>> 'cargo vendor' fetch all dependencies required by a Rust project.
> >>>
> >>> Administrators will be able to create an archive (via the upcoming
> >>> cargo-vendor-archive.sh script) containing all dependencies of a Rust project
> >>> and upload it to the VideoLAN FTP.
> >>>
> >>> *-vendor packages will try to use such archive as the only crates source. In
> >>> case of failure (checksum failed, archive not uploaded), CARGO_INSTALL will
> >>> fallback to crates.io (by not using the --frozen --offline arguments).
> > 
> > 
> > There is one -vendor project, hence one -vendor checksum per package.
> 
> So I don't understand the foreach loop in the makefile.

cf. UNPACK. This a way to match an archive from the list of prerequisite

> 
> >>>
> >>> A warning is displayed when the crates.io source is used. This is like our
> >>> download_pkg mechanism (try first VideoLAN FTP, or print a warning and use the
> >>> original source).
> >>> ---
> >>>    contrib/src/main-rust.mak | 42 +++++++++++++++++++++++++++++++++++++++
> >>>    1 file changed, 42 insertions(+)
> >>>
> >>> diff --git a/contrib/src/main-rust.mak b/contrib/src/main-rust.mak
> >>> index ca272e25e21..2a0654e4698 100644
> >>> --- a/contrib/src/main-rust.mak
> >>> +++ b/contrib/src/main-rust.mak
> >>> @@ -18,3 +18,45 @@ RUST_TARGET = x86_64-sun-solaris
> >>>    else ifdef HAVE_LINUX
> >>>    RUST_TARGET = $(ARCH)-unknown-linux-gnu
> >>>    endif
> >>> +
> >>> +CARGO_HOME = $(BUILDBINDIR)/.cargo
> >>> +
> >>> +CARGO = CARGO_HOME=$(CARGO_HOME) $(CARGO_HOME)/bin/cargo
> >>> +
> >>> +CARGO_INSTALL_ARGS = --target=$(RUST_TARGET) --prefix=$(PREFIX) \
> >>> +	--library-type staticlib --release
> >>> +
> >>> +# Use the .cargo-vendor source if present, otherwise use crates.io
> >>> +CARGO_INSTALL_ARGS += \
> >>> +	$(shell test -d $<-vendor && echo --frozen --offline || echo --locked)
> >>> +
> >>> +CARGO_INSTALL = $(CARGO) install $(CARGO_INSTALL_ARGS)
> >>> +
> >>> +CARGOC_INSTALL = $(CARGO) capi install $(CARGO_INSTALL_ARGS)
> >>> +
> >>> +download_vendor = \
> >>> +	$(call download,$(CONTRIB_VIDEOLAN)/$(1)) || (\
> >>> +               echo "" && \
> >>> +               echo "WARNING: cargo vendor archive for $(1) not found" && \
> >>> +               echo "" && \
> >>> +               touch $@);
> >>> +
> >>> +# Extract and move the vendor archive if the checksum is valid. Succeed even in
> >>> +# case of error (download or checksum failed). In that case, the cargo-vendor
> >>> +# archive won't be used (crates.io will be used directly).
> >>> +.%-vendor: $(SRC)/%-vendor/SHA512SUMS
> >>> +	$(RM) -R $(patsubst .%,%,$@)
> >>> +	$(call checksum,$(SHA512SUM),SHA512,.) \
> >>> +		$(foreach f,$(filter %.tar.bz2,$^), && tar xvjfo $(f) && \
> >>> +		  mv $(patsubst %.tar.bz2,%,$(notdir $(f))) $(patsubst .%,%,$@)) || true
> >>> +	touch $@
> >>
> >> It seems you are processing all the *-vendor files for every *-vendor
> >> file that is found in the big Makefile ? Or is there one big checksum
> >> file for all the vendor files ?
> >>
> >>> +
> >>> +CARGO_VENDOR_SETUP = \
> >>> +	if test -d $@-vendor; then \
> >>> +		mkdir -p $(UNPACK_DIR)/.cargo; \
> >>> +		echo "[source.crates-io]" > $(UNPACK_DIR)/.cargo/config.toml; \
> >>> +		echo "replace-with = \"vendored-sources\"" >> $(UNPACK_DIR)/.cargo/config.toml; \
> >>> +		echo "[source.vendored-sources]" >> $(UNPACK_DIR)/.cargo/config.toml; \
> >>> +		echo "directory = \"../$@-vendor\"" >> $(UNPACK_DIR)/.cargo/config.toml; \
> >>> +		echo "Using cargo vendor archive for $(UNPACK_DIR)"; \
> >>> +	fi;
> >>> -- 
> >>> 2.28.0
> >>>
> >>> _______________________________________________
> >>> vlc-devel mailing list
> >>> To unsubscribe or modify your subscription options:
> >>> https://mailman.videolan.org/listinfo/vlc-devel
> >>>
> >> _______________________________________________
> >> vlc-devel mailing list
> >> To unsubscribe or modify your subscription options:
> >> https://mailman.videolan.org/listinfo/vlc-devel
> > _______________________________________________
> > vlc-devel mailing list
> > To unsubscribe or modify your subscription options:
> > https://mailman.videolan.org/listinfo/vlc-devel
> > 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list