diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 0000000..8c139e5 --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,203 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2016 the meta-rust-bin authors + + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..121c96b --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,23 @@ +MIT License + +Copyright (c) 2016 the meta-rust-bin authors + + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..019f373 --- /dev/null +++ b/README.md @@ -0,0 +1,129 @@ +meta-rust-bin +============= + +An OpenEmebdded/Yocto layer providing pre-built toolchains for the +[Rust programming language](https://www.rust-lang.org). + + + +- [Basic Example](#basic-example) +- [Features](#features) +- [Advanced Features](#advanced-features) + * [Specifying Cargo Features](#specifying-cargo-features) + * [Using Components Individually](#using-components-individually) +- [Pre-built vs. Compiled](#pre-built-vs-compiled) +- [Copyright](#copyright) + + + + +## Basic Example + +A basic class for cargo-based executables is provided. The following is a +simple recipe that builds the [gpio-utils](https://github.com/rust-embedded/gpio-utils) +crate from a branch tagged with the version `${PV}`: + +```bitbake +inherit cargo + +SUMMARY = "GPIO Utilities" +HOMEPAGE = "git://github.com/rust-embedded/gpio-utils" +LICENSE = "MIT" + +SRC_URI = "https://github.com/rust-embedded/gpio-utils.git;tag=${PV}" +S = "${WORKDIR}/git" + +LIC_FILES_CHKSUM = "file://LICENSE-MIT;md5=935a9b2a57ae70704d8125b9c0e39059" +``` + +As you can see, there is almost no overhead introduced from the `cargo` class +beyond simply inheriting it. The `cargo` class adds the appropriate Rust +dependencies as well as default compile and install steps. + + +## Features + +Currently supported: + + * Rust 1.11 + * x86 (32 and 64-bit), ARM (32 and 64-bit) build systems. + * All Linux architectures that Rust itself supports (Multiple flavors of: + x86, ARM, PPC, and MIPS) + * Statically-linked libstd, dynamically-linked system libraries (libc, libm, + etc) + +Future: + + * [ ] Building and installing `dev` and `staticdev` packages (i.e. allow build + and install of static and dynamic library builds). + * [ ] Debug builds with separated debug info to allow gdbserver usage. + * [ ] Running Rust/Cargo on target. + * [ ] Vendoring of Cargo dependencies (to better play with the Yocto offline + build model). + * [ ] Use of a shared libstd across all Rust packages on a target system + (provides space savings). + * [ ] Total static linking using MUSL. + + + +## Advanced Features + +### Specifying Cargo Features + +Because Yocto is primarily used for embedded development, it is likely that +projects will have differing features based on whether the crate is run on the +hardware or in development on a PC. Cargo features can be easily specified by +adding a space-separated list of `CARGO_FEATURES` to the recipe: + +```bitbake +CARGO_FEATURES = "feature1 feature2" +``` + +### Using Components Individually + +Although the `cargo` class is the easiest way to use this layer, the components +it provides may also be used directly. To add the Rust compiler plus target and +host standard libraries to the environment, depend on or install `rust-bin`. To +manually install `cargo` depend on or install `cargo-bin`. + +Note that while there is nothing explicitly preventing the installation of Rust +on the target, it hasn't been tested and is likely not to work. Pull requests +are welcome! + + +## Pre-built vs. Compiled + +This layer exists as a tradeoff against other options, e.g. the +[meta-rust](https://github.com/meta-rust) project. Both exist to satisfy +different requirements. + +Because this layer uses the upstream compiled versions of Rust and Cargo, it +will never be able to support architectures or options not supported by the +Rust team itself. + +Also, because this layer uses pre-built Rust standard libraries, it is possible +that the standard libraries provided with this layer will be less efficient +than code produced by a custom-compiled standard library. + +However, using pre-built tools has advantages: + + * Updating the layer to a new version of Rust is as easy as updating + checksums and file names, so new versions of Rust are available quickly. + * In almost all modern systems, it is faster to download the binaries than it + is to download source and build the Rust toolchain from scratch. + * Compatability across multiple versions of Yocto is maximized since only + basic, stable recipe features are used. + * Trivial support for all architectures supported by upstream Rust. + + +## Copyright + +``` +Copyright (c) 2016, the meta-rust-bin authors. + +Licensed under the Apache License, Version 2.0 or the MIT license +, at your +option. This file may not be copied, modified, or distributed +except according to those terms. +``` diff --git a/classes/cargo.bbclass b/classes/cargo.bbclass new file mode 100644 index 0000000..46f4cfd --- /dev/null +++ b/classes/cargo.bbclass @@ -0,0 +1,112 @@ +inherit rust-common + +# Move CARGO_HOME from default of ~/.cargo +export CARGO_HOME = "${WORKDIR}/cargo_home" + +# If something fails while building, this might give useful information +export RUST_BACKTRACE = "1" + +DEPENDS += "\ + rust-bin \ + cargo-bin-native \ +" + +# Do build out-of-tree +B = "${WORKDIR}/target" +export CARGO_TARGET_DIR = "${B}" + +# When cross-compiling, explicitly set target. When natively compiling target +# the BUILD system. +RUST_TARGET = "${@rust_target(d, 'TARGET')}" +RUST_TARGET_class-native = "${@rust_target(d, 'BUILD')}" + +# Additional flags passed directly to the "cargo build" invocation +EXTRA_CARGO_FLAGS ??= "" + +# Space-separated list of features to enable +CARGO_FEATURES ??= "" + +CARGO_DEBUG_DIR = "${B}/${RUST_TARGET}/debug" +CARGO_RELEASE_DIR = "${B}/${RUST_TARGET}/release" +WRAPPER_DIR = "${WORKDIR}/wrappers" + +CARGO_BUILD_FLAGS = "\ + --verbose \ + --manifest-path ${S}/Cargo.toml \ + --target=${RUST_TARGET} \ + --${@build_type(d)} \ + ${@base_conditional('CARGO_FEATURES', '', '', '--features "${CARGO_FEATURES}"', d)} \ + ${EXTRA_CARGO_FLAGS} \ +" + +create_cargo_config() { + cat >${CARGO_HOME}/config << EOF +[target.${RUST_TARGET}] +linker = "${WRAPPER_DIR}/cc-wrapper.sh" + +[build] +rustflags = ["-C", "rpath"] +EOF +} + +cargo_do_configure() { + mkdir -p "${B}" + mkdir -p "${CARGO_HOME}" + mkdir -p "${WRAPPER_DIR}" + + # Yocto provides the C compiler in ${CC} but that includes options beyond + # the compiler binary. cargo/rustc expect a single binary, so we put ${CC} + # in a wrapper script. + echo "#!/bin/sh" >"${WRAPPER_DIR}/cc-wrapper.sh" + echo "${CC} \$@" >>"${WRAPPER_DIR}/cc-wrapper.sh" + chmod +x "${WRAPPER_DIR}/cc-wrapper.sh" + + # Create our global config in CARGO_HOME + create_cargo_config +} + +def build_type(d): + is_debug_build = d.getVar("PN", True).endswith("-dbg") + if is_debug_build: + return "debug" + else: + return "release" + +cargo_do_compile() { + export CC="${WRAPPER_DIR}/cc-wrapper.sh" + bbnote "which rustc:" `which rustc` + bbnote "rustc --version" `rustc --version` + bbnote "which cargo:" `which cargo` + bbnote "cargo --version" `cargo --version` + bbnote cargo build ${CARGO_BUILD_FLAGS} + cargo build ${CARGO_BUILD_FLAGS} +} + +cargo_do_install() { + install -d "${D}${bindir}" + if [ "${@build_type}" = "debug" ]; then + local cargo_bindir="${CARGO_DEBUG_DIR}" + else + local cargo_bindir="${CARGO_RELEASE_DIR}" + fi + + local files_installed="" + for f in "$cargo_bindir"/*; do + if [ -f "$f" ] && [ -x "$f" ]; then + install -m 0755 "$f" "${D}${bindir}" + files_installed="$files_installed $f" + fi + done + + if [ -z "$files_installed" ]; then + bbfatal "Cargo found no files to install" + else + bbnote "Installed the following files:" + for f in $files_installed; do + bbnote " " `basename $f` + done + fi +} + +BBCLASSEXTEND += "native nativesdk" +EXPORT_FUNCTIONS do_configure do_compile do_install diff --git a/classes/rust-common.bbclass b/classes/rust-common.bbclass new file mode 100644 index 0000000..b7ce05f --- /dev/null +++ b/classes/rust-common.bbclass @@ -0,0 +1,61 @@ +def rust_target(d, spec_type): + ''' + Convert BitBake system specs into Rust target. + `spec_type` is one of BUILD, TARGET, or HOST + ''' + spec_type = spec_type.upper() + + arch = d.getVar('%s_ARCH' % spec_type, True) + os = d.getVar('%s_OS' % spec_type, True) + + # Sometimes bitbake mixes the calling convention into the OS, sometimes it + # doesn't... let's just take the first part + os = os.split('-')[0] + + # The bitbake vendor won't ever match the Rust specs + vendor = "unknown" + + # Only GNU calling convention supported for now, but MUSL is a distinct + # future possibility. + callconvention = "gnu" + + # TUNE_FEATURES are always only for the TARGET + if spec_type == "TARGET": + tune = d.getVar("TUNE_FEATURES", True).split() + else: + tune = [] + + if not os == 'linux': + bb.fatal("Unsupported OS: %s. Only Linux is supported." % os) + + if arch in ["i386", "i486", "i686", "i786", "x86"]: + arch = "i686" + elif arch in ["x86_64", "x86-64", "x64", "amd64"]: + arch = "x86_64" + elif arch in ["xscale", "arm", "armv6l", "armv7l"]: + # Rust requires NEON/VFP in order to build for armv7, else fall back to v6 + if all(x in tune for x in ["armv7a", "neon", "callconvention-hard"]): + arch = "armv7" + callconvention = "gnueabihf" + else: + arch = "arm" + if "callconvention-hard" in tune: + callconvention = "gnueabihf" + else: + callconvention = "gnueabi" + elif arch in ["aarch64"]: + arch = "aarch64" + elif arch in ["ppc"]: + arch = "powerpc" + elif arch in ["ppc64"]: + arch = "powerpc64" + elif arch in ["ppc64le"]: + arch = "powerpc64le" + else: + bb.fatal("Unknown architecture: %s" % arch) + + target = "%s-%s-%s-%s" % (arch, vendor, os, callconvention) + + return target + +RUST_BASE_URI := "https://static.rust-lang.org" diff --git a/conf/layer.conf b/conf/layer.conf new file mode 100644 index 0000000..998a604 --- /dev/null +++ b/conf/layer.conf @@ -0,0 +1,11 @@ +# We have a conf and classes directory, append to BBPATH +BBPATH .= ":${LAYERDIR}" + +# We have a recipes directory, add to BBFILES +BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend" + +BBFILE_COLLECTIONS += "rust-bin-layer" +BBFILE_PATTERN_rust-bin-layer := "^${LAYERDIR}/" +BBFILE_PRIORITY_rust-bin-layer = "7" + +LICENSE_PATH += "${LAYERDIR}/files/common-licenses" diff --git a/recipes-devtools/rust/cargo-bin.inc b/recipes-devtools/rust/cargo-bin.inc new file mode 100644 index 0000000..08b5319 --- /dev/null +++ b/recipes-devtools/rust/cargo-bin.inc @@ -0,0 +1,31 @@ +DESCRIPTION = "Cargo build tool for Rust (pre-compiled binary version)" +HOMEPAGE = "https://rust-lang.org" +LICENSE = "Apache-2.0 | MIT" +SECTION = "devel" + +inherit rust-common + +CARGO_HOST_TARGET = "${@rust_target(d, 'HOST')}" + +S = "${WORKDIR}/cargo-nightly-${CARGO_HOST_TARGET}" + +do_install() { + ${S}/install.sh --destdir="${D}" --prefix="${prefix}" + rm -f ${D}${prefix}/lib/rustlib/uninstall.sh + rm -f ${D}${prefix}/lib/rustlib/install.log + rm -f ${D}${prefix}/lib/rustlib/components + rm -f ${D}${prefix}/lib/rustlib/rust-installer-version +} + +python () { + base_uri = d.getVar("RUST_BASE_URI", True) + pv = d.getVar("PV", True) + pv_uri = pv[0:4] + '-' + pv[4:6] + '-' + pv[6:8] + target = d.getVar("CARGO_HOST_TARGET", True) + cargo_uri = ("%s/cargo-dist/%s/cargo-nightly-%s.tar.gz;md5sum=%s;sha256sum=%s" % + (base_uri, pv_uri, target, cargo_md5(target), cargo_sha256(target))) + src_uri = d.getVar("SRC_URI", True).split() + d.setVar("SRC_URI", ' '.join(src_uri + [cargo_uri])) +} + +BBCLASSEXTEND += "native nativesdk" diff --git a/recipes-devtools/rust/cargo-bin_20160705.bb b/recipes-devtools/rust/cargo-bin_20160705.bb new file mode 100644 index 0000000..ab37000 --- /dev/null +++ b/recipes-devtools/rust/cargo-bin_20160705.bb @@ -0,0 +1,36 @@ +def get_hash(hashes, triple): + try: + return hashes[triple] + except: + bb.fatal("Unsupported triple: %s" % triple) + +def cargo_md5(triple): + HASHES = { + "aarch64-unknown-linux-gnu": "21e17ddb5bf706df5662338a9d675695", + "arm-unknown-linux-gnueabi": "99c51d4886934d4a5cc307f4ec4b3ce8", + "arm-unknown-linux-gnueabihf": "307c208afe0a470eed48d05125c62e48", + "armv7-unknown-linux-gnueabihf": "0e4735148dcaeca5a9ff98a2769f0f77", + "i686-unknown-linux-gnu": "a1f1e479289894639d6b9c58809560c8", + "x86_64-unknown-linux-gnu": "8481e37267273bea60cf012d59156c80", + } + return get_hash(HASHES, triple) + +def cargo_sha256(triple): + HASHES = { + "aarch64-unknown-linux-gnu": "1bdf1f446199b164b8e4234fede68fb82d4528adce9757ad69fa6ace67859d94", + "arm-unknown-linux-gnueabi": "d2debabfe50ded1598e9b61a0b1e262c44e6b6f6e14a994d46ee445c77466618", + "arm-unknown-linux-gnueabihf": "c2ced46ebc017d163aa8f47999c6ff8883169d8f5496ca6b03cbcd68eb10fdd9", + "armv7-unknown-linux-gnueabihf": "eba6649f0b6b38e44ff8d6b7df741d79828cfe78b3cdb8fe035579cc42b5e36a", + "i686-unknown-linux-gnu": "f640d0dc0badeea87e2bab26b629e0acad5ebf1e7d8b6adef16febb72cab3da4", + "x86_64-unknown-linux-gnu": "cf47787fd50bf6c7f68db290eab054e493e4619d42a8faf66565431449055f1c", + } + return get_hash(HASHES, triple) + + +DEPENDS += "rust-bin (= 1.11.0)" +LIC_FILES_CHKSUM = "\ + file://LICENSE-APACHE;md5=1836efb2eb779966696f473ee8540542 \ + file://LICENSE-MIT;md5=362255802eb5aa87810d12ddf3cfedb4 \ +" + +include cargo-bin.inc diff --git a/recipes-devtools/rust/rust-bin.inc b/recipes-devtools/rust/rust-bin.inc new file mode 100644 index 0000000..943ec58 --- /dev/null +++ b/recipes-devtools/rust/rust-bin.inc @@ -0,0 +1,57 @@ +DESCRIPTION = "Rust compiler and standard libraries (pre-compiled binary version)" +HOMEPAGE = "https://rust-lang.org" +LICENSE = "Apache-2.0 | MIT" +SECTION = "devel" + +inherit cross +inherit rust-common + +# Native compiler is installed as a bonus with the cross compiler. +PROVIDES += "rust-bin-native" + +# Extra architectures to install standard library for. Must match one of the +# standard rust targets. The standard library for the default host and target +# will be installed automatically. +EXTRA_RUST_TARGETS ?= "" + +RUST_BUILD_TARGET = "${@rust_target(d, 'BUILD')}" +RUST_TARGET_TARGET = "${@rust_target(d, 'TARGET')}" +RUST_ALL_TARGETS = "${RUST_BUILD_TARGET} ${RUST_TARGET_TARGET} ${EXTRA_RUST_TARGETS}" + +S = "${WORKDIR}/rustc-${PV}-${RUST_BUILD_TARGET}" + +do_install() { + # Install rustc + ${S}/install.sh --destdir="${D}" --prefix="${prefix}" + + # Install rust standard libraries + cd ${WORKDIR}/rust-std + for subdir in *; do + $subdir/install.sh --destdir="${D}" --prefix="${prefix}" + done + + # Remove components that will conflict with other installables + rm -f ${D}${prefix}/lib/rustlib/uninstall.sh + rm -f ${D}${prefix}/lib/rustlib/install.log + rm -f ${D}${prefix}/lib/rustlib/components + rm -f ${D}${prefix}/lib/rustlib/rust-installer-version +} + +python () { + pv = d.getVar("PV", True) + base_uri = d.getVar("RUST_BASE_URI", True) + targets = d.getVar("RUST_ALL_TARGETS", True).split() + build_target = d.getVar("RUST_BUILD_TARGET", True) + rustc_src_uri = ("%s/dist/rustc-%s-%s.tar.gz;md5sum=%s;sha256sum=%s" % + (base_uri, pv, build_target, rustc_md5(build_target), rustc_sha256(build_target))) + std_src_uris = ["%s/dist/rust-std-${PV}-%s.tar.gz;md5sum=%s;sha256sum=%s;subdir=rust-std" % + (base_uri, target, rust_std_md5(target), rust_std_sha256(target)) for target in targets] + src_uri = d.getVar("SRC_URI", True).split() + d.setVar("SRC_URI", ' '.join(src_uri + [rustc_src_uri] + std_src_uris)) +} + +SYSROOT_PREPROCESS_FUNCS = "rust_process_sysroot" +rust_process_sysroot() { + sysroot_stage_dir ${D}${prefix}/bin ${SYSROOT_DESTDIR}${prefix}/bin + sysroot_stage_dir ${D}${prefix}/lib ${SYSROOT_DESTDIR}${prefix}/lib +} diff --git a/recipes-devtools/rust/rust-bin_1.11.0.bb b/recipes-devtools/rust/rust-bin_1.11.0.bb new file mode 100644 index 0000000..b25d1be --- /dev/null +++ b/recipes-devtools/rust/rust-bin_1.11.0.bb @@ -0,0 +1,64 @@ +def get_hash(hashes, triple): + try: + return hashes[triple] + except: + bb.fatal("Unsupported triple: %s" % triple) + +def rust_std_md5(triple): + HASHES = { + "aarch64-unknown-linux-gnu": "9e86de3b4138eecd37e378e6ad45b9c9", + "arm-unknown-linux-gnueabi": "1b46b6d0aa606b61536b15f71345e10e", + "arm-unknown-linux-gnueabihf": "00bd0d4347808e5ddaeec235a2c16f42", + "armv7-unknown-linux-gnueabihf": "919a3ffcf08937325171a049992ec2c4", + "i686-unknown-linux-gnu": "9ba1f6934d5f09937c9ebaf68261ff10", + "mips-unknown-linux-gnu": "b90ae32b2681b07301d011ce17067376", + "mipsel-unknown-linux-gnu": "d68a0b100c1d7e84397b92fcdd5a0c08", + "powerpc-unknown-linux-gnu": "fabcfe72cba56da32696f08fea3cde4b", + "powerpc64-unknown-linux-gnu": "14ce3a15f88250896c452058aa483dae", + "powerpc64le-unknown-linux-gnu": "ef8ef16204bd8229f93ddb2dd6e2c1b4", + "x86_64-unknown-linux-gnu": "04497872d0ed1eb7efa8fefcfce71ab4", + } + return get_hash(HASHES, triple) + +def rust_std_sha256(triple): + HASHES = { + "aarch64-unknown-linux-gnu": "5bc07fe375913dee02dc4dba1d2388e6f35166f24ba69b0568d560f335689f31", + "arm-unknown-linux-gnueabi": "07ba1d4b75beba6f388441adddb12eba6480eba6c723d8703ba5dd8fa68443b5", + "arm-unknown-linux-gnueabihf": "7e9b5bf8488676c454b92a3af7853555792dda4e474988adbd1fab89cc981e5d", + "armv7-unknown-linux-gnueabihf": "eb1ebee507f8e2e63728558de8a8c8ec830dfd76359704a93eb2785ab4500c55", + "i686-unknown-linux-gnu": "eb131603b5cbb10841b408eb2075b727d0f913facad41f1f5f1c39287c2b2c75", + "mips-unknown-linux-gnu": "830667f2dfbbc6c5ed1c7ca9adfb6687e00e49ae085b22d63a9d1a55329cae8d", + "mipsel-unknown-linux-gnu": "57be30f7bb793ec82de5f1b6a823d04e61dcdf18a4e7bd045c1333196448f987", + "powerpc-unknown-linux-gnu": "c044c8b1483e774f2fc13c98e961143ec3bc0a7ade0ae0fd25827b3eeba97979", + "powerpc64-unknown-linux-gnu": "cdc592d78eac54fd3e9868627a6f506d114147124d7ee54c4a1fa6d021d336b0", + "powerpc64le-unknown-linux-gnu": "1edc3225047e09c7a720d4629c919dd29a08461305418314288c4cd693902456", + "x86_64-unknown-linux-gnu": "893a53b5f78ec9eb7ac4ad3b3bd375d2ddad8ca1687ed5867621ec157eddbea5", + } + return get_hash(HASHES, triple) + +def rustc_md5(triple): + HASHES = { + "aarch64-unknown-linux-gnu": "2beae9a9bd441553e979e10464829a97", + "arm-unknown-linux-gnueabi": "8249b5fe2291e47e8458acb989b38688", + "arm-unknown-linux-gnueabihf": "7d76432d54649ff6efcaae44cfd0552b", + "armv7-unknown-linux-gnueabihf": "7386f1fae4b9e9ef95e281ea27f1446a", + "i686-unknown-linux-gnu": "932c698c242238a68530c2c15fd0b810", + "x86_64-unknown-linux-gnu": "b83d7a1a90c2d80bef97a518022948c8", + } + return get_hash(HASHES, triple) + +def rustc_sha256(triple): + HASHES = { + "aarch64-unknown-linux-gnu": "49d3977bc4d3d868ae0632b860308a43975255a81a92d26c3a40569b4186bdc1", + "arm-unknown-linux-gnueabi": "b6224b50293d31a88315c905fed9e50012831bf14d92db654b8137b023eadc37", + "arm-unknown-linux-gnueabihf": "896a7529b452dcc8ef7f3cbf0afb6d3e92868a762e2fbb234fe1b788cc8386cd", + "armv7-unknown-linux-gnueabihf": "c7d68a45536883c3cb0cb6e01ae47e403b0de0165050f0a6cf7a454a9f62440b", + "i686-unknown-linux-gnu": "16273afc0540b4353e54faab6b73e16310ae724f3dc941938bf09129b08bed03", + "x86_64-unknown-linux-gnu": "e9d27a72900da33c1bbd0e59dd42fd6414c6bcdfa33593fb7c7360068406394a", + } + return get_hash(HASHES, triple) + + +LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=43e1f1fb9c0ee3af66693d8c4fecafa8" + +include rust-bin.inc