blob: 401d51041ee2829f18fd845297d0308dda00d92d [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001require rust-target.inc
2require rust-source.inc
3require rust-snapshot.inc
4
5INSANE_SKIP:${PN}:class-native = "already-stripped"
6FILES:${PN} += "${libdir}/rustlib"
7FILES:${PN} += "${libdir}/*.so"
8FILES:${PN}-dev = ""
9
10# Used by crossbeam_atomic.patch
11export TARGET_VENDOR
12
13do_compile () {
14 rust_runx build --stage 2
15}
16
17do_compile:append:class-target () {
18 rust_runx build --stage 2 src/tools/clippy
19 rust_runx build --stage 2 src/tools/rustfmt
20}
21
22do_compile:append:class-nativesdk () {
23 rust_runx build --stage 2 src/tools/clippy
24 rust_runx build --stage 2 src/tools/rustfmt
25}
26
27ALLOW_EMPTY:${PN} = "1"
28
29PACKAGES =+ "${PN}-tools-clippy ${PN}-tools-rustfmt"
30FILES:${PN}-tools-clippy = "${bindir}/cargo-clippy ${bindir}/clippy-driver"
31FILES:${PN}-tools-rustfmt = "${bindir}/rustfmt"
32RDEPENDS:${PN}-tools-clippy = "${PN}"
33RDEPENDS:${PN}-tools-rustfmt = "${PN}"
34
35SUMMARY:${PN}-tools-clippy = "A collection of lints to catch common mistakes and improve your Rust code"
36SUMMARY:${PN}-tools-rustfmt = "A tool for formatting Rust code according to style guidelines"
37
38rust_do_install() {
39 rust_runx install
40}
41
42rust_do_install:class-nativesdk() {
43 export PSEUDO_UNLOAD=1
44 rust_runx install
45 unset PSEUDO_UNLOAD
46
47 install -d ${D}${bindir}
48 for i in cargo-clippy clippy-driver rustfmt; do
49 cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir}
50 chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i
51 done
52
53 chown root:root ${D}/ -R
54 rm ${D}${libdir}/rustlib/uninstall.sh
55 rm ${D}${libdir}/rustlib/install.log
56 rm ${D}${libdir}/rustlib/manifest*
57}
58
59rust_do_install:class-target() {
60 export PSEUDO_UNLOAD=1
61 rust_runx install
62 unset PSEUDO_UNLOAD
63
64 install -d ${D}${bindir}
65 for i in cargo-clippy clippy-driver rustfmt; do
66 cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir}
67 chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i
68 done
69
70 chown root:root ${D}/ -R
71 rm ${D}${libdir}/rustlib/uninstall.sh
72 rm ${D}${libdir}/rustlib/install.log
73 rm ${D}${libdir}/rustlib/manifest*
74}
75
76# see recipes-devtools/gcc/gcc/0018-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch
77# we need to link with ssp_nonshared on musl to avoid "undefined reference to `__stack_chk_fail_local'"
78# when building MACHINE=qemux86 for musl
79WRAPPER_TARGET_EXTRALD:libc-musl = "-lssp_nonshared"
80
81RUSTLIB_DEP:class-nativesdk = ""
82
83# musl builds include libunwind.a
84INSANE_SKIP:${PN} = "staticdev"
85