diff mbox series

[PATCHv4] package/bat: new package

Message ID 20220107090348.3947187-1-romain.naour@smile.fr
State Accepted
Headers show
Series [PATCHv4] package/bat: new package | expand

Commit Message

Romain Naour Jan. 7, 2022, 9:03 a.m. UTC
From: David Pierret <david.pierret@smile.fr>

bat is a cat(1) clone with syntax highlighting and Git integration.

Using the aarch64 ARM toolchain that use the prefix
"aarch64-none-linux-gnu-", we need to set CC_aarch64_unknown_linux_gnu
in the environment to provide the right toolchain prefix [1].
Otherwise the build fail because rust use aarch64-unknown-linux-gnu as
default toolchain prefix.

Indeed, the aarch64 ARM toolchain is not listed as supported toolchains
[2][3]. The build succeed when the aarch64 Linaro toolchain is used
(tuple "aarch64-unknown-linux-gnu-").

The problem occure during the package install step... For some reason
bat is rebuilt during this step. A similar behavior has been observed
for host-sentry-cli [4]. For now, only set CC_aarch64_unknown_linux_gnu
in INSTALL_TARGET_CMDS (hack).

Since we set CC_aarch64_unknown_linux_gnu, convert RUSTC_TARGET_NAME
aarch64-unknown-linux-gnu to aarch64_unknown_linux_gnu since bash
doesn't allow to minus characters in environement variables.

[1] https://github.com/rust-lang/rust/blob/c367798cfd3817ca6ae908ce675d1d99242af148/src/ci/docker/dist-aarch64-linux/Dockerfile#L29
[2] https://github.com/rust-lang/rust/blob/52d2c7ac948d6abdc18eb9e05a53d03ddcaffd98/src/librustc_target/spec/mod.rs#L492
[3] https://doc.rust-lang.org/nightly/rustc/platform-support.html
[4] https://lore.kernel.org/buildroot/20201210213122.035e149a@windsurf.home/

Signed-off-by: David Pierret <david.pierret@smile.fr>
Signed-off-by: Romain Naour <romain.naour@smile.fr>
[Romain: Use CC_$(RUSTC_TARGET_NAME)]
Signed-off-by: Romain Naour <romain.naour@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
----
bat supports syntax highlighting for a large number of programming
and markup languages. He can communicates with git to show
modifications with respect to the index.
For conveignance use, bat can pipe its own output to less if the
output is too large for one screen.

v4: Convert to cargo package infrastructure
    bump to version 0.18.3
    remove "select BR2_PACKAGE_NCURSES"
    Improve the commit log about the issue between the aarch64-linaro
    and the aarch64-ARM toolchains ("aarch64-none-linux-gnu-" vs "aarch64-unknown-linux-gnu-")
    See: https://doc.rust-lang.org/nightly/rustc/platform-support.html

    This patch needs the series "Support for Cargo and Go vendoring" v3
    http://lists.busybox.net/pipermail/buildroot/2022-January/632561.html

v3: remove "env" and use CC_$(subst -,_,$(RUSTC_TARGET_NAME))
    instead of CC_$(RUSTC_TARGET_NAME)

v1 -> v2
Add selection of less out of busybox for command line option
compatibility

bat: bump to version 0.18 & switch to cargo infra
---
 DEVELOPERS            |  3 +++
 package/Config.in     |  1 +
 package/bat/Config.in | 11 +++++++++++
 package/bat/bat.hash  |  4 ++++
 package/bat/bat.mk    | 12 ++++++++++++
 package/pkg-cargo.mk  |  1 +
 6 files changed, 32 insertions(+)
 create mode 100644 package/bat/Config.in
 create mode 100644 package/bat/bat.hash
 create mode 100644 package/bat/bat.mk

Comments

Thomas Petazzoni Jan. 7, 2022, 10:05 a.m. UTC | #1
Hello,

On Fri,  7 Jan 2022 10:03:48 +0100
Romain Naour <romain.naour@smile.fr> wrote:

> diff --git a/package/pkg-cargo.mk b/package/pkg-cargo.mk
> index bf1436a86b..e2fe104cf3 100644
> --- a/package/pkg-cargo.mk
> +++ b/package/pkg-cargo.mk
> @@ -110,6 +110,7 @@ ifndef $(2)_INSTALL_TARGET_CMDS
>  define $(2)_INSTALL_TARGET_CMDS
>  	cd $$(@D) && \
>  	$$(TARGET_MAKE_ENV) $$($(2)_CARGO_ENV) \
> +		CC_$$(subst -,_,$$(RUSTC_TARGET_NAME))=$$(TARGET_CC) \

But we don't even pass this variable at build time.. why would it be
needed at install time? Due to the fact that "bar" builds stuff during
the install step, I understand that we might need extra variable during
the installation step, but I would expect to only need variables that
are already passed during the build step.

Any idea?

Thomas
Romain Naour Jan. 7, 2022, 10:08 a.m. UTC | #2
Le 07/01/2022 à 11:05, Thomas Petazzoni a écrit :
> Hello,
> 
> On Fri,  7 Jan 2022 10:03:48 +0100
> Romain Naour <romain.naour@smile.fr> wrote:
> 
>> diff --git a/package/pkg-cargo.mk b/package/pkg-cargo.mk
>> index bf1436a86b..e2fe104cf3 100644
>> --- a/package/pkg-cargo.mk
>> +++ b/package/pkg-cargo.mk
>> @@ -110,6 +110,7 @@ ifndef $(2)_INSTALL_TARGET_CMDS
>>  define $(2)_INSTALL_TARGET_CMDS
>>  	cd $$(@D) && \
>>  	$$(TARGET_MAKE_ENV) $$($(2)_CARGO_ENV) \
>> +		CC_$$(subst -,_,$$(RUSTC_TARGET_NAME))=$$(TARGET_CC) \
> 
> But we don't even pass this variable at build time.. why would it be
> needed at install time? Due to the fact that "bar" builds stuff during
> the install step, I understand that we might need extra variable during
> the installation step, but I would expect to only need variables that
> are already passed during the build step.

It seems we just need to add $$(TARGET_CONFIGURE_OPTS) to _INSTALL_TARGET_CMDS

http://lists.busybox.net/pipermail/buildroot/2022-January/632613.html

> 
> Any idea?
> 
> Thomas
>
Thomas Petazzoni Jan. 7, 2022, 10:17 a.m. UTC | #3
Hello,

On Fri, 7 Jan 2022 11:08:21 +0100
Romain Naour <romain.naour@smile.fr> wrote:

> > But we don't even pass this variable at build time.. why would it be
> > needed at install time? Due to the fact that "bar" builds stuff during
> > the install step, I understand that we might need extra variable during
> > the installation step, but I would expect to only need variables that
> > are already passed during the build step.  
> 
> It seems we just need to add $$(TARGET_CONFIGURE_OPTS) to _INSTALL_TARGET_CMDS
> 
> http://lists.busybox.net/pipermail/buildroot/2022-January/632613.html

Ah, OK. This indeed we are passing at build time, but not at install
time currently. We can certainly add that at install time too. Though
this "build during install step" thing is a bit annoying...

Thomas
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index ff661e9357..99637c7ae3 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -673,6 +673,9 @@  F:	linux/linux-ext-ev3dev-linux-drivers.mk
 F:	package/brickd/
 F:	package/ev3dev-linux-drivers/
 
+N:	David Pierret <david.pierret@smile.fr>
+F:	package/bat/
+
 N:	Davide Viti <zinosat@gmail.com>
 F:	board/friendlyarm/nanopi-r1/
 F:	configs/friendlyarm_nanopi_r1_defconfig
diff --git a/package/Config.in b/package/Config.in
index a88f0a6849..98a4d4c5f3 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -2595,6 +2595,7 @@  menu "System tools"
 endmenu
 
 menu "Text editors and viewers"
+	source "package/bat/Config.in"
 	source "package/ed/Config.in"
 	source "package/joe/Config.in"
 	source "package/less/Config.in"
diff --git a/package/bat/Config.in b/package/bat/Config.in
new file mode 100644
index 0000000000..515eaf591a
--- /dev/null
+++ b/package/bat/Config.in
@@ -0,0 +1,11 @@ 
+config BR2_PACKAGE_BAT
+	bool "bat"
+	depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
+	select BR2_PACKAGE_HOST_RUSTC
+	# we need a full version of less
+	select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+	select BR2_PACKAGE_LESS
+	help
+	  A cat(1) clone with syntax highlighting and Git integration.
+
+	  https://github.com/sharkdp/bat
diff --git a/package/bat/bat.hash b/package/bat/bat.hash
new file mode 100644
index 0000000000..aa6c8d743d
--- /dev/null
+++ b/package/bat/bat.hash
@@ -0,0 +1,4 @@ 
+# Locally generated
+sha256  9c345788eb916777a60e7ff32031f1c92edc5565031e0c057bce860982768744  bat-0.18.3.tar.gz
+sha256  c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4  LICENSE-APACHE
+sha256  64de710b6309a7db5e44ad0af382300c7fb6f6d116d8ae32f0164e05db033068  LICENSE-MIT
diff --git a/package/bat/bat.mk b/package/bat/bat.mk
new file mode 100644
index 0000000000..9b619af172
--- /dev/null
+++ b/package/bat/bat.mk
@@ -0,0 +1,12 @@ 
+################################################################################
+#
+# bat
+#
+################################################################################
+
+BAT_VERSION = 0.18.3
+BAT_SITE = $(call github,sharkdp,bat,v$(BAT_VERSION))
+BAT_LICENSE = Apache-2.0 or MIT
+BAT_LICENSE_FILES = LICENSE-APACHE LICENSE-MIT
+
+$(eval $(cargo-package))
diff --git a/package/pkg-cargo.mk b/package/pkg-cargo.mk
index bf1436a86b..e2fe104cf3 100644
--- a/package/pkg-cargo.mk
+++ b/package/pkg-cargo.mk
@@ -110,6 +110,7 @@  ifndef $(2)_INSTALL_TARGET_CMDS
 define $(2)_INSTALL_TARGET_CMDS
 	cd $$(@D) && \
 	$$(TARGET_MAKE_ENV) $$($(2)_CARGO_ENV) \
+		CC_$$(subst -,_,$$(RUSTC_TARGET_NAME))=$$(TARGET_CC) \
 		cargo install \
 			--target $$(RUSTC_TARGET_NAME) \
 			--offline \