diff mbox series

[3/4] package/go-bin: new package

Message ID 20221017151726.44005-4-thomas.perale@mind.be
State Superseded
Headers show
Series Add support for using a pre-compiled Go compiler | expand

Commit Message

Thomas Perale Oct. 17, 2022, 3:17 p.m. UTC
This package provides a pre-built version of the go compiler for the
host target.
This enable the user to select between the pre-built and the compiled
version of the go compiler. The pre-built version will be used by
default when a go compiler is required.

The virtual package 'goc' creates a menu that let the user select which
variant of the go compiler to use.

The supported host platform for the pre-built compiler are actually the
same as the one for 'go-bootstrap' no further verification are required
than the one already in place.

For now GO_BIN_VERSION and GO_VERSION are set the same by hand but in
next version this variable should be in common. Because the order of the
'.mk' file is not guaranteed this will be investigated in a next patch.

Signed-off-by: Thomas Perale <thomas.perale@mind.be>
---
 package/Config.in.host        |  1 +
 package/go-bin/Config.in.host |  5 +++++
 package/go-bin/go-bin.hash    |  4 ++++
 package/go-bin/go-bin.mk      | 20 ++++++++++++++++++++
 package/goc/Config.in.host    | 26 +++++++++++++++++++++++++-
 5 files changed, 55 insertions(+), 1 deletion(-)
 create mode 100644 package/go-bin/Config.in.host
 create mode 100644 package/go-bin/go-bin.hash
 create mode 100644 package/go-bin/go-bin.mk
diff mbox series

Patch

diff --git a/package/Config.in.host b/package/Config.in.host
index 8c44ff0cb4..95b59bdacc 100644
--- a/package/Config.in.host
+++ b/package/Config.in.host
@@ -37,6 +37,7 @@  menu "Host utilities"
 	source "package/genpart/Config.in.host"
 	source "package/gnupg/Config.in.host"
 	source "package/go/Config.in.host"
+	source "package/go-bin/Config.in.host"
 	source "package/go-bootstrap/Config.in.host"
 	source "package/goc/Config.in.host"
 	source "package/google-breakpad/Config.in.host"
diff --git a/package/go-bin/Config.in.host b/package/go-bin/Config.in.host
new file mode 100644
index 0000000000..392060584f
--- /dev/null
+++ b/package/go-bin/Config.in.host
@@ -0,0 +1,5 @@ 
+config BR2_PACKAGE_HOST_GO_BIN_HOST_ARCH
+	string
+	default 386      if BR2_HOSTARCH = "x86"
+	default amd64    if BR2_HOSTARCH = "x86_64"
+	default arm64    if BR2_HOSTARCH = "arm"
diff --git a/package/go-bin/go-bin.hash b/package/go-bin/go-bin.hash
new file mode 100644
index 0000000000..91456d3e9a
--- /dev/null
+++ b/package/go-bin/go-bin.hash
@@ -0,0 +1,4 @@ 
+# sha256 checksum from https://go.dev/dl/
+sha256  9acc57342400c5b0c2da07b5b01b50da239dd4a7fad41a1fb56af8363ef4133f  go1.19.1.linux-386.tar.gz
+sha256  acc512fbab4f716a8f97a8b3fbaa9ddd39606a28be6c2515ef7c6c6311acffde  go1.19.1.linux-amd64.tar.gz
+sha256  49960821948b9c6b14041430890eccee58c76b52e2dbaafce971c3c38d43df9f  go1.19.1.linux-arm64.tar.gz
diff --git a/package/go-bin/go-bin.mk b/package/go-bin/go-bin.mk
new file mode 100644
index 0000000000..cf2db90532
--- /dev/null
+++ b/package/go-bin/go-bin.mk
@@ -0,0 +1,20 @@ 
+################################################################################
+#
+# go-bin
+#
+################################################################################
+
+GO_BIN_VERSION = 1.19.1
+GO_BIN_SITE = https://go.dev/dl
+GO_BIN_LICENSE = BSD-3-Clause
+GO_BIN_LICENSE_FILES = LICENSE
+
+HOST_GO_BIN_PROVIDES = host-goc
+
+HOST_GO_BIN_SOURCE = go$(GO_BIN_VERSION).linux-$(call qstrip, $(BR2_PACKAGE_HOST_GO_BIN_HOST_ARCH)).tar.gz
+
+define HOST_GO_BIN_INSTALL_CMDS
+	$(HOST_GO_INSTALL_CMDS)
+endef
+
+$(eval $(host-generic-package))
diff --git a/package/goc/Config.in.host b/package/goc/Config.in.host
index b0266b50ea..0bde50982f 100644
--- a/package/goc/Config.in.host
+++ b/package/goc/Config.in.host
@@ -8,8 +8,32 @@  config BR2_PACKAGE_HOST_GOC
 
 if BR2_PACKAGE_HOST_GOC
 
+choice
+	prompt "Go compiler variant"
+	default BR2_PACKAGE_HOST_GO_BIN
+	help
+	  Select a Go compiler variant.
+
+	  Default to 'host-go-bin'.
+
+config BR2_PACKAGE_HOST_GO
+	bool "host go"
+	depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
+	help
+	  This package will build the go compiler for the host.
+
+config BR2_PACKAGE_HOST_GO_BIN
+	bool "host go (pre-built)"
+	help
+	  This package will install pre-built versions of the compiler
+	  for the host.
+
+endchoice
+
 config BR2_PACKAGE_PROVIDES_HOST_GOC
 	string
-	default "host-go"
+	# Default to host-go-bin
+	default "host-go-bin" if BR2_PACKAGE_HOST_GO_BIN
+	default "host-go" if BR2_PACKAGE_HOST_GO
 
 endif