Commit graph

38 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
3781ce3b33 Merge #179 Include linker flags for package note in %build_rustflags 2022-02-20 14:17:32 +00:00
e1f911661f Include linker flags for package note in %build_rustflags
%build_rustflags was used in %cargo_prep, which is executed in %prep,
when %buildsubdir is not set yet. To avoid this, insertion of flags is
moved to an environment variable that is set for %cargo_build and
%cargo_test.

The linker flag gets passed to rustc, and resulting binaries seem to have
note as expected.
2022-02-15 17:25:09 +01:00
c2a760efcd Add %crate_instdir convenience macro
Fixes #41.

The template is adjusted to use the new macro. This will only work
if the macro is defined, thus the required version of rust-packaging
is bumped.
2022-02-14 14:01:44 +01:00
Aleksei Bavshin
f1be3a0d4d
macros: pass CFLAGS/CXXFLAGS to the processes started by cargo
This is mainly targeted to the crates using `rust-cc`, where we want to
apply system-wide compiler flags when invoking the compiler. `cc`
supports CFLAGS and CXXFLAGS, but we never set those.
Defining that per project is not possible, as we have no way to inherit
any build context from a dependency package.

Possibly also affects: `bindgen`, `cxx`, any other crate that invokes
the C/C++ compiler and passes the CFLAGSS
2021-12-05 22:20:52 -08:00
1482f79e28 Drop __cargo_skip_build logic
It looks like this logic was only used for module builds, which is not
how Rust packages have been built for a few Fedora releases now.

Fixes #142.
2021-11-25 08:49:17 +00:00
Jan Staněk
035e458f0a
Parse features with + in their name
If a crate has a feature with `+` in it's name,
the `%__cargo_feature_from_name` macro fails to correctly parse it.
For example, the `cxxbridge-flags` crate declares (among others)
the `c++20` feature; that is currently parsed as follows:

```lua
> string.match("cxxbridge-flags+c++20-devel", "^.+%+(.+)-devel$")
20
```

The adjusted regex matches the *first* `+` as feature name separator:

```lua
> string.match("cxxbridge-flags+c++20-devel", "^[^+]+%+(.+)-devel$")
c++20
```
2021-02-01 13:56:37 +01:00
Thomas Jarosch
90d0e85da2
Fix up Cargo.toml.orig error message that started to appear with Rust 1.43.0
+ /usr/bin/env CARGO_HOME=.cargo RUSTC_BOOTSTRAP=1 /opt/rust/bin/cargo package -l
+ grep -w -v Cargo.lock
+ xargs -d '\n' /bin/cp --parents -a -t /user/rpmbuild/BUILDROOT/rust-term_size-0.3.0-1.i2n.x86_64/datastore/dev/rust/cargo/registry/term_size-0.3.0
warning: No (git) VCS found for `/datastore/rpmbuild/BUILD/term_size-0.3.0`
/bin/cp: cannot stat 'Cargo.toml.orig': No such file or directory

Signed-off-by: Igor Raits <ignatenkobrain@fedoraproject.org>
2020-05-02 19:12:54 +02:00
Josh Stone
b4581d8f5b Use cargo install --no-track with cargo 1.41
In cargo 1.41, `cargo install` adds a new `.crates2.json` file in the
install root for tracking version upgrades. This would be another file
that `%cargo_install` should remove afterward, but there is also a new
`--no-track` option which disables such metadata files altogether.

This update should be coordinated with the Rust toolchain update in the
distro, e.g. with rust-packaging `Requires: cargo >= 1.41`. The new
option will be rejected as an unstable option on earlier versions.
2020-01-30 22:02:59 -08:00
Igor Gnatenko
b5e2db003f
Ignore Cargo.lock
Fixes: https://pagure.io/fedora-rust/rust2rpm/issue/90

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2019-09-08 15:44:37 +02:00
Igor Gnatenko
4c891852b5
Implement %__cargo_skip_build
We need to have an easy way how to skip doing 'cargo build' to speedup a
module builds.

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2019-06-09 16:00:25 +02:00
Igor Gnatenko
c54d2409da
Remove temporary Cargo.toml.deps
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2019-04-28 07:47:06 +02:00
Igor Gnatenko
c57afa88aa
Add support for %generate_buildrequires
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2019-04-16 11:46:27 +02:00
Igor Gnatenko
5d7a0b2444
Do not pull optional dependencies
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2019-03-14 10:37:37 +01:00
Igor Gnatenko
7f0a499ff3
data: Escape \n properly
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2019-03-10 10:14:28 +01:00
Igor Gnatenko
84a73bfa24
data: Cargo doesn't escape paths with space
When building matrixmultiply v0.2.2:

BUILDSTDERR: /usr/bin/cp: cannot stat 'spare': No such file or directory
BUILDSTDERR: /usr/bin/cp: failed to get attributes of 'kernels': No such file or directory

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2019-02-17 17:19:25 +01:00
Josh Stone
a04e95bc4f Set the install root in .cargo/config 2018-12-07 13:59:03 -08:00
Josh Stone
b4e2503829 Set CARGO_HOME to the local .config 2018-12-07 13:58:41 -08:00
Igor Gnatenko
2cac5e5ad5
split features into subpackages
References: https://discussion.fedoraproject.org/t/rfc-new-crates-packaging-design-features-have-their-own-subpackages/563?u=ignatenkobrain
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-11-03 21:45:04 +01:00
Igor Gnatenko
80237720ae
macros: remove support for target-dir
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-06-22 21:53:09 +02:00
Igor Gnatenko
c9ce952e26
macros: make %cargo_* macros parametric
Unfortunately cargo-install doesn't accept --target-dir, so have to pass
setting through envvar.

Also %{shrink:…} them so it looks nicer in build log.

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-06-22 21:05:42 +02:00
Igor Gnatenko
c5bab762f5 macros: pass %__cargo_common_opts to %cargo_install
Reason this has not been done before is that cargo-install doesn't
understand --release. Let's just add it to other commands and be done
with it.

Reported-by: Josh Stone <jistone@redhat.com>
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-02-20 22:08:02 +01:00
Igor Gnatenko
cd63296353 macros: remove spurious whitespace
Fixes: https://pagure.io/fedora-rust/rust2rpm/issue/48
Reported-by: Josh Stone <jistone@redhat.com>
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-01-09 06:52:36 +01:00
Igor Gnatenko
5313b35271 macros: remove Cargo.lock
cargo-package automatically strips it out, but we package also some
things directly from git.

Acked-by: Josh Stone <jistone@redhat.com>
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-01-09 00:00:04 +01:00
Igor Gnatenko
09a434b55a make 'rlib' first-class citizen
Fixes: https://pagure.io/fedora-rust/rust2rpm/issue/47
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-01-08 19:09:54 +01:00
Igor Gnatenko
4b31b3e594 macros: search for whole string
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-01-08 19:09:10 +01:00
Igor Gnatenko
47b6c3ef80 macros.crago: pass --no-fail-fast
It is quite useful to see all failing tests instead of few of first.

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
Reviewed-by: Josh Stone <jistone@redhat.com>
2017-12-05 13:03:41 +01:00
Igor Gnatenko
59809d4940 use cp instead of install
We want to preserve original modes and so on.

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-11-04 15:32:39 +01:00
Martin Sehnoutka
2c556e1473 macros: explicitly set rustdoc
On systems where rustup is used, simple rpmbuild will use rustc from system,
but rustdoc will be taken from PATH which might be different from system.
Given this, doc-tests or anything related to rustdoc will fail with mis-mathching
rustc version.

Merges: https://pagure.io/fedora-rust/rust2rpm/pull-request/38
2017-06-23 13:41:42 +02:00
Igor Gnatenko
cce3d7bc92 macros: switch to /usr/share/cargo/registry
We should not be using /usr/src because that one is supposed to be used for
"Source code may be placed in this subdirectory, only for reference purposes".

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-06-20 23:10:28 +02:00
Igor Gnatenko
a254693cde Revert "macros: move Cargo.toml.orig inplace"
Somehow this doesn't really work. No time for investigation.

This reverts commit fc12436f25.
2017-02-25 21:51:08 +01:00
Igor Gnatenko
86d06ae613 macros: strip all dev-dependencies sections
Even [dev-dependencies.foo].

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-25 21:45:24 +01:00
Igor Gnatenko
fc12436f25 macros: move Cargo.toml.orig inplace
cargo package -l lists Cargo.toml.orig and we're installing it anyway,
so let's just do mv -f instead of doing new install.

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-25 19:21:40 +01:00
Igor Gnatenko
e834debc6a add support for proc-macro kind
Closes: https://pagure.io/fedora-rust/rust2rpm/issue/19
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-18 19:53:08 +01:00
Igor Gnatenko
d4334a2ee7 macros: automatically strip dev-dependencies
All background written in upstream cargo GitHub issue[0].

In short, cargo build/install enforces us to have all dev-dependencies
even they are not used for building/installed.

[0] https://github.com/rust-lang/cargo/issues/3732

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-18 16:10:50 +01:00
Igor Gnatenko
ee68fab15b macros: don't define %cargo_build/test as functions
There are only problems from this.

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-18 02:25:21 +01:00
Igor Gnatenko
2fbb50e1dc distribute rust2rpm in PyPI via setuptools
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-12 11:35:45 +01:00
Igor Gnatenko
c12df7d085 %cargo_install is now smart to handle libs and bins
So far we had %cargo_install (for binaries) and %cargo_install_crate
(for libraries) which is a bit awkward and requires us to put
additional arguments for latter one.

We can do all the magic behind the scene.

Closes: https://pagure.io/fedora-rust/rust2rpm/issue/7
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-10 22:17:45 +01:00
Igor Gnatenko
74beb9388f move RPM stuff into subdirectory
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-02-05 18:15:28 +01:00
Renamed from macros.cargo (Browse further)