* [Buildroot] [PATCH v10 01/10] rustc: new virtual package
2018-02-04 18:07 [Buildroot] [PATCH v10 00/10] Add support for the Rust programming language Eric Le Bihan
@ 2018-02-04 18:07 ` Eric Le Bihan
2018-02-08 22:52 ` Thomas Petazzoni
2018-02-04 18:07 ` [Buildroot] [PATCH v10 02/10] rust-bin: new package Eric Le Bihan
` (9 subsequent siblings)
10 siblings, 1 reply; 20+ messages in thread
From: Eric Le Bihan @ 2018-02-04 18:07 UTC (permalink / raw)
To: buildroot
The compiler for the Rust programming language is called rustc.
There is only one reference implementation for it, based on LLVM, from
the Rust project [1]. It can generate code for various architectures so
it can be labeled as a cross-compiler. But, as for GCC, building it
from source takes time.
So it would be sensible to have at least one package which provides it
as a pre-built version, fetched from the upstream project. Later another
package can be added, to build it from source code.
In addition to the compiler, the standard library for the host and/or
the target should also be fetched/built.
So, add a virtual package named rustc to enable support for multiple
providers.
Currently, only the host variant will be available to allow the user to
cross-compile Rust programs for the target.
[1] http://rust-lang.org
Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
---
package/Config.in.host | 1 +
package/rustc/Config.in.host | 31 +++++++++++++++++++++++++++++++
package/rustc/rustc.mk | 20 ++++++++++++++++++++
3 files changed, 52 insertions(+)
create mode 100644 package/rustc/Config.in.host
create mode 100644 package/rustc/rustc.mk
diff --git a/package/Config.in.host b/package/Config.in.host
index dd6415bba5..2f20dd0e48 100644
--- a/package/Config.in.host
+++ b/package/Config.in.host
@@ -46,6 +46,7 @@ menu "Host utilities"
source "package/qemu/Config.in.host"
source "package/raspberrypi-usbboot/Config.in.host"
source "package/rauc/Config.in.host"
+ source "package/rustc/Config.in.host"
source "package/s6-rc/Config.in.host"
source "package/sam-ba/Config.in.host"
source "package/squashfs/Config.in.host"
diff --git a/package/rustc/Config.in.host b/package/rustc/Config.in.host
new file mode 100644
index 0000000000..a49f635d65
--- /dev/null
+++ b/package/rustc/Config.in.host
@@ -0,0 +1,31 @@
+config BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS
+ bool
+ depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86"
+ # The pre-built Rust standard library is only available for the
+ # following architectures/ABIs, and is built against glibc.
+ default y if BR2_i386
+ default y if BR2_x86_64
+ default y if BR2_aarch64
+ default y if BR2_arm && !BR2_ARM_CPU_ARMV4 && !BR2_ARM_CPU_ARMV5
+ default y if BR2_powerpc || BR2_powerpc64
+ default y if (BR2_mips || BR2_mipsel) && !BR2_MIPS_CPU_MIPS32R6
+ default y if (BR2_mips64 || BR2_mips64el) && !BR2_MIPS_CPU_MIPS64R6 \
+ && BR2_MIPS_NABI64
+ depends on BR2_TOOLCHAIN_USES_GLIBC
+
+config BR2_PACKAGE_HOST_RUSTC_ARCH
+ string
+ default "armv7" if BR2_ARM_CPU_ARMV7A
+ default BR2_ARCH if !BR2_ARM_CPU_ARMV7A
+
+config BR2_PACKAGE_HOST_RUSTC_ABI
+ string
+ default "eabi" if BR2_ARM_EABI
+ default "eabihf" if BR2_ARM_EABIHF
+ default "abi64" if BR2_MIPS_NABI64
+
+config BR2_PACKAGE_HAS_HOST_RUSTC
+ bool
+
+config BR2_PACKAGE_PROVIDES_HOST_RUSTC
+ string
diff --git a/package/rustc/rustc.mk b/package/rustc/rustc.mk
new file mode 100644
index 0000000000..7a951c0cfd
--- /dev/null
+++ b/package/rustc/rustc.mk
@@ -0,0 +1,20 @@
+################################################################################
+#
+# rustc
+#
+################################################################################
+
+RUSTC_ARCH = $(call qstrip,$(BR2_PACKAGE_HOST_RUSTC_ARCH))
+RUSTC_ABI = $(call qstrip,$(BR2_PACKAGE_HOST_RUSTC_ABI))
+
+RUST_TARGET_NAME = $(RUSTC_ARCH)-unknown-linux-gnu$(RUSTC_ABI)
+
+ifeq ($(HOSTARCH),x86)
+RUSTC_HOST_ARCH = i686
+else
+RUSTC_HOST_ARCH = $(HOSTARCH)
+endif
+
+RUST_HOST_NAME = $(RUSTC_HOST_ARCH)-unknown-linux-gnu
+
+$(eval $(host-virtual-package))
--
2.14.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [Buildroot] [PATCH v10 01/10] rustc: new virtual package
2018-02-04 18:07 ` [Buildroot] [PATCH v10 01/10] rustc: new virtual package Eric Le Bihan
@ 2018-02-08 22:52 ` Thomas Petazzoni
2018-02-09 8:49 ` Eric Le Bihan
0 siblings, 1 reply; 20+ messages in thread
From: Thomas Petazzoni @ 2018-02-08 22:52 UTC (permalink / raw)
To: buildroot
Hello,
+Peter, Arnout, Ricardo in Cc.
On Sun, 4 Feb 2018 19:07:40 +0100, Eric Le Bihan wrote:
> diff --git a/package/rustc/rustc.mk b/package/rustc/rustc.mk
> new file mode 100644
> index 0000000000..7a951c0cfd
> --- /dev/null
> +++ b/package/rustc/rustc.mk
> @@ -0,0 +1,20 @@
> +################################################################################
> +#
> +# rustc
> +#
> +################################################################################
> +
> +RUSTC_ARCH = $(call qstrip,$(BR2_PACKAGE_HOST_RUSTC_ARCH))
> +RUSTC_ABI = $(call qstrip,$(BR2_PACKAGE_HOST_RUSTC_ABI))
> +
> +RUST_TARGET_NAME = $(RUSTC_ARCH)-unknown-linux-gnu$(RUSTC_ABI)
> +
> +ifeq ($(HOSTARCH),x86)
> +RUSTC_HOST_ARCH = i686
> +else
> +RUSTC_HOST_ARCH = $(HOSTARCH)
> +endif
> +
> +RUST_HOST_NAME = $(RUSTC_HOST_ARCH)-unknown-linux-gnu
check-package is not happy with RUST_TARGET_NAME and RUST_HOST_NAME
because they don't have a RUSTC_ prefix, even though they are defined
in rustc.mk:
./package/rustc/rustc.mk:10: possible typo: RUST_TARGET_NAME -> *RUSTC*
./package/rustc/rustc.mk:18: possible typo: RUST_HOST_NAME -> *RUSTC*
Would renaming them to RUSTC_TARGET_NAME and RUSTC_HOST_NAME make
sense ? Or do we need to keep RUST_TARGET_NAME/RUST_HOST_NAME and add
an exception in check-package ?
Thanks for your feedback,
Thomas
--
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Buildroot] [PATCH v10 01/10] rustc: new virtual package
2018-02-08 22:52 ` Thomas Petazzoni
@ 2018-02-09 8:49 ` Eric Le Bihan
2018-02-09 8:56 ` Thomas Petazzoni
0 siblings, 1 reply; 20+ messages in thread
From: Eric Le Bihan @ 2018-02-09 8:49 UTC (permalink / raw)
To: buildroot
On 2018-02-08 23:52, Thomas Petazzoni wrote:
> Hello,
>
> +Peter, Arnout, Ricardo in Cc.
>
> On Sun, 4 Feb 2018 19:07:40 +0100, Eric Le Bihan wrote:
>
> > diff --git a/package/rustc/rustc.mk b/package/rustc/rustc.mk
> > new file mode 100644
> > index 0000000000..7a951c0cfd
> > --- /dev/null
> > +++ b/package/rustc/rustc.mk
> > @@ -0,0 +1,20 @@
> > +################################################################################
> > +#
> > +# rustc
> > +#
> > +################################################################################
> > +
> > +RUSTC_ARCH = $(call qstrip,$(BR2_PACKAGE_HOST_RUSTC_ARCH))
> > +RUSTC_ABI = $(call qstrip,$(BR2_PACKAGE_HOST_RUSTC_ABI))
> > +
> > +RUST_TARGET_NAME = $(RUSTC_ARCH)-unknown-linux-gnu$(RUSTC_ABI)
> > +
> > +ifeq ($(HOSTARCH),x86)
> > +RUSTC_HOST_ARCH = i686
> > +else
> > +RUSTC_HOST_ARCH = $(HOSTARCH)
> > +endif
> > +
> > +RUST_HOST_NAME = $(RUSTC_HOST_ARCH)-unknown-linux-gnu
>
> check-package is not happy with RUST_TARGET_NAME and RUST_HOST_NAME
> because they don't have a RUSTC_ prefix, even though they are defined
> in rustc.mk:
>
> ./package/rustc/rustc.mk:10: possible typo: RUST_TARGET_NAME -> *RUSTC*
> ./package/rustc/rustc.mk:18: possible typo: RUST_HOST_NAME -> *RUSTC*
>
> Would renaming them to RUSTC_TARGET_NAME and RUSTC_HOST_NAME make
> sense ? Or do we need to keep RUST_TARGET_NAME/RUST_HOST_NAME and add
> an exception in check-package ?
I do not see any problems using RUSTC_{HOST,TARGET}_NAME: it still caries
the same information as RUST_{HOST,TARGET}_NAME.
Regards,
--
ELB
^ permalink raw reply [flat|nested] 20+ messages in thread* [Buildroot] [PATCH v10 01/10] rustc: new virtual package
2018-02-09 8:49 ` Eric Le Bihan
@ 2018-02-09 8:56 ` Thomas Petazzoni
2018-02-09 18:11 ` Eric Le Bihan
0 siblings, 1 reply; 20+ messages in thread
From: Thomas Petazzoni @ 2018-02-09 8:56 UTC (permalink / raw)
To: buildroot
Hello,
On Fri, 9 Feb 2018 09:49:06 +0100, Eric Le Bihan wrote:
> > check-package is not happy with RUST_TARGET_NAME and RUST_HOST_NAME
> > because they don't have a RUSTC_ prefix, even though they are defined
> > in rustc.mk:
> >
> > ./package/rustc/rustc.mk:10: possible typo: RUST_TARGET_NAME -> *RUSTC*
> > ./package/rustc/rustc.mk:18: possible typo: RUST_HOST_NAME -> *RUSTC*
> >
> > Would renaming them to RUSTC_TARGET_NAME and RUSTC_HOST_NAME make
> > sense ? Or do we need to keep RUST_TARGET_NAME/RUST_HOST_NAME and add
> > an exception in check-package ?
>
> I do not see any problems using RUSTC_{HOST,TARGET}_NAME: it still caries
> the same information as RUST_{HOST,TARGET}_NAME.
Question is: are these host and target names "Rust" related, or "Rust
compiler" related. If they are Rust related, the current RUST_ prefix
makes more sense. If they are specific to the Rust compiler, then
RUSTC_ would make more sense. If it isn't clear, then we can use RUSTC_
to avoid the problem :-)
If you are happy with RUSTC_, could you submit a patch against "master"
that does the renaming ?
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
^ permalink raw reply [flat|nested] 20+ messages in thread* [Buildroot] [PATCH v10 01/10] rustc: new virtual package
2018-02-09 8:56 ` Thomas Petazzoni
@ 2018-02-09 18:11 ` Eric Le Bihan
0 siblings, 0 replies; 20+ messages in thread
From: Eric Le Bihan @ 2018-02-09 18:11 UTC (permalink / raw)
To: buildroot
On 2018-02-09 09:56, Thomas Petazzoni wrote:
> Hello,
>
> On Fri, 9 Feb 2018 09:49:06 +0100, Eric Le Bihan wrote:
>
> > > check-package is not happy with RUST_TARGET_NAME and RUST_HOST_NAME
> > > because they don't have a RUSTC_ prefix, even though they are defined
> > > in rustc.mk:
> > >
> > > ./package/rustc/rustc.mk:10: possible typo: RUST_TARGET_NAME -> *RUSTC*
> > > ./package/rustc/rustc.mk:18: possible typo: RUST_HOST_NAME -> *RUSTC*
> > >
> > > Would renaming them to RUSTC_TARGET_NAME and RUSTC_HOST_NAME make
> > > sense ? Or do we need to keep RUST_TARGET_NAME/RUST_HOST_NAME and add
> > > an exception in check-package ?
> >
> > I do not see any problems using RUSTC_{HOST,TARGET}_NAME: it still caries
> > the same information as RUST_{HOST,TARGET}_NAME.
>
> Question is: are these host and target names "Rust" related, or "Rust
> compiler" related. If they are Rust related, the current RUST_ prefix
> makes more sense. If they are specific to the Rust compiler, then
> RUSTC_ would make more sense. If it isn't clear, then we can use RUSTC_
> to avoid the problem :-)
As RUSTC_{HOST,TARGET}_NAME is passed to the Rust compiler by the
--target option, it is "Rust compiler" related. So the renaming makes
sense.
> If you are happy with RUSTC_, could you submit a patch against "master"
> that does the renaming ?
Should I provide a global patch or a series of patches, one for each
affected package?
Regards,
--
ELB
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Buildroot] [PATCH v10 02/10] rust-bin: new package
2018-02-04 18:07 [Buildroot] [PATCH v10 00/10] Add support for the Rust programming language Eric Le Bihan
2018-02-04 18:07 ` [Buildroot] [PATCH v10 01/10] rustc: new virtual package Eric Le Bihan
@ 2018-02-04 18:07 ` Eric Le Bihan
2018-02-04 18:07 ` [Buildroot] [PATCH v10 03/10] cargo-bin: " Eric Le Bihan
` (8 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Eric Le Bihan @ 2018-02-04 18:07 UTC (permalink / raw)
To: buildroot
This package provides a pre-built version of rustc, the compiler for the
Rust programming language, fetched from the upstream project.
A pre-built version of the standard library for the host as well as one
for the chosen target are also fetched and installed.
Only the host variant is provided to allow the user to cross-compile
Rust programs and run them on the target.
This package could also be used to provide a bootstrap compiler when building
Rust from source. So, in order to add it as a build dependency, the compiler and
standard libraries are only installed in $(HOST_DIR) if the package is
explicitly selected.
The menuconfig entry for rustc is also updated to expose this provider.
Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
---
DEVELOPERS | 1 +
package/rust-bin/rust-bin.hash | 33 +++++++++++++++++++++++
package/rust-bin/rust-bin.mk | 61 ++++++++++++++++++++++++++++++++++++++++++
package/rustc/Config.in.host | 29 ++++++++++++++++++++
4 files changed, 124 insertions(+)
create mode 100644 package/rust-bin/rust-bin.hash
create mode 100644 package/rust-bin/rust-bin.mk
diff --git a/DEVELOPERS b/DEVELOPERS
index 4f2c84758e..7e04f872ac 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -548,6 +548,7 @@ F: package/hicolor-icon-theme/
F: package/jemalloc/
F: package/meson/
F: package/ninja/
+F: package/rust-bin/
F: package/s6/
F: package/s6-dns/
F: package/s6-linux-init/
diff --git a/package/rust-bin/rust-bin.hash b/package/rust-bin/rust-bin.hash
new file mode 100644
index 0000000000..5b34a6aa0c
--- /dev/null
+++ b/package/rust-bin/rust-bin.hash
@@ -0,0 +1,33 @@
+# From https://static.rust-lang.org/dist/rustc-1.23.0-i686-unknown-linux-gnu.tar.xz.sha256
+sha256 243de2826b2d545b8428414a3f7e86ce5e86163ec927a374958052a047b55e69 rustc-1.23.0-i686-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/rustc-1.23.0-x86_64-unknown-linux-gnu.tar.xz.sha256
+sha256 d72674a683dcc8a07ad72d6ae08b96a7dfc72cf08433e2ae69c0f8a2b9c79c17 rustc-1.23.0-x86_64-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-aarch64-unknown-linux-gnu.tar.xz.sha256
+sha256 0d9c976c46a277ef860ce5766387ea8e40f84657e5f9962cba91be62a00ca345 rust-std-1.23.0-aarch64-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-arm-unknown-linux-gnueabi.tar.xz.sha256
+sha256 3d7ce58f6d2bbf6faf91049893e96611a172b0af02d98190e36a49e8b0f974ee rust-std-1.23.0-arm-unknown-linux-gnueabi.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-arm-unknown-linux-gnueabihf.tar.xz.sha256
+sha256 0a2a43668c2ddc2516e85e1c097d2672acaf61541d2b70f40daba548b3ccbee1 rust-std-1.23.0-arm-unknown-linux-gnueabihf.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-armv7-unknown-linux-gnueabihf.tar.xz.sha256
+sha256 b2f7f4e2e31d86302e929d0435b6f40778c22fc9306f0850b0edc4738ff2634e rust-std-1.23.0-armv7-unknown-linux-gnueabihf.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-i686-unknown-linux-gnu.tar.xz.sha256
+sha256 f9659f844ccd2e25e9f01a49fb7adf0ce26cbbec7a4df7081dd2d0929a86b2d3 rust-std-1.23.0-i686-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-mips-unknown-linux-gnu.tar.xz.sha256
+sha256 8324d9c1eacba0de31fff29841d0f0567261489ee46a270e30be929095bfe19a rust-std-1.23.0-mips-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-mips64-unknown-linux-gnuabi64.tar.xz.sha256
+sha256 521f70f3346ff8e28e33350fd5ad9bbba7dfc9038389f3965bcfa2f1d1a498a5 rust-std-1.23.0-mips64-unknown-linux-gnuabi64.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-mips64el-unknown-linux-gnuabi64.tar.xz.sha256
+sha256 d08f5792bd0d4f5d3d81a4ec1b3a2b36e7c389de2ecf2e777e390461ff015d08 rust-std-1.23.0-mips64el-unknown-linux-gnuabi64.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-mipsel-unknown-linux-gnu.tar.xz.sha256
+sha256 77291fff357b9e1764a4d7975bdbecdb37aeb0d37d85ccb68f7d785f4da1a056 rust-std-1.23.0-mipsel-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-powerpc-unknown-linux-gnu.tar.xz.sha256
+sha256 d1b862d32c4921058ff4ea5b7fead3b2954b5f0f036603b1c58a600e602d1f25 rust-std-1.23.0-powerpc-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-powerpc64-unknown-linux-gnu.tar.xz.sha256
+sha256 e03bf7907914c88d2f19e719f07641b1b1ffbb65cf9daae8b028f4ab4619b4ff rust-std-1.23.0-powerpc64-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-powerpc64le-unknown-linux-gnu.tar.xz.sha256
+sha256 674f74245341119409e203109c22d432d0ed3312a6ff4d3b03cab251e61cc53a rust-std-1.23.0-powerpc64le-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/rust-std-1.23.0-x86_64-unknown-linux-gnu.tar.xz.sha256
+sha256 0d87225dd081c7ea5002fdeb21983d23bc52fa37d23c88d5c97b2c44660f8af9 rust-std-1.23.0-x86_64-unknown-linux-gnu.tar.xz
+# Locally generated
+sha256 a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2 LICENSE-APACHE
+sha256 23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3 LICENSE-MIT
diff --git a/package/rust-bin/rust-bin.mk b/package/rust-bin/rust-bin.mk
new file mode 100644
index 0000000000..255573e582
--- /dev/null
+++ b/package/rust-bin/rust-bin.mk
@@ -0,0 +1,61 @@
+################################################################################
+#
+# rust-bin
+#
+################################################################################
+
+RUST_BIN_VERSION = 1.23.0
+RUST_BIN_SITE = https://static.rust-lang.org/dist
+RUST_BIN_LICENSE = Apache-2.0 or MIT
+RUST_BIN_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
+
+HOST_RUST_BIN_PROVIDES = host-rustc
+
+HOST_RUST_BIN_SOURCE = rustc-$(RUST_BIN_VERSION)-$(RUST_HOST_NAME).tar.xz
+
+HOST_RUST_BIN_EXTRA_DOWNLOADS = \
+ rust-std-$(RUST_BIN_VERSION)-$(RUST_HOST_NAME).tar.xz \
+ rust-std-$(RUST_BIN_VERSION)-$(RUST_TARGET_NAME).tar.xz
+
+HOST_RUST_BIN_LIBSTD_HOST_PREFIX = rust-std-$(RUST_BIN_VERSION)-$(RUST_HOST_NAME)/rust-std-$(RUST_HOST_NAME)
+
+define HOST_RUST_BIN_LIBSTD_EXTRACT
+ mkdir -p $(@D)/std
+ $(foreach f,$(HOST_RUST_BIN_EXTRA_DOWNLOADS), \
+ $(call suitable-extractor,$(f)) $(DL_DIR)/$(f) | \
+ $(TAR) -C $(@D)/std $(TAR_OPTIONS) -
+ )
+ cd $(@D)/rustc/lib/rustlib; \
+ ln -sf ../../../std/$(HOST_RUST_BIN_LIBSTD_HOST_PREFIX)/lib/rustlib/$(RUST_HOST_NAME)
+endef
+
+HOST_RUST_BIN_POST_EXTRACT_HOOKS += HOST_RUST_BIN_LIBSTD_EXTRACT
+
+HOST_RUST_BIN_INSTALL_OPTS = \
+ --prefix=$(HOST_DIR) \
+ --disable-ldconfig
+
+ifeq ($(BR2_PACKAGE_HOST_RUST_BIN),y)
+define HOST_RUST_BIN_INSTALL_RUSTC
+ (cd $(@D); \
+ ./install.sh $(HOST_RUST_BIN_INSTALL_OPTS))
+endef
+
+define HOST_RUST_BIN_INSTALL_LIBSTD_HOST
+ (cd $(@D)/std/rust-std-$(RUST_BIN_VERSION)-$(RUST_HOST_NAME); \
+ ./install.sh $(HOST_RUST_BIN_INSTALL_OPTS))
+endef
+
+define HOST_RUST_BIN_INSTALL_LIBSTD_TARGET
+ (cd $(@D)/std/rust-std-$(RUST_BIN_VERSION)-$(RUST_TARGET_NAME); \
+ ./install.sh $(HOST_RUST_BIN_INSTALL_OPTS))
+endef
+endif
+
+define HOST_RUST_BIN_INSTALL_CMDS
+ $(HOST_RUST_BIN_INSTALL_RUSTC)
+ $(HOST_RUST_BIN_INSTALL_LIBSTD_HOST)
+ $(HOST_RUST_BIN_INSTALL_LIBSTD_TARGET)
+endef
+
+$(eval $(host-generic-package))
diff --git a/package/rustc/Config.in.host b/package/rustc/Config.in.host
index a49f635d65..66c50c4579 100644
--- a/package/rustc/Config.in.host
+++ b/package/rustc/Config.in.host
@@ -24,8 +24,37 @@ config BR2_PACKAGE_HOST_RUSTC_ABI
default "eabihf" if BR2_ARM_EABIHF
default "abi64" if BR2_MIPS_NABI64
+config BR2_PACKAGE_HOST_RUSTC
+ bool "host rustc"
+ depends on BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS
+ help
+ Compiler for the Rust language
+
+ http://www.rust-lang.org
+
+if BR2_PACKAGE_HOST_RUSTC
+
+choice
+ prompt "Rust compiler variant"
+ default BR2_PACKAGE_HOST_RUST_BIN
+ help
+ Select a Rust compiler
+
+config BR2_PACKAGE_HOST_RUST_BIN
+ bool "host rust (pre-built)"
+ select BR2_PACKAGE_HAS_HOST_RUSTC
+ help
+ This package will install pre-built versions of the compiler
+ for the host and the Rust standard library for the target.
+
+endchoice
+
config BR2_PACKAGE_HAS_HOST_RUSTC
bool
config BR2_PACKAGE_PROVIDES_HOST_RUSTC
string
+ default "host-rust-bin" if BR2_PACKAGE_HOST_RUST_BIN
+
+endif
+
--
2.14.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [Buildroot] [PATCH v10 03/10] cargo-bin: new package
2018-02-04 18:07 [Buildroot] [PATCH v10 00/10] Add support for the Rust programming language Eric Le Bihan
2018-02-04 18:07 ` [Buildroot] [PATCH v10 01/10] rustc: new virtual package Eric Le Bihan
2018-02-04 18:07 ` [Buildroot] [PATCH v10 02/10] rust-bin: new package Eric Le Bihan
@ 2018-02-04 18:07 ` Eric Le Bihan
2018-02-04 18:07 ` [Buildroot] [PATCH v10 04/10] rust: " Eric Le Bihan
` (7 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Eric Le Bihan @ 2018-02-04 18:07 UTC (permalink / raw)
To: buildroot
This new package fetches a binary version of Cargo, suitable to
bootstrap the host variants of the Rust compiler and Cargo, the package
manager.
Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
---
DEVELOPERS | 1 +
package/cargo-bin/cargo-bin.hash | 8 ++++++++
package/cargo-bin/cargo-bin.mk | 13 +++++++++++++
3 files changed, 22 insertions(+)
create mode 100644 package/cargo-bin/cargo-bin.hash
create mode 100644 package/cargo-bin/cargo-bin.mk
diff --git a/DEVELOPERS b/DEVELOPERS
index 7e04f872ac..70ca569feb 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -541,6 +541,7 @@ F: package/xxhash/
N: Eric Le Bihan <eric.le.bihan.dev@free.fr>
F: docs/manual/adding-packages-meson.txt
F: package/adwaita-icon-theme/
+F: package/cargo-bin/
F: package/darkhttpd/
F: package/eudev/
F: package/execline/
diff --git a/package/cargo-bin/cargo-bin.hash b/package/cargo-bin/cargo-bin.hash
new file mode 100644
index 0000000000..ea121547b4
--- /dev/null
+++ b/package/cargo-bin/cargo-bin.hash
@@ -0,0 +1,8 @@
+# From https://static.rust-lang.org/dist/cargo-0.24.0-i686-unknown-linux-gnu.tar.xz.sha256
+sha256 6ffc847e0ee2a1273223ce500f7b212d051e99a6d234e34585d0c55e21a963ea cargo-0.24.0-i686-unknown-linux-gnu.tar.xz
+# From https://static.rust-lang.org/dist/cargo-0.24.0-x86_64-unknown-linux-gnu.tar.xz.sha256
+sha256 93b953c8c7a2088aef952de8dccd7f6ccf9b21bf94b735d3909961ffe831da8c cargo-0.24.0-x86_64-unknown-linux-gnu.tar.xz
+# Locally generated
+sha256 a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2 LICENSE-APACHE
+sha256 23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3 LICENSE-MIT
+sha256 8bd89f9222dc80292f4107347103b693ac66f3a083371f0629ccf42338abe880 LICENSE-THIRD-PARTY
diff --git a/package/cargo-bin/cargo-bin.mk b/package/cargo-bin/cargo-bin.mk
new file mode 100644
index 0000000000..0f235748ff
--- /dev/null
+++ b/package/cargo-bin/cargo-bin.mk
@@ -0,0 +1,13 @@
+################################################################################
+#
+# cargo-bin
+#
+################################################################################
+
+CARGO_BIN_VERSION = 0.24.0
+CARGO_BIN_SITE = https://static.rust-lang.org/dist
+CARGO_BIN_SOURCE = cargo-$(CARGO_BIN_VERSION)-$(RUST_HOST_NAME).tar.xz
+CARGO_BIN_LICENSE = Apache-2.0 or MIT
+CARGO_BIN_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
+
+$(eval $(host-generic-package))
--
2.14.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [Buildroot] [PATCH v10 04/10] rust: new package
2018-02-04 18:07 [Buildroot] [PATCH v10 00/10] Add support for the Rust programming language Eric Le Bihan
` (2 preceding siblings ...)
2018-02-04 18:07 ` [Buildroot] [PATCH v10 03/10] cargo-bin: " Eric Le Bihan
@ 2018-02-04 18:07 ` Eric Le Bihan
2018-02-04 18:07 ` [Buildroot] [PATCH v10 05/10] libssh2: add host variant Eric Le Bihan
` (6 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Eric Le Bihan @ 2018-02-04 18:07 UTC (permalink / raw)
To: buildroot
This new package provides rustc, the compiler for the Rust programming
language, built from source.
Currently, only the host variant is built.
The Rust compiler uses LLVM as its backend: a copy of LLVM source code
is provided and CMake is used to build it. It is possible to use a
pre-built external copy. When LLVM/clang will be available in Buildroot,
it would be possible to benefit from this feature and thus decrease
build time.
LLVM is configured to generate code for x86, ARM, PowerPC and MIPS
architectures.
The Rust compiler uses Cargo as its build system and is written in Rust.
Therefore this package depends on cargo-bin and rust-bin.
The internal build process is as follows:
1. stage0 compiler, provided by rust-bin, is used to build stage1
compiler.
2. stage1 compiler builds the final Rust compiler (stage2 compiler)
and the standard library for the host architecture.
3. the standard library for the target architecture is built.
The target architecture to support is given by the GNU/LLVM target
triple. Rust supports some predefined targets [1]. As the build system
expects the triple to be in the form of <arch>-unknown-<system> and
Buildroot toolchain wrapper uses <arch>-buildroot-<system>, the package
Makefile uses $(RUST_TARGET_NAME) defined in the rustc package and uses
it instead of $(GNU_TARGET_NAME).
When compiling Rust code with this compiler, the generated program only
depends on the target C library, as it is statically linked to the Rust
standard library and any other code from Rust packages (a.k.a.
"crates").
If the jemalloc package is selected, support for this memory allocator
will be enabled in the target standard library.
The menuconfig entry for rustc is also updated to expose this provider.
[1] https://forge.rust-lang.org/platform-support.html
Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
---
DEVELOPERS | 1 +
package/rust/rust.hash | 5 +++
package/rust/rust.mk | 79 ++++++++++++++++++++++++++++++++++++++++++++
package/rustc/Config.in.host | 19 +++++++++++
4 files changed, 104 insertions(+)
create mode 100644 package/rust/rust.hash
create mode 100644 package/rust/rust.mk
diff --git a/DEVELOPERS b/DEVELOPERS
index 70ca569feb..0e041d6f40 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -550,6 +550,7 @@ F: package/jemalloc/
F: package/meson/
F: package/ninja/
F: package/rust-bin/
+F: package/rust/
F: package/s6/
F: package/s6-dns/
F: package/s6-linux-init/
diff --git a/package/rust/rust.hash b/package/rust/rust.hash
new file mode 100644
index 0000000000..d6731b6dc2
--- /dev/null
+++ b/package/rust/rust.hash
@@ -0,0 +1,5 @@
+# From https://static.rust-lang.org/dist/rustc-1.23.0-src.tar.xz.sha256
+sha256 7196032371b50dd5582465b3bfa79ffd783b74f0711420d99b61b26c96fb3d80 rustc-1.23.0-src.tar.xz
+# Locally generated
+sha256 a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2 LICENSE-APACHE
+sha256 23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3 LICENSE-MIT
diff --git a/package/rust/rust.mk b/package/rust/rust.mk
new file mode 100644
index 0000000000..6d6ac4370a
--- /dev/null
+++ b/package/rust/rust.mk
@@ -0,0 +1,79 @@
+################################################################################
+#
+# rust
+#
+################################################################################
+
+RUST_VERSION = 1.23.0
+RUST_SOURCE = rustc-$(RUST_VERSION)-src.tar.xz
+RUST_SITE = https://static.rust-lang.org/dist
+RUST_LICENSE = Apache-2.0 or MIT
+RUST_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
+
+HOST_RUST_PROVIDES = host-rustc
+
+HOST_RUST_DEPENDENCIES = \
+ toolchain \
+ host-rust-bin \
+ host-cargo-bin \
+ host-python \
+ $(BR2_CMAKE_HOST_DEPENDENCY)
+
+ifeq ($(BR2_PACKAGE_JEMALLOC),y)
+HOST_RUST_DEPENDENCIES += jemalloc
+HOST_RUST_JEMALLOC_ENABLED = true
+HOST_RUST_JEMALLOC_CONF = 'jemalloc = "$(STAGING_DIR)/usr/lib/libjemalloc_pic.a"'
+else
+HOST_RUST_JEMALLOC_ENABLED = false
+endif
+
+HOST_RUST_VERBOSITY = $(if $(VERBOSE),2,0)
+
+# Some vendor crates contain Cargo.toml.orig files. The associated
+# .cargo-checksum.json file will contain a checksum for Cargo.toml.orig but
+# support/scripts/apply-patches.sh will delete them. This will cause the build
+# to fail, as Cargo will not be able to find the file and verify the checksum.
+# So, remove all Cargo.toml.orig entries from the affected .cargo-checksum.json
+# files
+define HOST_RUST_EXCLUDE_ORIG_FILES
+ for file in $$(find $(@D) -name '*.orig'); do \
+ crate=$$(dirname $${file}); \
+ fn=$${crate}/.cargo-checksum.json; \
+ sed -i -e 's/"Cargo.toml.orig":"[a-z0-9]\+",//g' $${fn}; \
+ done
+endef
+
+HOST_RUST_POST_EXTRACT_HOOKS += HOST_RUST_EXCLUDE_ORIG_FILES
+
+define HOST_RUST_CONFIGURE_CMDS
+ ( \
+ echo '[build]'; \
+ echo 'target = ["$(RUST_TARGET_NAME)"]'; \
+ echo 'cargo = "$(HOST_CARGO_BIN_DIR)/cargo/bin/cargo"'; \
+ echo 'rustc = "$(HOST_RUST_BIN_DIR)/rustc/bin/rustc"'; \
+ echo 'python = "$(HOST_DIR)/bin/python2"'; \
+ echo 'submodules = false'; \
+ echo 'vendor = true'; \
+ echo 'compiler-docs = false'; \
+ echo 'docs = false'; \
+ echo 'verbose = $(HOST_RUST_VERBOSITY)'; \
+ echo '[install]'; \
+ echo 'prefix = "$(HOST_DIR)"'; \
+ echo '[rust]'; \
+ echo 'use-jemalloc = $(HOST_RUST_JEMALLOC_ENABLED)'; \
+ echo '[target.$(RUST_TARGET_NAME)]'; \
+ echo 'cc = "$(TARGET_CROSS)gcc"'; \
+ echo $(HOST_RUST_JEMALLOC_CONF); \
+ ) > $(@D)/config.toml
+endef
+
+define HOST_RUST_BUILD_CMDS
+ cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python2 x.py build
+endef
+
+define HOST_RUST_INSTALL_CMDS
+ cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python2 x.py dist
+ cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python2 x.py install
+endef
+
+$(eval $(host-generic-package))
diff --git a/package/rustc/Config.in.host b/package/rustc/Config.in.host
index 66c50c4579..d93ff05209 100644
--- a/package/rustc/Config.in.host
+++ b/package/rustc/Config.in.host
@@ -40,6 +40,24 @@ choice
help
Select a Rust compiler
+config BR2_PACKAGE_HOST_RUST
+ bool "host rust"
+ depends on BR2_HOST_GCC_AT_LEAST_4_7 # required by LLVM
+ # triggers ICE on trunc_int_for_mode, at explow.c:56
+ depends on BR2_TOOLCHAIN_GCC_AT_LEAST_5 || !BR2_aarch64
+ select BR2_PACKAGE_HAS_HOST_RUSTC
+ help
+ This package will build the compiler for the host as well as
+ two flavors of the standard library: one for the host, another
+ for the target. Both are installed in the host directory.
+
+comment "host-rust needs a toolchain w/ gcc >= 5"
+ depends on BR2_aarch64
+ depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_5
+
+comment "host-rust needs host gcc >= 4.7"
+ depends on !BR2_HOST_GCC_AT_LEAST_4_7
+
config BR2_PACKAGE_HOST_RUST_BIN
bool "host rust (pre-built)"
select BR2_PACKAGE_HAS_HOST_RUSTC
@@ -54,6 +72,7 @@ config BR2_PACKAGE_HAS_HOST_RUSTC
config BR2_PACKAGE_PROVIDES_HOST_RUSTC
string
+ default "host-rust" if BR2_PACKAGE_HOST_RUST
default "host-rust-bin" if BR2_PACKAGE_HOST_RUST_BIN
endif
--
2.14.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [Buildroot] [PATCH v10 05/10] libssh2: add host variant
2018-02-04 18:07 [Buildroot] [PATCH v10 00/10] Add support for the Rust programming language Eric Le Bihan
` (3 preceding siblings ...)
2018-02-04 18:07 ` [Buildroot] [PATCH v10 04/10] rust: " Eric Le Bihan
@ 2018-02-04 18:07 ` Eric Le Bihan
2018-02-04 18:07 ` [Buildroot] [PATCH v10 06/10] libhttpparser: " Eric Le Bihan
` (5 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Eric Le Bihan @ 2018-02-04 18:07 UTC (permalink / raw)
To: buildroot
Allow build of host variant of libssh2, which depends on host-openssl.
Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
---
package/libssh2/libssh2.mk | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/package/libssh2/libssh2.mk b/package/libssh2/libssh2.mk
index 18e772c722..c5b0bd855e 100644
--- a/package/libssh2/libssh2.mk
+++ b/package/libssh2/libssh2.mk
@@ -40,4 +40,10 @@ else
LIBSSH2_CONF_OPTS += --without-libz
endif
+HOST_LIBSSH2_DEPENDENCIES += host-openssl
+HOST_LIBSSH2_CONF_OPTS += --with-openssl \
+ --with-libssl-prefix=$(HOST_DIR)/usr \
+ --without-libgcrypt
+
$(eval $(autotools-package))
+$(eval $(host-autotools-package))
--
2.14.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [Buildroot] [PATCH v10 06/10] libhttpparser: add host variant
2018-02-04 18:07 [Buildroot] [PATCH v10 00/10] Add support for the Rust programming language Eric Le Bihan
` (4 preceding siblings ...)
2018-02-04 18:07 ` [Buildroot] [PATCH v10 05/10] libssh2: add host variant Eric Le Bihan
@ 2018-02-04 18:07 ` Eric Le Bihan
2018-02-04 18:07 ` [Buildroot] [PATCH v10 07/10] libcurl: " Eric Le Bihan
` (4 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Eric Le Bihan @ 2018-02-04 18:07 UTC (permalink / raw)
To: buildroot
Allow build of host variant of libhttpparser.
Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
---
package/libhttpparser/libhttpparser.mk | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/package/libhttpparser/libhttpparser.mk b/package/libhttpparser/libhttpparser.mk
index 8ff0413322..1df26017e7 100644
--- a/package/libhttpparser/libhttpparser.mk
+++ b/package/libhttpparser/libhttpparser.mk
@@ -23,4 +23,13 @@ define LIBHTTPPARSER_INSTALL_TARGET_CMDS
$(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) PREFIX=$(TARGET_DIR)/usr install
endef
+define HOST_LIBHTTPPARSER_BUILD_CMDS
+ $(MAKE) $(HOST_CONFIGURE_OPTS) -C $(@D) library package
+endef
+
+define HOST_LIBHTTPPARSER_INSTALL_CMDS
+ $(MAKE) $(HOST_CONFIGURE_OPTS) -C $(@D) PREFIX=$(HOST_DIR)/usr install
+endef
+
$(eval $(generic-package))
+$(eval $(host-generic-package))
--
2.14.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [Buildroot] [PATCH v10 07/10] libcurl: add host variant
2018-02-04 18:07 [Buildroot] [PATCH v10 00/10] Add support for the Rust programming language Eric Le Bihan
` (5 preceding siblings ...)
2018-02-04 18:07 ` [Buildroot] [PATCH v10 06/10] libhttpparser: " Eric Le Bihan
@ 2018-02-04 18:07 ` Eric Le Bihan
2018-02-04 18:07 ` [Buildroot] [PATCH v10 08/10] cargo: new package Eric Le Bihan
` (3 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Eric Le Bihan @ 2018-02-04 18:07 UTC (permalink / raw)
To: buildroot
Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
---
package/libcurl/libcurl.mk | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/package/libcurl/libcurl.mk b/package/libcurl/libcurl.mk
index a1d2aa7a60..39ed3e4da5 100644
--- a/package/libcurl/libcurl.mk
+++ b/package/libcurl/libcurl.mk
@@ -88,4 +88,18 @@ endef
LIBCURL_POST_INSTALL_TARGET_HOOKS += LIBCURL_TARGET_CLEANUP
endif
+HOST_LIBCURL_DEPENDENCIES = host-openssl
+HOST_LIBCURL_CONF_OPTS = \
+ --disable-manual \
+ --disable-ntlm-wb \
+ --disable-curldebug \
+ --with-ssl \
+ --without-gnutls \
+ --without-mbedtls \
+ --without-polarssl \
+ --without-nss
+
+HOST_LIBCURL_POST_PATCH_HOOKS += LIBCURL_FIX_DOT_PC
+
$(eval $(autotools-package))
+$(eval $(host-autotools-package))
--
2.14.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [Buildroot] [PATCH v10 08/10] cargo: new package
2018-02-04 18:07 [Buildroot] [PATCH v10 00/10] Add support for the Rust programming language Eric Le Bihan
` (6 preceding siblings ...)
2018-02-04 18:07 ` [Buildroot] [PATCH v10 07/10] libcurl: " Eric Le Bihan
@ 2018-02-04 18:07 ` Eric Le Bihan
2018-02-05 10:26 ` Peter Korsgaard
2018-02-04 18:07 ` [Buildroot] [PATCH v10 09/10] docs/manual: document cargo-based packages Eric Le Bihan
` (2 subsequent siblings)
10 siblings, 1 reply; 20+ messages in thread
From: Eric Le Bihan @ 2018-02-04 18:07 UTC (permalink / raw)
To: buildroot
This new package provides Cargo, the Rust official package manager.
Cargo is written in Rust and uses Cargo as its build system. It also
depends on other Rust packages.
Normally, a previously installed version of Cargo would be used to:
1. Fetch the dependencies.
2. Build the new version of Cargo, using the available Rust compiler.
But the fetching step prevents offline builds. So instead two features
of Cargo are leveraged: vendoring [1] and local registry.
First, a tarball of the build dependencies generated using `cargo
vendor` is fetched along with Cargo source code.
Then, the build process is as follows:
1. The tarball of the build dependencies is uncompressed in a local
registry.
2. A snapshot of Cargo, provided by cargo-bin, builds the final
version of Cargo.
3. A configuration file telling Cargo how to cross-compile programs for
the target is generated and installed.
Currently, only the host variant is provided.
[1] https://github.com/alexcrichton/cargo-vendor
Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
---
DEVELOPERS | 1 +
package/Config.in.host | 1 +
package/cargo/Config.in.host | 8 ++++
package/cargo/cargo.hash | 8 ++++
package/cargo/cargo.mk | 91 ++++++++++++++++++++++++++++++++++++++++++++
package/cargo/config.in | 2 +
6 files changed, 111 insertions(+)
create mode 100644 package/cargo/Config.in.host
create mode 100644 package/cargo/cargo.hash
create mode 100644 package/cargo/cargo.mk
create mode 100644 package/cargo/config.in
diff --git a/DEVELOPERS b/DEVELOPERS
index 0e041d6f40..c524cb6ac5 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -542,6 +542,7 @@ N: Eric Le Bihan <eric.le.bihan.dev@free.fr>
F: docs/manual/adding-packages-meson.txt
F: package/adwaita-icon-theme/
F: package/cargo-bin/
+F: package/cargo/
F: package/darkhttpd/
F: package/eudev/
F: package/execline/
diff --git a/package/Config.in.host b/package/Config.in.host
index 2f20dd0e48..199a8e9856 100644
--- a/package/Config.in.host
+++ b/package/Config.in.host
@@ -2,6 +2,7 @@ menu "Host utilities"
source "package/aespipe/Config.in.host"
source "package/android-tools/Config.in.host"
+ source "package/cargo/Config.in.host"
source "package/cbootimage/Config.in.host"
source "package/checkpolicy/Config.in.host"
source "package/cmake/Config.in.host"
diff --git a/package/cargo/Config.in.host b/package/cargo/Config.in.host
new file mode 100644
index 0000000000..0f1ca305c6
--- /dev/null
+++ b/package/cargo/Config.in.host
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_HOST_CARGO
+ bool "host cargo"
+ depends on BR2_PACKAGE_HAS_HOST_RUSTC
+ help
+ Cargo is the package manager for the Rust programming
+ language.
+
+ https://crates.io/
diff --git a/package/cargo/cargo.hash b/package/cargo/cargo.hash
new file mode 100644
index 0000000000..f0990484d9
--- /dev/null
+++ b/package/cargo/cargo.hash
@@ -0,0 +1,8 @@
+# Locally generated
+sha256 a9d4291254a1d622d3c3cb942aaa56ab4059b8d04915c3af234f0362f14722e8 cargo-0.24.0.tar.gz
+sha256 dc7240d60a869fa24a68c8734fb7c810c27cca0a6dad52df6279865e4e8e7fae rust-installer-4f994850808a572e2cc8d43f968893c8e942e9bf.tar.gz
+sha256 a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2 LICENSE-APACHE
+sha256 23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3 LICENSE-MIT
+sha256 8bd89f9222dc80292f4107347103b693ac66f3a083371f0629ccf42338abe880 LICENSE-THIRD-PARTY
+# From http://pkgs.fedoraproject.org/repo/pkgs/cargo/cargo-0.23.0-vendor.tar.xz/sha512
+sha512 60c12ce49a53cf986490f5a5fdf606f0374677902edfdc4d48ab1ba6094f3f23efc59626cd3776649c9386a9cab2a60332e5693aad6acbcbb92132efdcf9fe21 cargo-0.24.0-vendor.tar.xz
diff --git a/package/cargo/cargo.mk b/package/cargo/cargo.mk
new file mode 100644
index 0000000000..dd060fed03
--- /dev/null
+++ b/package/cargo/cargo.mk
@@ -0,0 +1,91 @@
+################################################################################
+#
+# cargo
+#
+################################################################################
+
+CARGO_VERSION = 0.24.0
+CARGO_SITE = $(call github,rust-lang,cargo,$(CARGO_VERSION))
+CARGO_LICENSE = Apache-2.0 or MIT
+CARGO_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
+
+CARGO_DEPS_SHA512 = 60c12ce49a53cf986490f5a5fdf606f0374677902edfdc4d48ab1ba6094f3f23efc59626cd3776649c9386a9cab2a60332e5693aad6acbcbb92132efdcf9fe21
+CARGO_DEPS_SITE = http://pkgs.fedoraproject.org/repo/pkgs/cargo/$(CARGO_DEPS_SOURCE)/sha512/$(CARGO_DEPS_SHA512)
+CARGO_DEPS_SOURCE = cargo-$(CARGO_VERSION)-vendor.tar.xz
+
+CARGO_INSTALLER_VERSION = 4f994850808a572e2cc8d43f968893c8e942e9bf
+CARGO_INSTALLER_SITE = $(call github,rust-lang,rust-installer,$(CARGO_INSTALLER_VERSION))
+CARGO_INSTALLER_SOURCE = rust-installer-$(CARGO_INSTALLER_VERSION).tar.gz
+
+HOST_CARGO_EXTRA_DOWNLOADS = \
+ $(CARGO_DEPS_SITE)/$(CARGO_DEPS_SOURCE) \
+ $(CARGO_INSTALLER_SITE)/$(CARGO_INSTALLER_SOURCE)
+
+HOST_CARGO_DEPENDENCIES = \
+ $(BR2_CMAKE_HOST_DEPENDENCY) \
+ host-pkgconf \
+ host-openssl \
+ host-libhttpparser \
+ host-libssh2 \
+ host-libcurl \
+ host-rustc \
+ host-cargo-bin
+
+HOST_CARGO_SNAP_BIN = $(HOST_CARGO_BIN_DIR)/cargo/bin/cargo
+HOST_CARGO_HOME = $(HOST_DIR)/share/cargo
+
+define HOST_CARGO_EXTRACT_DEPS
+ @mkdir -p $(@D)/vendor
+ $(call suitable-extractor,$(CARGO_DEPS_SOURCE)) \
+ $(DL_DIR)/$(CARGO_DEPS_SOURCE) | \
+ $(TAR) --strip-components=1 -C $(@D)/vendor $(TAR_OPTIONS) -
+endef
+
+HOST_CARGO_POST_EXTRACT_HOOKS += HOST_CARGO_EXTRACT_DEPS
+
+define HOST_CARGO_EXTRACT_INSTALLER
+ @mkdir -p $(@D)/src/rust-installer
+ $(call suitable-extractor,$(CARGO_INSTALLER_SOURCE)) \
+ $(DL_DIR)/$(CARGO_INSTALLER_SOURCE) | \
+ $(TAR) --strip-components=1 -C $(@D)/src/rust-installer $(TAR_OPTIONS) -
+endef
+
+HOST_CARGO_POST_EXTRACT_HOOKS += HOST_CARGO_EXTRACT_INSTALLER
+
+define HOST_CARGO_SETUP_DEPS
+ mkdir -p $(@D)/.cargo
+ ( \
+ echo "[source.crates-io]"; \
+ echo "registry = 'https://github.com/rust-lang/crates.io-index'"; \
+ echo "replace-with = 'vendored-sources'"; \
+ echo "[source.vendored-sources]"; \
+ echo "directory = '$(@D)/vendor'"; \
+ ) > $(@D)/.cargo/config
+endef
+
+HOST_CARGO_PRE_CONFIGURE_HOOKS += HOST_CARGO_SETUP_DEPS
+
+HOST_CARGO_SNAP_OPTS = \
+ --release \
+ $(if $(VERBOSE),--verbose)
+
+HOST_CARGO_ENV = \
+ RUSTFLAGS="-Clink-arg=-Wl,-rpath,$(HOST_DIR)/lib" \
+ CARGO_HOME=$(HOST_CARGO_HOME)
+
+define HOST_CARGO_BUILD_CMDS
+ (cd $(@D); $(HOST_MAKE_ENV) $(HOST_CARGO_ENV) $(HOST_CARGO_SNAP_BIN) \
+ build $(HOST_CARGO_SNAP_OPTS))
+endef
+
+define HOST_CARGO_INSTALL_CMDS
+ $(INSTALL) -D -m 0755 $(@D)/target/release/cargo $(HOST_DIR)/bin/cargo
+ $(INSTALL) -D package/cargo/config.in \
+ $(HOST_DIR)/share/cargo/config
+ $(SED) 's/@RUST_TARGET_NAME@/$(RUST_TARGET_NAME)/' \
+ $(HOST_DIR)/share/cargo/config
+ $(SED) 's/@CROSS_PREFIX@/$(notdir $(TARGET_CROSS))/' \
+ $(HOST_DIR)/share/cargo/config
+endef
+
+$(eval $(host-generic-package))
diff --git a/package/cargo/config.in b/package/cargo/config.in
new file mode 100644
index 0000000000..cc048c71c4
--- /dev/null
+++ b/package/cargo/config.in
@@ -0,0 +1,2 @@
+[target. at RUST_TARGET_NAME@]
+linker = "@CROSS_PREFIX at gcc"
--
2.14.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [Buildroot] [PATCH v10 08/10] cargo: new package
2018-02-04 18:07 ` [Buildroot] [PATCH v10 08/10] cargo: new package Eric Le Bihan
@ 2018-02-05 10:26 ` Peter Korsgaard
2018-02-05 13:11 ` Sam Voss
2018-02-05 13:58 ` Peter Korsgaard
0 siblings, 2 replies; 20+ messages in thread
From: Peter Korsgaard @ 2018-02-05 10:26 UTC (permalink / raw)
To: buildroot
>>>>> "Eric" == Eric Le Bihan <eric.le.bihan.dev@free.fr> writes:
> This new package provides Cargo, the Rust official package manager.
> Cargo is written in Rust and uses Cargo as its build system. It also
> depends on other Rust packages.
> Normally, a previously installed version of Cargo would be used to:
> 1. Fetch the dependencies.
> 2. Build the new version of Cargo, using the available Rust compiler.
> But the fetching step prevents offline builds. So instead two features
> of Cargo are leveraged: vendoring [1] and local registry.
> First, a tarball of the build dependencies generated using `cargo
> vendor` is fetched along with Cargo source code.
> Then, the build process is as follows:
> 1. The tarball of the build dependencies is uncompressed in a local
> registry.
> 2. A snapshot of Cargo, provided by cargo-bin, builds the final
> version of Cargo.
> 3. A configuration file telling Cargo how to cross-compile programs for
> the target is generated and installed.
> Currently, only the host variant is provided.
> [1] https://github.com/alexcrichton/cargo-vendor
> +++ b/package/cargo/cargo.hash
> @@ -0,0 +1,8 @@
> +# Locally generated
> +sha256 a9d4291254a1d622d3c3cb942aaa56ab4059b8d04915c3af234f0362f14722e8 cargo-0.24.0.tar.gz
> +sha256 dc7240d60a869fa24a68c8734fb7c810c27cca0a6dad52df6279865e4e8e7fae rust-installer-4f994850808a572e2cc8d43f968893c8e942e9bf.tar.gz
> +sha256 a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2 LICENSE-APACHE
> +sha256 23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3 LICENSE-MIT
> +sha256 8bd89f9222dc80292f4107347103b693ac66f3a083371f0629ccf42338abe880 LICENSE-THIRD-PARTY
> +# From http://pkgs.fedoraproject.org/repo/pkgs/cargo/cargo-0.23.0-vendor.tar.xz/sha512
That should probably be 0.24.0?
> +CARGO_VERSION = 0.24.0
> +CARGO_SITE = $(call github,rust-lang,cargo,$(CARGO_VERSION))
> +CARGO_LICENSE = Apache-2.0 or MIT
> +CARGO_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
> +
> +CARGO_DEPS_SHA512 = 60c12ce49a53cf986490f5a5fdf606f0374677902edfdc4d48ab1ba6094f3f23efc59626cd3776649c9386a9cab2a60332e5693aad6acbcbb92132efdcf9fe21
> +CARGO_DEPS_SITE = http://pkgs.fedoraproject.org/repo/pkgs/cargo/$(CARGO_DEPS_SOURCE)/sha512/$(CARGO_DEPS_SHA512)
Is that the official location for this?
pkgs.fedoraproject.org is failing for me at the moment :/
--2018-02-05 11:25:50-- http://pkgs.fedoraproject.org/repo/pkgs/cargo/cargo-0.24.0-vendor.tar.xz/sha512/60c12ce49a53cf986490f5a5fdf606f0374677902edfdc4d48ab1ba6094f3f23efc59626cd3776649c9386a9cab2a60332e5693aad6acbcbb92132efdcf9fe21/cargo-0.24.0-vendor.tar.xz
Resolving pkgs.fedoraproject.org (pkgs.fedoraproject.org)... 209.132.181.4
Connecting to pkgs.fedoraproject.org (pkgs.fedoraproject.org)|209.132.181.4|:80... failed: No route to host.
Otherwise the series looks good to me and I would like to add it for
2018.02.
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Buildroot] [PATCH v10 08/10] cargo: new package
2018-02-05 10:26 ` Peter Korsgaard
@ 2018-02-05 13:11 ` Sam Voss
2018-02-05 13:58 ` Peter Korsgaard
1 sibling, 0 replies; 20+ messages in thread
From: Sam Voss @ 2018-02-05 13:11 UTC (permalink / raw)
To: buildroot
Eric, Peter,
On Mon, Feb 5, 2018 at 11:26 AM, Peter Korsgaard <peter@korsgaard.com> wrote:
>>>>>> "Eric" == Eric Le Bihan <eric.le.bihan.dev@free.fr> writes:
>
[snip]
> > +CARGO_DEPS_SHA512 = 60c12ce49a53cf986490f5a5fdf606f0374677902edfdc4d48ab1ba6094f3f23efc59626cd3776649c9386a9cab2a60332e5693aad6acbcbb92132efdcf9fe21
> > +CARGO_DEPS_SITE = http://pkgs.fedoraproject.org/repo/pkgs/cargo/$(CARGO_DEPS_SOURCE)/sha512/$(CARGO_DEPS_SHA512)
>
> Is that the official location for this?
>
> pkgs.fedoraproject.org is failing for me at the moment :/
I hopped into #fedora-admin and was told that pkgs was deprecated last
year, and due to some DoS mitigation was taken offline last week (I
didn't press if it was permanent).
In either case, it seems like this should using src.fedoraproject.org
as that is the permanent solution given to me.
Thanks,
Sam Voss
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Buildroot] [PATCH v10 08/10] cargo: new package
2018-02-05 10:26 ` Peter Korsgaard
2018-02-05 13:11 ` Sam Voss
@ 2018-02-05 13:58 ` Peter Korsgaard
1 sibling, 0 replies; 20+ messages in thread
From: Peter Korsgaard @ 2018-02-05 13:58 UTC (permalink / raw)
To: buildroot
>>>>> "Peter" == Peter Korsgaard <peter@korsgaard.com> writes:
Hi,
>> +CARGO_DEPS_SHA512 =
>> 60c12ce49a53cf986490f5a5fdf606f0374677902edfdc4d48ab1ba6094f3f23efc59626cd3776649c9386a9cab2a60332e5693aad6acbcbb92132efdcf9fe21
>> +CARGO_DEPS_SITE =
>> http://pkgs.fedoraproject.org/repo/pkgs/cargo/$(CARGO_DEPS_SOURCE)/sha512/$(CARGO_DEPS_SHA512)
> Is that the official location for this?
> pkgs.fedoraproject.org is failing for me at the moment :/
Committed after changing to src.fedoraproject.org, thanks.
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Buildroot] [PATCH v10 09/10] docs/manual: document cargo-based packages
2018-02-04 18:07 [Buildroot] [PATCH v10 00/10] Add support for the Rust programming language Eric Le Bihan
` (7 preceding siblings ...)
2018-02-04 18:07 ` [Buildroot] [PATCH v10 08/10] cargo: new package Eric Le Bihan
@ 2018-02-04 18:07 ` Eric Le Bihan
2018-02-05 10:29 ` Peter Korsgaard
2018-02-04 18:07 ` [Buildroot] [PATCH v10 10/10] support/testing: add tests for Rust Eric Le Bihan
2018-02-05 14:03 ` [Buildroot] [PATCH v10 00/10] Add support for the Rust programming language Peter Korsgaard
10 siblings, 1 reply; 20+ messages in thread
From: Eric Le Bihan @ 2018-02-04 18:07 UTC (permalink / raw)
To: buildroot
Add instructions for adding a package which uses Cargo as build system.
Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
---
docs/manual/adding-packages-cargo.txt | 110 ++++++++++++++++++++++++++++++++++
docs/manual/adding-packages.txt | 2 +
2 files changed, 112 insertions(+)
create mode 100644 docs/manual/adding-packages-cargo.txt
diff --git a/docs/manual/adding-packages-cargo.txt b/docs/manual/adding-packages-cargo.txt
new file mode 100644
index 0000000000..8de7c97cb9
--- /dev/null
+++ b/docs/manual/adding-packages-cargo.txt
@@ -0,0 +1,110 @@
+// -*- mode:doc; -*-
+// vim: set syntax=asciidoc:
+
+=== Integration of Cargo-based packages
+
+Cargo is the package manager for the Rust programming language. It allows the
+user to build programs or libraries written in Rust, but it also downloads and
+manages their dependencies, to ensure repeatable builds. Cargo packages are
+called "crates".
+
+[[cargo-package-tutorial]]
+
+==== Cargo-based package's +Config.in+ file
+
+The +Config.in+ file of Cargo-based package 'foo' should contain:
+
+---------------------------
+01: config BR2_PACKAGE_FOO
+02: bool "foo"
+03: depends on BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS
+04: select BR2_PACKAGE_HOST_CARGO
+05: help
+06: This is a comment that explains what foo is.
+07:
+08: http://foosoftware.org/foo/
+---------------------------
+
+==== Cargo-based package's +.mk+ file
+
+Buildroot does not (yet) provide a dedicated package infrastructure for
+Cargo-based packages. So, we will explain how to write a +.mk+ file for such a
+package. Let's start with an example:
+
+------------------------------
+01: ################################################################################
+02: #
+03: # foo
+04: #
+05: ################################################################################
+06:
+07: FOO_VERSION = 1.0
+08: FOO_SOURCE = foo-$(FOO_VERSION).tar.gz
+09: FOO_SITE = http://www.foosoftware.org/download
+10: FOO_LICENSE = GPLv3+
+11: FOO_LICENSE_FILES = COPYING
+12:
+13: FOO_DEPENDENCIES = host-cargo
+14:
+15: FOO_CARGO_ENV = CARGO_HOME=$(HOST_DIR)/share/cargo
+16: FOO_CARGO_MODE = $(if $(BR2_ENABLE_DEBUG),debug,release)
+17:
+18: FOO_BIN_DIR = target/$(RUST_TARGET_NAME)/$(FOO_CARGO_MODE)
+19:
+20: FOO_CARGO_OPTS = \
+21: --$(FOO_CARGO_MODE) \
+22: --target=$(RUST_TARGET_NAME) \
+23: --manifest-path=$(@D)/Cargo.toml
+24:
+25: define FOO_BUILD_CMDS
+26: $(TARGET_MAKE_ENV) $(FOO_CARGO_ENV) \
+27: cargo build $(FOO_CARGO_OPTS)
+28: endef
+29:
+30: define FOO_INSTALL_TARGET_CMDS
+31: $(INSTALL) -D -m 0755 $(@D)/$(FOO_BIN_DIR)/foo \
+32: $(TARGET_DIR)/usr/bin/foo
+33: endef
+34:
+35: $(eval $(generic-package))
+--------------------------------
+
+The Makefile starts with the definition of the standard variables for package
+declaration (lines 7 to 11).
+
+As seen in line 35, it is based on the
+xref:generic-package-tutorial[+generic-package+ infrastructure]. So, it defines
+the variables required by this particular infrastructure, where Cargo is
+invoked:
+
+* +FOO_BUILD_CMDS+: Cargo is invoked to perform the build. The options required
+ to configure the cross-compilation of the package are passed via
+ +FOO_CONF_OPTS+.
+
+* +FOO_INSTALL_TARGET_CMDS+: The binary executable generated is installed on
+ the target.
+
+In order to have Cargo available for the build, +FOO_DEPENDENCIES+ needs to
+contain +host-cargo+.
+
+To sum it up, to add a new Cargo-based package, the Makefile example can be
+copied verbatim then edited to replace all occurences of +FOO+ with the
+uppercase name of the new package and update the values of the standard
+variables.
+
+==== About Dependencies Management
+
+A crate can depend on other libraries from crates.io or git repositories, listed
+in its Cargo.toml file. Before starting a build, Cargo usually downloads
+automatically them. This step can also be performed independently, via the
++cargo fetch+ command.
+
+Cargo maintains a local cache of the registry index and of git checkouts of the
+crates, whose location is given by +$CARGO_HOME+. As seen in the package
+Makefile example at line 15, this environment variable is set to
++$(HOST_DIR)/share/cargo+.
+
+This dependency download mechanism is not convenient when performing an offline
+build, as Cargo will fail to fetch the dependencies. In that case, it is advised
+to generate a tarball of the dependencies using the +cargo vendor+ and add it to
++FOO_EXTRA_DOWNLOADS+.
diff --git a/docs/manual/adding-packages.txt b/docs/manual/adding-packages.txt
index e542124cf9..e8d40daee4 100644
--- a/docs/manual/adding-packages.txt
+++ b/docs/manual/adding-packages.txt
@@ -36,6 +36,8 @@ include::adding-packages-waf.txt[]
include::adding-packages-meson.txt[]
+include::adding-packages-cargo.txt[]
+
include::adding-packages-kernel-module.txt[]
include::adding-packages-asciidoc.txt[]
--
2.14.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [Buildroot] [PATCH v10 09/10] docs/manual: document cargo-based packages
2018-02-04 18:07 ` [Buildroot] [PATCH v10 09/10] docs/manual: document cargo-based packages Eric Le Bihan
@ 2018-02-05 10:29 ` Peter Korsgaard
0 siblings, 0 replies; 20+ messages in thread
From: Peter Korsgaard @ 2018-02-05 10:29 UTC (permalink / raw)
To: buildroot
>>>>> "Eric" == Eric Le Bihan <eric.le.bihan.dev@free.fr> writes:
> Add instructions for adding a package which uses Cargo as build system.
> Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
> ---
> docs/manual/adding-packages-cargo.txt | 110 ++++++++++++++++++++++++++++++++++
> docs/manual/adding-packages.txt | 2 +
> 2 files changed, 112 insertions(+)
> create mode 100644 docs/manual/adding-packages-cargo.txt
> diff --git a/docs/manual/adding-packages-cargo.txt b/docs/manual/adding-packages-cargo.txt
> new file mode 100644
> index 0000000000..8de7c97cb9
> --- /dev/null
> +++ b/docs/manual/adding-packages-cargo.txt
> @@ -0,0 +1,110 @@
> +// -*- mode:doc; -*-
> +// vim: set syntax=asciidoc:
> +
> +=== Integration of Cargo-based packages
> +
> +Cargo is the package manager for the Rust programming language. It allows the
> +user to build programs or libraries written in Rust, but it also downloads and
> +manages their dependencies, to ensure repeatable builds. Cargo packages are
> +called "crates".
> +
> +[[cargo-package-tutorial]]
> +
> +==== Cargo-based package's +Config.in+ file
> +
> +The +Config.in+ file of Cargo-based package 'foo' should contain:
> +
> +---------------------------
> +01: config BR2_PACKAGE_FOO
> +02: bool "foo"
> +03: depends on BR2_PACKAGE_HOST_RUSTC_ARCH_SUPPORTS
> +04: select BR2_PACKAGE_HOST_CARGO
> +05: help
> +06: This is a comment that explains what foo is.
The indentation here is wrong. It should be <tab>help and
<tab><space><space>This is a comment..
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Buildroot] [PATCH v10 10/10] support/testing: add tests for Rust
2018-02-04 18:07 [Buildroot] [PATCH v10 00/10] Add support for the Rust programming language Eric Le Bihan
` (8 preceding siblings ...)
2018-02-04 18:07 ` [Buildroot] [PATCH v10 09/10] docs/manual: document cargo-based packages Eric Le Bihan
@ 2018-02-04 18:07 ` Eric Le Bihan
2018-02-05 14:03 ` [Buildroot] [PATCH v10 00/10] Add support for the Rust programming language Peter Korsgaard
10 siblings, 0 replies; 20+ messages in thread
From: Eric Le Bihan @ 2018-02-04 18:07 UTC (permalink / raw)
To: buildroot
To test the support for the Rust language, the following tests are added:
- building Rust compiler and Cargo from source.
- installing a pre-built Rust compiler and building Cargo from source.
For each test, a Rust test program is built and installed in the root file
system of a ARM vexpress QEMU system. The test is declared OK if the program can
be run properly from the test system.
Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
---
support/testing/tests/package/test_rust.py | 107 +++++++++++++++++++++++++++++
1 file changed, 107 insertions(+)
create mode 100644 support/testing/tests/package/test_rust.py
diff --git a/support/testing/tests/package/test_rust.py b/support/testing/tests/package/test_rust.py
new file mode 100644
index 0000000000..8035f8b83a
--- /dev/null
+++ b/support/testing/tests/package/test_rust.py
@@ -0,0 +1,107 @@
+import os
+import tempfile
+import subprocess
+import shutil
+
+import infra.basetest
+
+
+class TestRustBase(infra.basetest.BRTest):
+
+ target = 'armv7-unknown-linux-gnueabihf'
+ crate = 'hello-world'
+
+ def login(self):
+ img = os.path.join(self.builddir, "images", "rootfs.cpio")
+ self.emulator.boot(arch="armv7",
+ kernel="builtin",
+ options=["-initrd", img])
+ self.emulator.login()
+
+ def build_test_prog(self):
+ hostdir = os.path.join(self.builddir, 'host')
+ env = os.environ.copy()
+ env["PATH"] = "{}:".format(os.path.join(hostdir, 'bin')) + env["PATH"]
+ env["CARGO_HOME"] = os.path.join(hostdir, 'usr', 'share', 'cargo')
+ env["RUST_TARGET_PATH"] = os.path.join(hostdir, 'etc', 'rustc')
+ cargo = os.path.join(hostdir, 'bin', 'cargo')
+ workdir = os.path.join(tempfile.mkdtemp(suffix='-br2-testing-rust'),
+ self.crate)
+ manifest = os.path.join(workdir, 'Cargo.toml')
+ prog = os.path.join(workdir, 'target', self.target, 'debug', self.crate)
+
+ cmd = [cargo, 'init', '--bin', '--vcs', 'none', '-vv', workdir]
+ ret = subprocess.call(cmd,
+ stdout=self.b.logfile,
+ stderr=self.b.logfile,
+ env=env)
+ if ret != 0:
+ raise SystemError("Cargo init failed")
+
+ cmd = [
+ cargo, 'build', '-vv', '--target', self.target,
+ '--manifest-path', manifest
+ ]
+ ret = subprocess.call(cmd,
+ stdout=self.b.logfile,
+ stderr=self.b.logfile,
+ env=env)
+ if ret != 0:
+ raise SystemError("Cargo build failed")
+
+ shutil.copy(prog, os.path.join(self.builddir, 'target', 'usr', 'bin'))
+ self.b.build()
+ shutil.rmtree(workdir)
+
+ def test_run(self):
+ self.build_test_prog()
+ self.login()
+ _, exit_code = self.emulator.run(self.crate)
+ self.assertEqual(exit_code, 0)
+
+
+class TestRustBin(TestRustBase):
+ config = \
+ """
+ BR2_arm=y
+ BR2_cortex_a9=y
+ BR2_ARM_ENABLE_NEON=y
+ BR2_ARM_ENABLE_VFP=y
+ BR2_TOOLCHAIN_EXTERNAL=y
+ BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+ BR2_SYSTEM_DHCP="eth0"
+ BR2_LINUX_KERNEL=y
+ BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+ BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.11.3"
+ BR2_LINUX_KERNEL_DEFCONFIG="vexpress"
+ BR2_LINUX_KERNEL_DTS_SUPPORT=y
+ BR2_LINUX_KERNEL_INTREE_DTS_NAME="vexpress-v2p-ca9"
+ BR2_TARGET_ROOTFS_CPIO=y
+ # BR2_TARGET_ROOTFS_TAR is not set
+ BR2_PACKAGE_HOST_CARGO=y
+ BR2_PACKAGE_HOST_RUSTC=y
+ """
+
+
+class TestRust(TestRustBase):
+ config = \
+ """
+ BR2_arm=y
+ BR2_cortex_a9=y
+ BR2_ARM_ENABLE_NEON=y
+ BR2_ARM_ENABLE_VFP=y
+ BR2_TOOLCHAIN_EXTERNAL=y
+ BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+ BR2_SYSTEM_DHCP="eth0"
+ BR2_LINUX_KERNEL=y
+ BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+ BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.11.3"
+ BR2_LINUX_KERNEL_DEFCONFIG="vexpress"
+ BR2_LINUX_KERNEL_DTS_SUPPORT=y
+ BR2_LINUX_KERNEL_INTREE_DTS_NAME="vexpress-v2p-ca9"
+ BR2_TARGET_ROOTFS_CPIO=y
+ # BR2_TARGET_ROOTFS_TAR is not set
+ BR2_PACKAGE_HOST_CARGO=y
+ BR2_PACKAGE_HOST_RUSTC=y
+ BR2_PACKAGE_HOST_RUST=y
+ """
--
2.14.3
^ permalink raw reply related [flat|nested] 20+ messages in thread* [Buildroot] [PATCH v10 00/10] Add support for the Rust programming language
2018-02-04 18:07 [Buildroot] [PATCH v10 00/10] Add support for the Rust programming language Eric Le Bihan
` (9 preceding siblings ...)
2018-02-04 18:07 ` [Buildroot] [PATCH v10 10/10] support/testing: add tests for Rust Eric Le Bihan
@ 2018-02-05 14:03 ` Peter Korsgaard
10 siblings, 0 replies; 20+ messages in thread
From: Peter Korsgaard @ 2018-02-05 14:03 UTC (permalink / raw)
To: buildroot
>>>>> "Eric" == Eric Le Bihan <eric.le.bihan.dev@free.fr> writes:
> This series adds support for the Rust programming language by adding the
> following packages:
> - rustc: a virtual package for the Rust compiler.
> - rust-bin: provides a pre-built version of rustc.
> - cargo-bin: provides a pre-built version of Rust package manager.
> - rust: builds rustc from source.
> - cargo: builds Rust package manager from source.
> Only the host variants are provided.
> The rustc virtual package is inspired by the mysql one.
> v9 -> v10:
> - add test cases in support/testing
> - add documentation about adding cargo-based packages
> - bump cargo to 0.24.0
> - bump rust to 1.23.0
> - bump cargo-bin to 0.24.0
> - bump rust-bin to 1.23.0
> - clarify origin of some hashes
> - reword some comments
> - use $(BR2_CMAKE_HOST_DEPENDENCY) wherever needed
> - move some options management from *.mk to Config.in
> v8 -> v9:
> - replace giant patch by post-extract hook
> - drop rust-cargo virtual package
> - explicitly enable SSL support in host-libcurl
> v7 -> v8:
> - replace cargo-bootstrap by cargo-bin
> - drop rust-bootstrap and use rust-bin instead
> - rust-bin and rust versions are the same
> - cargo-bin and cargo versions are the same
> - bump cargo to 0.23.0
> - bump rust to 1.22.1
> - add rust-cargo virtual package
> v6 -> v7:
> - add cargo 0.20.0
> - bump rust to 1.19.0
> - bump rust-bootstrap to 1.18.0
> - bump cargo-bootstrap to 0.19.0
> - bump rust-bin to 1.19.0
> - fix mips64 target name in rustc
> v5 -> v6:
> - bump rust to 1.18.0
> - bump rust-bootstrap to 1.17.0
> - bump rust-bin to 1.18.0
> v4 -> v5:
> - add rustc virtual package
> - add rust-bin, provider for rustc
> - rework rust to be a provider for rustc
> - rework some commit messages
> v3 -> v4:
> - bump rust to 1.16.0
> - bump rust-bootstrap to 1.15.1
> - add cargo-bootstrap
> - use built-in target specifications
> - drop external Python script to generate target specifications
> - enable support for PowerPC
> - expose host variant in menuconfig
> v2 -> v3:
> - bump rust to 1.10.0
> - rework and bump rust-bootstrap to 1.9.0
> - host-rust requires at least GCC 4.7 because of LLVM (suggested by R. Naour)
> - rust requires a glibc-based cross-compiler
> - rust requires GCC 5.x or above for Aarch64
> v1 -> v2:
> - bump rust to version 1.9.0.
> - drop patch for bzip2 support in host-python.
> - add package for jemalloc.
> - add dependency on host being a x86 machine.
> - add dependency on toolchain.
> - use dedicated package to provide bootstrapping binary: rust-bootstrap.
> - let ./configure find out host/build on its own.
> - remove entry from configuration menu.
> Eric Le Bihan (10):
> rustc: new virtual package
> rust-bin: new package
> cargo-bin: new package
> rust: new package
> libssh2: add host variant
> libhttpparser: add host variant
> libcurl: add host variant
> cargo: new package
> docs/manual: document cargo-based packages
> support/testing: add tests for Rust
Committed series, thanks!
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 20+ messages in thread