blob: 1f9dbd3ccea748d5d361b395f9f3b65917132ae7 [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
Andrew Geissler87f5cff2022-09-30 13:13:31 -050059EXTRA_TOOLS ?= "cargo-clippy clippy-driver rustfmt"
60EXTRA_TOOLS:remove:riscv32 = "rustfmt"
Patrick Williams92b42cb2022-09-03 06:53:57 -050061rust_do_install:class-target() {
62 export PSEUDO_UNLOAD=1
63 rust_runx install
64 unset PSEUDO_UNLOAD
65
66 install -d ${D}${bindir}
Andrew Geissler87f5cff2022-09-30 13:13:31 -050067 for i in ${EXTRA_TOOLS}; do
Patrick Williams92b42cb2022-09-03 06:53:57 -050068 cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir}
69 chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i
70 done
71
72 chown root:root ${D}/ -R
73 rm ${D}${libdir}/rustlib/uninstall.sh
74 rm ${D}${libdir}/rustlib/install.log
75 rm ${D}${libdir}/rustlib/manifest*
76}
77
78# see recipes-devtools/gcc/gcc/0018-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch
79# we need to link with ssp_nonshared on musl to avoid "undefined reference to `__stack_chk_fail_local'"
80# when building MACHINE=qemux86 for musl
81WRAPPER_TARGET_EXTRALD:libc-musl = "-lssp_nonshared"
82
83RUSTLIB_DEP:class-nativesdk = ""
84
85# musl builds include libunwind.a
86INSANE_SKIP:${PN} = "staticdev"
87