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