1 | # -*- coding: utf-8; mode: _tcl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- vim:fenc=utf-8:ft=portfile:et:sw=2:ts=2:sts=2 |
---|
2 | |
---|
3 | PortSystem 1.0 |
---|
4 | PortGroup muniversal 1.0 |
---|
5 | PortGroup active_variants 1.1 |
---|
6 | |
---|
7 | name rust |
---|
8 | version 1.26.2 |
---|
9 | categories lang devel |
---|
10 | platforms darwin |
---|
11 | supported_archs i386 x86_64 |
---|
12 | license {MIT Apache-2} BSD zlib NCSA Permissive |
---|
13 | maintainers {g5pw @g5pw} openmaintainer |
---|
14 | |
---|
15 | description A safe, concurrent, practical language |
---|
16 | |
---|
17 | long_description Rust is a curly-brace, block-structured expression \ |
---|
18 | language. It visually resembles the C language \ |
---|
19 | family, but differs significantly in syntactic and \ |
---|
20 | semantic details. Its design is oriented toward \ |
---|
21 | concerns of \"programming in the large\", that is, of \ |
---|
22 | creating and maintaining boundaries -- both abstract \ |
---|
23 | and operational -- that preserve large-system \ |
---|
24 | integrity, availability and concurrency. |
---|
25 | |
---|
26 | homepage https://www.rust-lang.org/ |
---|
27 | |
---|
28 | set ruststd_version 1.25.0 |
---|
29 | set rustc_version 1.25.0 |
---|
30 | set cargo_version 0.26.0 |
---|
31 | set llvm_version 6.0 |
---|
32 | |
---|
33 | # can use cmake or cmake-devel; default to cmake. |
---|
34 | depends_build path:bin/cmake:cmake \ |
---|
35 | bin:python2.7:python27 |
---|
36 | |
---|
37 | depends_lib port:llvm-${llvm_version} |
---|
38 | |
---|
39 | master_sites https://static.rust-lang.org/dist |
---|
40 | |
---|
41 | distname ${name}c-${version}-src |
---|
42 | |
---|
43 | patchfiles patch-src-librustc-llvm-lib.diff |
---|
44 | |
---|
45 | if {![variant_isset universal]} { |
---|
46 | if {${build_arch} eq "i386"} { |
---|
47 | set architectures i686 |
---|
48 | } else { |
---|
49 | set architectures ${build_arch} |
---|
50 | } |
---|
51 | } else { |
---|
52 | set architectures {} |
---|
53 | foreach arch ${universal_archs} { |
---|
54 | if {${arch} eq "i386"} { |
---|
55 | lappend architectures i686 |
---|
56 | } else { |
---|
57 | lappend architectures ${arch} |
---|
58 | } |
---|
59 | } |
---|
60 | } |
---|
61 | |
---|
62 | foreach arch ${architectures} { |
---|
63 | distfiles-append rust-std-${ruststd_version}-${arch}-apple-${os.platform}${extract.suffix} \ |
---|
64 | rustc-${rustc_version}-${arch}-apple-${os.platform}${extract.suffix} \ |
---|
65 | cargo-${cargo_version}-${arch}-apple-${os.platform}${extract.suffix} |
---|
66 | } |
---|
67 | |
---|
68 | checksums ${distname}${extract.suffix} \ |
---|
69 | rmd160 a99aecdcb80e35985598991f3fe37ab5fcdb8b98 \ |
---|
70 | sha256 fb9ecf304488c9b56600ab20cfd1937482057f7e5db7899fddb86e0774548700 \ |
---|
71 | size 95312651 |
---|
72 | |
---|
73 | checksums-append \ |
---|
74 | rust-std-${ruststd_version}-i686-apple-${os.platform}${extract.suffix} \ |
---|
75 | rmd160 9e6a5e8f4c34ad24c2bd16c045d7090efffb37e9 \ |
---|
76 | sha256 ef58976acd7d97f3d7d2832553a9b63e29bed6ccb68783e90c8a3de98b1ab6be \ |
---|
77 | size 48237324 \ |
---|
78 | rustc-${rustc_version}-i686-apple-${os.platform}${extract.suffix} \ |
---|
79 | rmd160 a6646bf8ad40ec8a79c196d26c06fd58dd3bb8d1 \ |
---|
80 | sha256 287d2b73d909791faa93e172835bfcdfd6faa3e8b1688dd2f393ffff289eb978 \ |
---|
81 | size 61033359 \ |
---|
82 | cargo-${cargo_version}-i686-apple-${os.platform}${extract.suffix} \ |
---|
83 | rmd160 cab4400acf6b2df6b9f2efdcba858deb0b92923c \ |
---|
84 | sha256 4126e65d47cc80c6ddf1d1f525bb312388d23918f62fc73ed85a3754e3ef3529 \ |
---|
85 | size 3619348 |
---|
86 | |
---|
87 | checksums-append \ |
---|
88 | rust-std-${ruststd_version}-x86_64-apple-${os.platform}${extract.suffix} \ |
---|
89 | rmd160 7bbdc0a38598f90db874ffad298e2b05ceb0af6c \ |
---|
90 | sha256 cfaae3e7a1fed1345fef8702380b0090af7d7821b705da3117d9e28ee13310cf \ |
---|
91 | size 49382071 \ |
---|
92 | rustc-${rustc_version}-x86_64-apple-${os.platform}${extract.suffix} \ |
---|
93 | rmd160 86b82b93b46f38fc166a5c73558f7d53ae4e4179 \ |
---|
94 | sha256 ff8b144aeb4407bb9c405291f96fdce2a7a57fd7e712f8560418239e762a3595 \ |
---|
95 | size 62274937 \ |
---|
96 | cargo-${cargo_version}-x86_64-apple-${os.platform}${extract.suffix} \ |
---|
97 | rmd160 ab89d35abe25d66f00b3490d6e40cd47c2c8b6cb \ |
---|
98 | sha256 cab6adf58e9dea7ac217b1882312eff3487005cf32dcde099327669aac6e37de \ |
---|
99 | size 3941366 |
---|
100 | |
---|
101 | pre-fetch { |
---|
102 | if {${os.platform} eq "darwin" && ${os.major} < 11} { |
---|
103 | ui_error "${name} is only supported on OS X 10.7 Lion or later." |
---|
104 | return -code error "unsupported platform version" |
---|
105 | } |
---|
106 | } |
---|
107 | |
---|
108 | post-extract { |
---|
109 | foreach arch ${architectures} { |
---|
110 | set rust_root ${worksrcpath}/build/stage0-${arch} |
---|
111 | set rust_platform ${arch}-apple-${os.platform} |
---|
112 | file mkdir ${rust_root} |
---|
113 | system "cp -r ${workpath}/rust-std-${ruststd_version}-${rust_platform}/rust-std-${rust_platform}/* ${rust_root}" |
---|
114 | system "cp -r ${workpath}/rustc-${rustc_version}-${rust_platform}/rustc/* ${rust_root}" |
---|
115 | system "cp -r ${workpath}/cargo-${cargo_version}-${rust_platform}/cargo/* ${rust_root}" |
---|
116 | } |
---|
117 | } |
---|
118 | |
---|
119 | configure.args --enable-vendor \ |
---|
120 | --default-linker=${configure.cc} \ |
---|
121 | --disable-codegen-tests \ |
---|
122 | --disable-docs \ |
---|
123 | --release-channel=stable |
---|
124 | |
---|
125 | # see https://trac.macports.org/ticket/56351 |
---|
126 | # see https://github.com/rust-lang/rust/issues/50220 |
---|
127 | if {[variant_isset universal]} { |
---|
128 | # LLVM is or will need to be universal |
---|
129 | set copy_llvm 1 |
---|
130 | } else { |
---|
131 | if {![catch {set result [active_variants llvm-${llvm_version} "universal" ""]}] && $result} { |
---|
132 | # LLVM was installed with universal variant |
---|
133 | set copy_llvm 1 |
---|
134 | } else { |
---|
135 | set copy_llvm 0 |
---|
136 | } |
---|
137 | } |
---|
138 | |
---|
139 | if {!${copy_llvm}} { |
---|
140 | # LLVM is NOT universal, so use installed version |
---|
141 | configure.args-append \ |
---|
142 | --llvm-root=${prefix}/libexec/llvm-${llvm_version} |
---|
143 | } else { |
---|
144 | # copy LLVM and thin static libraries |
---|
145 | # see https://trac.macports.org/ticket/56351 |
---|
146 | # see https://github.com/rust-lang/rust/issues/50220 |
---|
147 | if {[variant_isset universal]} { |
---|
148 | set archs ${universal_archs} |
---|
149 | foreach arch ${universal_archs} { |
---|
150 | lappend merger_configure_args(${arch}) \ |
---|
151 | --llvm-root=${workpath}/llvm-${llvm_version}-${arch} |
---|
152 | } |
---|
153 | } else { |
---|
154 | set archs ${build_arch} |
---|
155 | configure.args-append \ |
---|
156 | --llvm-root=${workpath}/llvm-${llvm_version}-${build_arch} |
---|
157 | } |
---|
158 | |
---|
159 | depends_extract-append port:llvm-${llvm_version} |
---|
160 | |
---|
161 | post-extract { |
---|
162 | foreach arch ${archs} { |
---|
163 | system -W ${workpath} "cp -R ${prefix}/libexec/llvm-${llvm_version} ${workpath}/llvm-${llvm_version}-${arch}" |
---|
164 | fs-traverse f ${workpath}/llvm-${llvm_version}-${arch} { |
---|
165 | if {[file isfile $f] && [file type $f]!="link" && [file extension $f]==".a"} { |
---|
166 | catch {system "lipo -thin ${arch} ${f} -o ${f}"} |
---|
167 | } |
---|
168 | } |
---|
169 | } |
---|
170 | } |
---|
171 | } |
---|
172 | |
---|
173 | if {![variant_isset universal]} { |
---|
174 | if {${build_arch} eq "i386"} { |
---|
175 | set arch_name i686 |
---|
176 | } else { |
---|
177 | set arch_name ${build_arch} |
---|
178 | } |
---|
179 | set rust_platform ${arch_name}-apple-${os.platform} |
---|
180 | set rust_root ${worksrcpath}/build/stage0-${arch_name} |
---|
181 | configure.args-append \ |
---|
182 | --build=${rust_platform} \ |
---|
183 | --local-rust-root=${rust_root} |
---|
184 | } else { |
---|
185 | foreach arch ${universal_archs} { |
---|
186 | if {${arch} eq "i386"} { |
---|
187 | set arch_name i686 |
---|
188 | } else { |
---|
189 | set arch_name ${build_arch} |
---|
190 | } |
---|
191 | set rust_platform ${arch_name}-apple-${os.platform} |
---|
192 | set rust_root ${worksrcpath}/build/stage0-${arch_name} |
---|
193 | lappend merger_configure_args(${arch}) \ |
---|
194 | --build=${rust_platform} \ |
---|
195 | --local-rust-root=${rust_root} |
---|
196 | } |
---|
197 | } |
---|
198 | |
---|
199 | foreach arch ${architectures} { |
---|
200 | set rust_platform ${arch}-apple-${os.platform} |
---|
201 | configure.args-append \ |
---|
202 | --set=target.${rust_platform}.cc=${configure.cc} \ |
---|
203 | --set=target.${rust_platform}.cxx=${configure.cxx} \ |
---|
204 | --set=target.${rust_platform}.linker=${configure.cc} |
---|
205 | } |
---|
206 | |
---|
207 | configure.universal_args-delete --disable-dependency-tracking |
---|
208 | |
---|
209 | post-configure { |
---|
210 | # the bootstrap call to rustc uses cc for the linker |
---|
211 | # place config file in the HOME directory |
---|
212 | # see https://trac.macports.org/wiki/UsingTheRightCompiler |
---|
213 | xinstall -d -m 0755 ${workpath}/.home/.cargo |
---|
214 | set config [open ${workpath}/.home/.cargo/config w] |
---|
215 | foreach arch ${architectures} { |
---|
216 | set rust_platform ${arch}-apple-${os.platform} |
---|
217 | puts ${config} "\[target.${rust_platform}\]" |
---|
218 | puts ${config} "linker = \"${configure.cc}\"" |
---|
219 | } |
---|
220 | close ${config} |
---|
221 | } |
---|
222 | |
---|
223 | build.env RUSTC_SAVE_ANALYSIS=api |
---|
224 | build.args VERBOSE=1 BOOTSTRAP_ARGS="-v -j${build.jobs}" |
---|
225 | |
---|
226 | test.run yes |
---|
227 | test.target check |
---|
228 | test.args VERBOSE=1 |
---|
229 | |
---|
230 | destroot.args VERBOSE=1 |
---|
231 | if {${subport} eq ${name}} { |
---|
232 | if {![variant_isset universal]} { |
---|
233 | post-destroot { |
---|
234 | if {${build_arch} eq "i386"} { |
---|
235 | set arch_name i686 |
---|
236 | } else { |
---|
237 | set arch_name ${build_arch} |
---|
238 | } |
---|
239 | set rust_platform ${arch_name}-apple-${os.platform} |
---|
240 | file copy \ |
---|
241 | ${worksrcpath}/build/${rust_platform}/stage1-std/${rust_platform}/release/deps/save-analysis \ |
---|
242 | ${destroot}${prefix}/lib/rustlib/${rust_platform}/analysis |
---|
243 | |
---|
244 | xinstall -d ${destroot}${prefix}/share/${name} |
---|
245 | xinstall -m 644 ${worksrcpath}/src/etc/ctags.rust \ |
---|
246 | ${destroot}${prefix}/share/${name} |
---|
247 | } |
---|
248 | } else { |
---|
249 | merger-post-destroot { |
---|
250 | foreach arch ${universal_archs} { |
---|
251 | if {${arch} eq "i386"} { |
---|
252 | set arch_name i686 |
---|
253 | } else { |
---|
254 | set arch_name ${arch} |
---|
255 | } |
---|
256 | set rust_platform ${arch_name}-apple-${os.platform} |
---|
257 | file copy \ |
---|
258 | ${worksrcpath}-${arch}/build/${rust_platform}/stage1-std/${rust_platform}/release/deps/save-analysis \ |
---|
259 | ${destroot}-${arch}${prefix}/lib/rustlib/${rust_platform}/analysis |
---|
260 | |
---|
261 | xinstall -d ${destroot}-${arch}${prefix}/share/${name} |
---|
262 | xinstall -m 644 ${worksrcpath}-${arch}/src/etc/ctags.rust \ |
---|
263 | ${destroot}-${arch}${prefix}/share/${name} |
---|
264 | } |
---|
265 | } |
---|
266 | } |
---|
267 | } |
---|
268 | |
---|
269 | livecheck.type regex |
---|
270 | livecheck.url https://github.com/rust-lang/rust/tags |
---|
271 | livecheck.regex archive/(\[\\d\\.\]+).zip |
---|
272 | |
---|
273 | subport rust-src { |
---|
274 | # remove dependencies |
---|
275 | depends_build |
---|
276 | depends_lib |
---|
277 | |
---|
278 | description Source code for the rust programming language |
---|
279 | long_description ${description} |
---|
280 | |
---|
281 | use_configure no |
---|
282 | |
---|
283 | build {} |
---|
284 | |
---|
285 | destroot { |
---|
286 | xinstall -d ${destroot}${prefix}/share/rust |
---|
287 | move ${worksrcpath}/src ${destroot}${prefix}/share/rust/src |
---|
288 | |
---|
289 | # correct the permissions |
---|
290 | system -W ${destroot}${prefix}/share/rust "find . -type d -exec chmod 755 {} \\;" |
---|
291 | system -W ${destroot}${prefix}/share/rust "find . -type f -exec chmod 644 {} \\;" |
---|
292 | |
---|
293 | # delete the test directories (which for some god awful reason contains binaries) |
---|
294 | system -W ${destroot}${prefix}/share/rust "find . -type d -name test -print0 | xargs -0 rm -rf" |
---|
295 | } |
---|
296 | } |
---|