forked from msys2/MINGW-packages
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathPKGBUILD
183 lines (155 loc) · 7.33 KB
/
PKGBUILD
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# Maintainer: Alexey Pavlov <[email protected]>
# Contributor: Zion Nimchuk <[email protected]>
# Contributor: Mateusz Mikuła <[email protected]
_realname=rust
_bootstrapping=yes
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}"
"${MINGW_PACKAGE_PREFIX}-rust-docs")
pkgver=1.60.0
pkgrel=1
pkgdesc="Systems programming language focused on safety, speed and concurrency (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://www.rust-lang.org/"
license=('MIT' 'Apache')
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake"
"${MINGW_PACKAGE_PREFIX}-curl"
"${MINGW_PACKAGE_PREFIX}-libffi"
"${MINGW_PACKAGE_PREFIX}-libssh2"
"${MINGW_PACKAGE_PREFIX}-lldb"
"${MINGW_PACKAGE_PREFIX}-llvm"
"${MINGW_PACKAGE_PREFIX}-ninja"
"${MINGW_PACKAGE_PREFIX}-openssl"
"${MINGW_PACKAGE_PREFIX}-python"
"${MINGW_PACKAGE_PREFIX}-autotools"
$([[ "$_bootstrapping" == "no" ]] && echo "${MINGW_PACKAGE_PREFIX}-rust")
"${MINGW_PACKAGE_PREFIX}-zlib"
"git")
options=('staticlibs' 'strip')
#install=rust.install
noextract=(${_realname}c-${pkgver}-src.tar.gz)
source=("https://static.rust-lang.org/dist/${_realname}c-${pkgver}-src.tar.gz"{,.asc}
"0001-add-missing-libs.patch"
"0004-unbundle-gcc.patch"
"0005-win32-config.patch"
"0007-clang-subsystem.patch"
"0008-disable-self-contained.patch")
sha256sums=('20ca826d1cf674daf8e22c4f8c4b9743af07973211c839b85839742314c838b7'
'SKIP'
'8c9c37f2ff3bee7d9ac520c66d3f37fd7f002012ddca4ddeeab2b009f520e4ce'
'6cc3234644768e24824e455d6304585c717ae25aa53ebf9cf1f1dea87bf869b7'
'c4e5ffeef84296d39c3e3e8f807fc8b33ce786b1e4edb21eef26b053586aca27'
'c79d91a7419e8b0da76295c3d64aa5e984851c7e03b778f6230a660a010c9a66'
'29f84cb8e05ce304e102e28912a3b4464add406a8ec37a6c6d717b9b7d81b67b')
validpgpkeys=('108F66205EAEB0AAA8DD5E1C85AB96E6FA1BE5FE' # Rust Language (Tag and Release Signing Key) <[email protected]>
'474E22316ABF4785A88C6E8EA2C794A986419D8A' # Tom Stellard <[email protected]>
'B6C8F98282B944E3B0D5C2530FC3042E345AD05D') # Hans Wennborg <[email protected]>
prepare() {
[[ -d ${srcdir}/${_realname}c-${pkgver}-src ]] && rm -rf ${srcdir}/${_realname}c-${pkgver}-src
tar -xzf ${srcdir}/${_realname}c-${pkgver}-src.tar.gz -C ${srcdir} || true
cd ${srcdir}/${_realname}c-${pkgver}-src
patch -p1 -i "${srcdir}/0001-add-missing-libs.patch"
patch -p1 -i "${srcdir}/0004-unbundle-gcc.patch"
patch -p1 -i "${srcdir}/0005-win32-config.patch"
patch -p1 -i "${srcdir}/0008-disable-self-contained.patch"
if [[ $MINGW_PACKAGE_PREFIX == *-clang-* ]]; then
patch -p1 -i "${srcdir}/0007-clang-subsystem.patch"
fi
}
build() {
[[ -d "${srcdir}/${MSYSTEM}" ]] && rm -rf "${srcdir}/${MSYSTEM}"
mkdir -p "${srcdir}/${MSYSTEM}" && cd "${srcdir}/${MSYSTEM}"
# The ultimate hack to let the bootstrap compiler use libgcc* libs
if [[ $MINGW_PACKAGE_PREFIX == *-clang-* ]]; then
export GCC_LIBS_HACK="$(cygpath -am build/missing-libs-hack)"
mkdir -p "${GCC_LIBS_HACK}"
cp "$(cygpath -u $(clang -print-libgcc-file-name))" "${GCC_LIBS_HACK}/libgcc.a"
cp "${MINGW_PREFIX}/lib/libunwind.a" "${GCC_LIBS_HACK}/libgcc_eh.a"
cp "${MINGW_PREFIX}/lib/libunwind.dll.a" "${GCC_LIBS_HACK}/libgcc_s.a"
export RUSTFLAGS_BOOTSTRAP="-C link-arg=-L$(cygpath -am build/missing-libs-hack)"
fi
# We have to do the following because rust doesn't count x86_64-w64-mingw32 as a target triple
OSTYPE="$CARCH-pc-windows-gnu"
# Otherwise it uses gcc during bootstrap, even when we build for clang
export CARGO_TARGET_${CARCH^^}_PC_WINDOWS_GNU_LINKER="${CC}"
local -a _rust_conf=()
if [ "${_bootstrapping}" = "no" ]; then
_rust_conf+=("--local-rust-root=$(cygpath -m ${MINGW_PREFIX})")
fi
# For a faster build:
# - add --disable-docs and --disable-compiler-docs
# - compile only rustc by removing --enable-extended
# - run makepkg-mingw with --nocheck
MSYS2_ARG_CONV_EXCL="--prefix;--sysconfdir;--localstatedir" \
../${_realname}c-${pkgver}-src/configure \
--prefix=${MINGW_PREFIX} \
--sysconfdir=${MINGW_PREFIX}/etc \
--localstatedir=${MINGW_PREFIX}/var/lib \
--build=$OSTYPE \
--host=$OSTYPE \
--target=$OSTYPE \
--release-channel=stable \
--enable-ninja \
--enable-extended \
--disable-codegen-tests \
--llvm-root=${MINGW_PREFIX} \
--python=${MINGW_PREFIX}/bin/python \
${_rust_conf}
DEP_NGHTTP_ROOT=${MINGW_PREFIX} \
DEP_OPENSSL_ROOT=${MINGW_PREFIX} \
DEP_Z_ROOT=${MINGW_PREFIX} \
${MINGW_PREFIX}/bin/python ../${_realname}c-${pkgver}-src/x.py build --verbose --stage 2
# create the install at a temporary directory
DEP_NGHTTP_ROOT=${MINGW_PREFIX} \
DEP_OPENSSL_ROOT=${MINGW_PREFIX} \
DEP_Z_ROOT=${MINGW_PREFIX} \
DESTDIR="$PWD"/dest-rust ${MINGW_PREFIX}/bin/python ../${_realname}c-${pkgver}-src/x.py install --stage 2 --verbose
# move docs out of the way for splitting
mv dest-rust/${MINGW_PREFIX}/share/doc dest-doc
rm -f dest-rust/${MINGW_PREFIX}/bin/libgcc*.dll
rm -f dest-rust/${MINGW_PREFIX}/bin/libstd*.dll
rm -f dest-rust/${MINGW_PREFIX}/bin/libwinpthread*.dll
rm -f dest-rust/${MINGW_PREFIX}/lib/rustlib/$OSTYPE/lib/self-contained/*
}
check() {
cd "${srcdir}/${MSYSTEM}"
DEP_NGHTTP_ROOT=${MINGW_PREFIX} \
DEP_OPENSSL_ROOT=${MINGW_PREFIX} \
DEP_Z_ROOT=${MINGW_PREFIX} \
${MINGW_PREFIX}/bin/python ../${_realname}c-${pkgver}-src/x.py test --stage 2 --exclude src/test/debuginfo
}
package_rust() {
depends=("${MINGW_PACKAGE_PREFIX}-cc"
"${MINGW_PACKAGE_PREFIX}-curl"
"${MINGW_PACKAGE_PREFIX}-libxml2"
"${MINGW_PACKAGE_PREFIX}-libssh2")
cd "${srcdir}/${MSYSTEM}"
cp -a dest-rust/* "$pkgdir"
install -Dm644 ${srcdir}/${_realname}c-${pkgver}-src/LICENSE-APACHE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE-APACHE"
install -Dm644 ${srcdir}/${_realname}c-${pkgver}-src/LICENSE-MIT "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE-MIT"
# delete unnecessary files, e.g. components and manifest files only used for the uninstall script
cd "$pkgdir"/${MINGW_PREFIX}/lib/rustlib
rm components install.log manifest-* rust-installer-version uninstall.sh
install -d "$pkgdir/${MINGW_PREFIX}/share/bash-completion/completions"
mv "${pkgdir}${MINGW_PREFIX}/etc/bash_completion.d/cargo" \
"${pkgdir}${MINGW_PREFIX}/share/bash-completion/completions/cargo"
}
package_rust-docs() {
pkgdesc='Documentation for the Rust programming language'
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}<1.52.0")
cd "${srcdir}/${MSYSTEM}"
install -Dm644 ${srcdir}/${_realname}c-${pkgver}-src/LICENSE-APACHE "${pkgdir}${MINGW_PREFIX}/share/licenses/$pkgname/LICENSE-APACHE"
install -Dm644 ${srcdir}/${_realname}c-${pkgver}-src/LICENSE-MIT "${pkgdir}${MINGW_PREFIX}/share/licenses/$pkgname/LICENSE-MIT"
install -d "$pkgdir"/${MINGW_PREFIX}/share/
cp -a dest-doc "$pkgdir"/${MINGW_PREFIX}/share/doc
}
# template start; name=mingw-w64-splitpkg-wrappers; version=1.0;
# vim: set ft=bash :
# generate wrappers
for _name in "${pkgname[@]}"; do
_short="package_${_name#${MINGW_PACKAGE_PREFIX}-}"
_func="$(declare -f "${_short}")"
eval "${_func/#${_short}/package_${_name}}"
done
# template end;