1 # Created by: Jyun-Yan You <jyyou@cs.nctu.edu.tw>
7 MASTER_SITES= http://static.rust-lang.org/dist/:src \
8 https://static.rust-lang.org/dist/:rust_bootstrap \
9 LOCAL/dumbbell/rust:rust_bootstrap \
10 https://static.rust-lang.org/dist/:cargo_bootstrap \
11 https://s3.amazonaws.com/rust-lang-ci/cargo-builds/:cargo_bootstrap \
12 LOCAL/dumbbell/rust:cargo_bootstrap \
13 LOCAL/marino:bootstrap
14 DISTNAME?= ${PORTNAME}c-${PORTVERSION}-src
15 BOOTSTRAP_FILES=${RUSTC_BOOTSTRAP}:rust_bootstrap \
16 ${RUST_STD_BOOTSTRAP}:rust_bootstrap \
17 ${CARGO_BOOTSTRAP}:cargo_bootstrap
18 DISTFILES?= ${DISTNAME}${EXTRACT_SUFX}:src \
20 .if !defined(SKIP_CARGO_REGISTRY)
21 MASTER_SITES+= LOCAL/riggs/rust:registry \
22 LOCAL/dumbbell/rust:registry
23 DISTFILES+= ${CARGO_REGISTRY}:registry
26 EXTRACT_ONLY?= ${DISTFILES:N*\:*bootstrap:C/:.*//}
28 MAINTAINER?= rust@FreeBSD.org
29 COMMENT= Language with a focus on memory safety and concurrency
34 # APACHE20 license is standard, see Templates/Licenses/APACHE20
35 LICENSE_FILE_MIT= ${WRKSRC}/LICENSE-MIT
37 BUILD_DEPENDS= cmake:devel/cmake
39 ONLY_FOR_ARCHS?= aarch64 amd64 i386
40 ONLY_FOR_ARCHS_REASON= requires prebuilt bootstrap compiler
42 # FIXME: The bootstrapped rustc adds -L/usr/local/lib in front of
43 # the LDFLAGS. When stage0's rustc is linked, it picks the installed
44 # librust*so and fails.
45 CONFLICTS_BUILD?= rust-nightly
46 CONFLICTS_BUILD+= ${PKGBASE}
47 CONFLICTS_INSTALL?= rust-nightly
49 RUST_BOOTSTRAP_DIR?= 2017-04-27
50 RUST_BOOTSTRAP_DIR_aarch64?= 2017-04-24
51 RUST_BOOTSTRAP_VERSION?= 1.17.0
52 RUST_BOOTSTRAP_VERSION_aarch64?=1.17.0
53 RUSTC_BOOTSTRAP= ${RUST_BOOTSTRAP_DIR_${ARCH}:U${RUST_BOOTSTRAP_DIR}}/rustc-${RUST_BOOTSTRAP_VERSION_${ARCH}:U${RUST_BOOTSTRAP_VERSION}}-${RUST_TARGET}.tar.gz
54 RUST_STD_BOOTSTRAP= ${RUST_BOOTSTRAP_DIR_${ARCH}:U${RUST_BOOTSTRAP_DIR}}/rust-std-${RUST_BOOTSTRAP_VERSION_${ARCH}:U${RUST_BOOTSTRAP_VERSION}}-${RUST_TARGET}.tar.gz
56 CARGO_BOOTSTRAP_DIR?= ${RUST_BOOTSTRAP_DIR}
57 CARGO_BOOTSTRAP_DIR_aarch64?= ${RUST_BOOTSTRAP_DIR_aarch64}
58 CARGO_BOOTSTRAP_VERSION?= 0.18.0
59 CARGO_BOOTSTRAP_VERSION_aarch64?=0.18.0
60 CARGO_BOOTSTRAP= ${CARGO_BOOTSTRAP_DIR_${ARCH}:U${CARGO_BOOTSTRAP_DIR}}/cargo-${CARGO_BOOTSTRAP_VERSION_${ARCH}:U${CARGO_BOOTSTRAP_VERSION}}-${RUST_TARGET}${EXTRACT_SUFX}
61 CARGO_REGISTRY= ${PORTNAME}-registry-${DISTVERSIONFULL}.tar.xz
63 RUST_CHANNEL= ${PKGNAMESUFFIX:Ustable:S/^-//}
65 # Rust's target arch string is different from *BSD arch strings
66 RUST_ARCH_aarch64= aarch64
67 RUST_ARCH_amd64= x86_64
69 RUST_ARCH_x86_64= x86_64 # dragonfly
70 RUST_TARGET= ${RUST_ARCH_${ARCH}}-unknown-${OPSYS:tl}
71 PLIST_SUB+= RUST_TARGET=${RUST_TARGET}
73 USES= compiler gmake libedit python:2.7,build
75 CONFIGURE_ARGS= --disable-valgrind \
76 ${CHOSEN_COMPILER_TYPE:Mclang:C/.+/--enable-&/} \
78 --musl-root=${PREFIX} \
79 --local-rust-root=${PREFIX} \
80 --mandir=${MANPREFIX}/man \
81 --release-channel=${RUST_CHANNEL} \
82 --python="${PYTHON_CMD}"
86 OPTIONS_DEFINE= DOCS GDB LLNEXTGEN PORT_LLVM
87 GDB_DESC= Install ports gdb (necessary for debugging rust programs)
88 LLNEXTGEN_DESC= Build with grammar verification
90 DOCS_CONFIGURE_ENABLE= docs
91 GDB_RUN_DEPENDS= ${LOCALBASE}/bin/gdb:devel/gdb
92 LLNEXTGEN_BUILD_DEPENDS= LLnextgen:devel/llnextgen
94 # Rust may pass more regression tests with bundled LLVM
95 PORT_LLVM_DESC= Build against devel/llvm${LLVM_VER} instead of bundled version
96 PORT_LLVM_BUILD_DEPENDS= ${LLVM_PREFIX}/bin/FileCheck:devel/llvm${LLVM_VER}
97 PORT_LLVM_CONFIGURE_ON= --llvm-root=${LLVM_PREFIX}
99 LLVM_PREFIX= ${LOCALBASE}/llvm${LLVM_VER}
101 # Note that make test does not work when rust is already installed
103 TEST_ENV+= ALLOW_NONZERO_RLIMIT_CORE=1
105 # Rust manifests list all files and directories installed by rust-installer.
107 # - pre-install to cleanup the ${STAGEDIR}
108 # - post-install to populate the ${TMPPLIST}
109 RUST_MANIFESTS= lib/rustlib/manifest-rustc \
110 lib/rustlib/manifest-rust-std-${RUST_TARGET}
111 RUST_DOCS_MANIFESTS= lib/rustlib/manifest-rust-docs
112 DOCS_VARS= rust_manifests+=${RUST_DOCS_MANIFESTS}
114 PLIST_FILES= lib/rustlib/components \
115 lib/rustlib/rust-installer-version
117 .include <bsd.port.pre.mk>
118 .if ${OPSYS} == FreeBSD && ${OSVERSION} >= 1200031
119 EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-ino64
123 # FIXME: This is the same check for CONFLICTS as the standard
124 # one, except port origins are not compared. This allows
125 # the port to conflict with itself, because Rust would pick
126 # installed Rust libraries instead of freshly built ones.
127 @conflicts_with=$$( \
128 { ${PKG_QUERY} -g "%n-%v %p %o" ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_BUILD:C/.+/'&'/} 2>/dev/null || : ; } \
129 | while read pkgname prfx orgn; do \
130 if [ "/${PREFIX}" = "/$${prfx}" ]; then \
131 ${ECHO_CMD} -n " $${pkgname}"; \
134 if [ -n "$${conflicts_with}" ]; then \
136 ${ECHO_MSG} "===> ${PKGNAME} conflicts with installed package(s): "; \
137 for entry in $${conflicts_with}; do \
138 ${ECHO_MSG} " $${entry}"; \
141 ${ECHO_MSG} " They will not build together."; \
142 ${ECHO_MSG} " Please remove them first with pkg delete."; \
146 RUST_STD_DIR= ${RUST_STD_BOOTSTRAP:T:R:R}
147 LIBSTD_SUFFIX= f4594d3e53dcb114
148 LIBSTD_SUFFIX_aarch64= b41e0ffe8c1bd541
149 LIBSTD= ${RUST_STD_DIR}/rust-std-${RUST_TARGET}/lib/rustlib/${RUST_TARGET}/lib/libstd-${LIBSTD_SUFFIX_${ARCH}:U${LIBSTD_SUFFIX}}.rlib
150 STDF= ${LIBSTD:T:R:S/lib//}.0.o
154 ${WRKSRC}/build/cache/${RUST_BOOTSTRAP_DIR_${ARCH}:U${RUST_BOOTSTRAP_DIR}} \
155 ${WRKSRC}/build/cache/${CARGO_BOOTSTRAP_DIR_${ARCH}:U${CARGO_BOOTSTRAP_DIR}}
156 ${LN} -sf ${DISTDIR}/${DIST_SUBDIR}/${RUSTC_BOOTSTRAP} \
157 ${WRKSRC}/build/cache/${RUST_BOOTSTRAP_DIR_${ARCH}:U${RUST_BOOTSTRAP_DIR}}
158 .if ${OPSYS} != FreeBSD || ${OSVERSION} < 1200031
159 ${LN} -sf ${DISTDIR}/${DIST_SUBDIR}/${RUST_STD_BOOTSTRAP} \
160 ${WRKSRC}/build/cache/${RUST_BOOTSTRAP_DIR_${ARCH}:U${RUST_BOOTSTRAP_DIR}}
162 ${LN} -sf ${DISTDIR}/${DIST_SUBDIR}/${CARGO_BOOTSTRAP} \
163 ${WRKSRC}/build/cache/${CARGO_BOOTSTRAP_DIR_${ARCH}:U${CARGO_BOOTSTRAP_DIR}}
164 .if ${OPSYS} == FreeBSD && ${OSVERSION} >= 1200031
165 ${TAR} -x -C ${WRKSRC} -f ${DISTDIR}/${DIST_SUBDIR}/${RUST_STD_BOOTSTRAP}
166 ${CC} ${CFLAGS} -fPIC -c -o ${WRKSRC}/old_fstat.o ${FILESDIR}/old_fstat.c
167 (cd ${WRKSRC} && ${AR} x ${WRKSRC}/${LIBSTD} ${STDF})
168 ${LD} -r -o ${WRKSRC}/std.xx.o ${WRKSRC}/${STDF} ${WRKSRC}/old_fstat.o
169 ${MV} ${WRKSRC}/std.xx.o ${WRKSRC}/${STDF}
170 (cd ${WRKSRC} && ${AR} r ${WRKSRC}/${LIBSTD} ${STDF})
171 ${TAR} -cy --format=ustar -C ${WRKSRC} -f ${WRKSRC}/rustc.tbz ${RUST_STD_DIR}
172 ${MV} ${WRKSRC}/rustc.tbz ${WRKSRC}/build/cache/${RUST_STD_BOOTSTRAP}
176 @test ! -f ${WRKSRC}/mk/main.mk || \
177 ${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|' \
179 @${REINPLACE_CMD} -e 's|gdb|${LOCALBASE}/bin/gdb|' \
180 ${WRKSRC}/src/etc/rust-gdb
181 @if test "${RUST_BOOTSTRAP_DIR_${ARCH}}" -o "${RUST_BOOTSTRAP_VERSION_${ARCH}}"; then \
182 ${REINPLACE_CMD} -e \
183 's|^rustc:.*|rustc: ${RUST_BOOTSTRAP_VERSION_${ARCH}:U${RUST_BOOTSTRAP_VERSION}}-${RUST_BOOTSTRAP_DIR_${ARCH}:U${RUST_BOOTSTRAP_DIR}}|' \
184 ${WRKSRC}/src/stage0.txt; \
186 @if test "${CARGO_BOOTSTRAP_DIR_${ARCH}}"; then \
187 ${REINPLACE_CMD} -e \
188 's|^cargo:.*|cargo: ${RUST_BOOTSTRAP_DIR_${ARCH}:U${RUST_BOOTSTRAP_DIR}}|' \
189 ${WRKSRC}/src/stage0.txt; \
191 @if test "${CARGO_BOOTSTRAP_VERSION_${ARCH}}"; then \
192 ${REINPLACE_CMD} -e \
193 's|cargo-nightly-|cargo-${CARGO_BOOTSTRAP_VERSION_${ARCH}:U${CARGO_BOOTSTRAP_VERSION}}-|' \
194 ${WRKSRC}/src/bootstrap/bootstrap.py; \
197 # In case the previous "make stage" failed, this ensures rust's
198 # install.sh won't backup previously staged files before reinstalling
199 # new ones. Otherwise, the staging directory is polluted with unneeded
202 @for f in ${RUST_MANIFESTS} ${RUST_DOCS_MANIFESTS}; do \
203 if test -f "${STAGEDIR}${PREFIX}/$$f"; then \
204 ${SED} -E -e 's,^(file|dir):,${STAGEDIR},' \
205 < "${STAGEDIR}${PREFIX}/$$f" \
206 | ${XARGS} ${RM} -r; \
207 ${RM} "${STAGEDIR}${PREFIX}/$$f"; \
210 @for f in ${PLIST_FILES}; do \
211 ${RM} "${STAGEDIR}${PREFIX}/$$f"; \
214 # In post-install, we use the manifests generated during Rust install
215 # to in turn generate the PLIST. We do that, instead of the regular
216 # `pkg-plist`, because several libraries have a computed filename based
217 # on the absolute path of the source files. As it is user-specific, we
218 # can't know their filename in advance.
220 # We fix manpage entries in the generated manifests because Rust
221 # installs them uncompressed but the Ports framework compresses them.
223 for f in ${RUST_MANIFESTS}; do \
224 ${REINPLACE_CMD} -E \
225 -e 's|:${STAGEDIR}|:|' \
226 -e 's|(man/man[1-9]/.*\.[0-9])|\1.gz|' \
227 ${STAGEDIR}${PREFIX}/$$f; \
228 ${RM} ${STAGEDIR}${PREFIX}/$$f.bak; \
229 ${ECHO} "${PREFIX}/$$f" >> ${TMPPLIST}; \
233 sub(/^file:/, "", file); \
238 sub(/^dir:/, "", dir); \
239 system("find ${STAGEDIR}" dir " -type f | ${SED} -E -e \"s|${STAGEDIR}||\""); \
241 ${STAGEDIR}${PREFIX}/$$f >> ${TMPPLIST}; \
244 ${STAGEDIR}${PREFIX}/lib/rustlib/install.log \
245 ${STAGEDIR}${PREFIX}/lib/rustlib/uninstall.sh
246 # FIXME: Static libraries in lib/rustlib/*/lib/*.rlib are not stripped,
247 # but they contain non-object files which make strip(1) unhappy.
249 ${STAGEDIR}${PREFIX}/bin/rustc \
250 ${STAGEDIR}${PREFIX}/bin/rustdoc \
251 ${STAGEDIR}${PREFIX}/lib/*.so \
252 ${STAGEDIR}${PREFIX}/lib/rustlib/*/lib/*.so
254 .include <bsd.port.post.mk>
256 # "make gen-registry" is a special target to ease this port update.
258 # After changing the version number and the Git revision, you can run
259 # "make gen-registry" to update the distinfo and create a new snapshot of
260 # the registry. The new registry is written to ${DISTDIR} and can be
264 ${MAKE} -C${.CURDIR} -DSKIP_CARGO_REGISTRY makesum
265 ${MAKE} -C${.CURDIR} -DSKIP_CARGO_REGISTRY
266 ${TAR} cJvf ${DISTDIR}/${DIST_SUBDIR}/${CARGO_REGISTRY} -C${WRKDIR} \
268 --exclude 'src/*/benches/' \
269 --exclude 'src/*/ci/' \
270 --exclude 'src/*/examples/' \
271 --exclude 'src/*/tests/' \
272 --exclude 'index/github.com-*/.git/' \
274 ${MAKE} -C${.CURDIR} makesum