forked from bottlerocket-os/bottlerocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcargo
44 lines (40 loc) · 1.86 KB
/
cargo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT
#
# Originally derived from https://github.com/amazonlinux/rust-bundled-packaging
# which is in turn derived from https://pagure.io/fedora-rust/rust2rpm
# Copyright (c) 2017 Igor Gnatenko
# Changes for Bottlerocket:
# - Remove _cargometadir, no automatic bundled() provides
# - Remove local registry generation
%__cargo %{_bindir}/cargo
%__cargo_common_opts --offline --locked --verbose
%__cargo_target %{_cross_triple}-gnu
%__cargo_target_static %{_cross_triple}-musl
%__cargo_cross_opts %{__cargo_common_opts} --target %{__cargo_target}
%__cargo_cross_opts_static %{__cargo_common_opts} --target %{__cargo_target_static}
%__cargo_env CARGO_TARGET_DIR="${HOME}/.cache" SKIP_README="true"
%__cargo_env_static CARGO_TARGET_DIR="${HOME}/.cache/.static" SKIP_README="true"
%__cargo_cross_pkg_config PKG_CONFIG_PATH="%{_cross_pkgconfigdir}" PKG_CONFIG_ALLOW_CROSS=1
%__cargo_cross_env %{__cargo_env} %{__cargo_cross_pkg_config} TARGET_CC="%{_cross_triple}-gnu-gcc"
%__cargo_cross_env_static %{__cargo_env_static} %{__cargo_cross_pkg_config} TARGET_CC="%{_cross_triple}-musl-gcc"
%cargo_prep (\
%{__mkdir} -p %{_builddir}/.cargo \
cat > %{_builddir}/.cargo/config << EOF \
[build]\
rustc = "%{__rustc}"\
rustdoc = "%{__rustdoc}"\
\
[target.%{_cross_triple}-gnu]\
linker = "%{_bindir}/%{_cross_triple}-gnu-gcc"\
ar = "%{_bindir}/%{_cross_triple}-gnu-gcc-ar"\
rustflags = %{__global_rustflags_shared_toml}\
\
[target.%{_cross_triple}-musl]\
linker = "%{_bindir}/%{_cross_triple}-musl-gcc"\
ar = "%{_bindir}/%{_cross_triple}-musl-gcc-ar"\
rustflags = %{__global_rustflags_static_toml}\
EOF\
)
%cargo_build %{__cargo_cross_env} %{__cargo} build %{__cargo_cross_opts} --release %{?cargo_args}
%cargo_build_static %{__cargo_cross_env_static} %{__cargo} build %{__cargo_cross_opts_static} --release %{?cargo_args}