Commit graph

11 commits

Author SHA1 Message Date
Tobias Kortkamp
2bad8d171a
Uses/cargo: Rework git source support based on patch-in-config sections
Git sources from `Cargo.lock` are added to `CARGO_CRATES` through
the normal mechanism of `make cargo-crates` by the porter.  They
are used to populate `MASTER_SITES`, `DISTFILES` with static
git-archive(1) tarballs a la `USE_GITHUB`, `USE_GITLAB`.  In the
configure phase we generate `[patch]` sections in the config file
which will cause `cargo update` to auto-update `Cargo.lock` to point
to the appropriate extraction directories.

Normally `cargo update` would connect to the network to update all
Git sources but since rust-1.55.0 our cargo has been patched to
skip this when `CARGO_FREEBSD_PORTS_SKIP_GIT_UPDATE` is set in the
environment.

This replaces the old `CARGO_USE_GITHUB`, `CARGO_USE_GITLAB` hacks
where this was done by editing all `Cargo.toml` with sed(1) calls.

Additionally, we try to automatically infer the individiual crate
sub-directories inside the Git sources based on `package.name` in
`Cargo.toml` to remove the need for `CARGO_GIT_SUBDIR`.

USES=cargo also now sets `WRKSRC_crate_$name` for each crate to
point to the crate extraction directories.

PR:		256581
Reviewed by:	jbeich
2021-10-25 10:49:06 +02:00
Tobias Kortkamp
628c61939e
Scripts/split-url.awk: Pass result array as parameter 2021-09-08 21:05:19 +02:00
Tobias Kortkamp
d8fbaa503c
Scripts/cargo-crates.awk: Move split_url() to separate file
Also stop leaking local variables
2021-09-07 18:53:36 +02:00
Mathieu Arnold
5d33e04596
framework: Remove $FreeBSD$
Where appropriate fiddle with a few other things.
2021-04-06 16:27:10 +02:00
Tobias Kortkamp
bb415dbba6 Mk/Uses/cargo.mk: Support new Cargo.lock format
The new format [1,2] dropped the [metadata] table.  As a consequence
our cargo-crates.awk script no longer outputs CARGO_CRATES.  We can
get the crate list from the various [[package]] tables instead.
This should work with the new as well as the old format.

[1] https://github.com/rust-lang/cargo/pull/7070
[2] https://github.com/rust-lang/cargo/pull/7579

PR:		242416
Reported by:	jbeich
2019-12-05 06:42:22 +00:00
Tobias Kortkamp
ee15f75b1e Mk/Uses/cargo.mk: cargo-crates to flag unknown git hosts
To avoid some head scratching print a warning instead of being
silent when encountering unhandled git hosts.
2019-08-07 10:37:10 +00:00
Tobias Kortkamp
076bb3ef0b Mk/Uses/cargo.mk: Add support for CARGO_USE_GITLAB/GL_TUPLE to cargo-crates 2019-08-06 08:12:39 +00:00
Tobias Kortkamp
2cb86a796d Assign cargo-crates.awk to rust@ too same as USES=cargo 2019-08-06 06:44:48 +00:00
Tobias Kortkamp
f06ec8723e Mk/Uses/cargo.mk: Fix cargo-crates to not output identical GH_TUPLE entries
For example, in audio/spotifyd some crates have their sources on
GitHub instead of crates.io and share the same repository and commit
in Cargo.lock like

[[package]]
name = "librespot"
source = "git+https://github.com/librespot-org/librespot.git#4e3576ba7c6146cf68e1953daeec929d619b26b1"

[[package]]
name = "librespot-audio"
source = "git+https://github.com/librespot-org/librespot.git#4e3576ba7c6146cf68e1953daeec929d619b26b1"

Based on this cargo-crates.awk would naively generate multiple
identical entries like

librespot-org:librespot:4e3576ba7c6146cf68e1953daeec929d619b26b1:librespot
librespot-org:librespot:4e3576ba7c6146cf68e1953daeec929d619b26b1:librespotaudio

This adds a lot of extra noise to the port and distinfo and is not
really needed for anything.
2019-08-06 06:43:43 +00:00
Tobias Kortkamp
05b30a8d06 When specifying Git dependencies in Cargo.toml developers can set 3
additional keys: rev, branch, tag [1].  These are reflected in a
projects' Cargo.lock file as e.g.

git+https://github.com/servo/angle?branch=servo#a1371e8a160128677af863d1d73f150862ba42b2
git+https://github.com/rust-lang/libc?tag=0.2.26#288942e6858a4b2f8ee56338da5386263b9c4b82

Currently cargo-crates.awk generates the wrong output in these cases:

GH_TUPLE=	servo:angle?branch=servo:a1371e8a160128677af863d1d73f150862ba42b2:angle \
		rust-lang:libc?tag=0.2.26:288942e6858a4b2f8ee56338da5386263b9c4b82:libc

Fix cargo-crates.awk to ignore the query string (except in the tag
case) and generate

GH_TUPLE=	servo:angle:a1371e8a160128677af863d1d73f150862ba42b2:angle \
		rust-lang:libc:0.2.26:libc

instead.

[1] https://github.com/rust-lang/cargo/blob/master/src/doc/specifying-dependencies.md#specifying-dependencies-from-git-repositories

PR:		220548
Reported by:	jbeich
Reviewed by:	jbeich, mat
Differential Revision:	https://reviews.freebsd.org/D11571
2017-07-19 14:00:16 +00:00
Tobias Kortkamp
1db23587bd Add USES=cargo to make creating ports of Rust applications easier
Approved by:	mat (mentor)
Reviewed by:	dumbbell, mat
Differential Revision:	https://reviews.freebsd.org/D11162
2017-06-21 16:22:32 +00:00