From 9f0470b28ee3843800716dac93af92f76aa893d2 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Fri, 8 Dec 2023 11:42:33 -0500 Subject: [PATCH] Build plugins for Windows ARM64 We start building the 'builder' and 'test' plugins for Windows ARM64. We also default new plugin projects to also building for Windows ARM64. The builder plugin will publish the Windows ARM64 binaries and include them in the plugin inventory DB if they are present. If they are not present, the builder plugin will ignore them with a printout as is done for the other two ARM64 builds. Signed-off-by: Marc Khouzam --- cmd/plugin/builder/command/cli_compile.go | 11 +++++++++++ .../plugintemplates/plugin-tooling.mk.tmpl | 2 +- pkg/cli/arch.go | 17 ++++++++++++----- plugin-tooling.mk | 2 +- test/sample-plugin/plugin-tooling.mk | 2 +- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/cmd/plugin/builder/command/cli_compile.go b/cmd/plugin/builder/command/cli_compile.go index 49da6ba7c..1a2b89a14 100644 --- a/cmd/plugin/builder/command/cli_compile.go +++ b/cmd/plugin/builder/command/cli_compile.go @@ -427,6 +427,17 @@ var archMap = map[cli.Arch]targetBuilder{ }, } }, + cli.WinARM64: func(pluginName, outPath string) target { + return target{ + env: []string{ + "GOARCH=arm64", + "GOOS=windows", + }, + args: []string{ + "-o", filepath.Join(outPath, cli.MakeArtifactName(pluginName, cli.WinARM64)), + }, + } + }, } func (p *plugin) compile() error { diff --git a/cmd/plugin/builder/template/plugintemplates/plugin-tooling.mk.tmpl b/cmd/plugin/builder/template/plugintemplates/plugin-tooling.mk.tmpl index d9d8e6d8b..eb97d32ae 100644 --- a/cmd/plugin/builder/template/plugintemplates/plugin-tooling.mk.tmpl +++ b/cmd/plugin/builder/template/plugintemplates/plugin-tooling.mk.tmpl @@ -36,7 +36,7 @@ PLUGIN_DEBUG=false endif # Add supported OS-ARCHITECTURE combinations here -PLUGIN_BUILD_OS_ARCH ?= linux-amd64 windows-amd64 darwin-amd64 darwin-arm64 linux-arm64 +PLUGIN_BUILD_OS_ARCH ?= linux-amd64 windows-amd64 darwin-amd64 linux-arm64 darwin-arm64 windows-arm64 # Paths and Directory information ROOT_DIR := $(shell git rev-parse --show-toplevel) diff --git a/pkg/cli/arch.go b/pkg/cli/arch.go index f1d0aa4a2..2392e58db 100644 --- a/pkg/cli/arch.go +++ b/pkg/cli/arch.go @@ -10,13 +10,18 @@ import ( ) var ( - // MinOSArch defines minimum OS/ARCH combination for which plugin needs to be built + // MinOSArch defines the minimum OS/ARCH combinations for which plugins need to be built MinOSArch = []Arch{LinuxAMD64, DarwinAMD64, WinAMD64} - // AllOSArch defines all OS/ARCH combination for which plugin can be built - AllOSArch = []Arch{LinuxAMD64, DarwinAMD64, WinAMD64, DarwinARM64, LinuxARM64} + // AllOSArch defines all OS/ARCH combinations for which plugins can be built + AllOSArch = []Arch{LinuxAMD64, DarwinAMD64, WinAMD64, LinuxARM64, DarwinARM64, WinARM64} - GOOS = runtime.GOOS + // GOOS is the current go os. Defaults to runtime.GOOS but could be overridden. + // The CLI code should always this variable instead of runtime.GOOS. + GOOS = runtime.GOOS + // GOARCH is the current go architecture. Defaults to runtime.GOARCH but is overridden + // for scenarios like installing AMD64 plugins on an ARM64 machine using emulation. + // The CLI code should always this variable instead of runtime.GOARCH. GOARCH = runtime.GOARCH ) @@ -35,7 +40,7 @@ func SetArch(a Arch) { // IsWindows tells if an arch is windows. func (a Arch) IsWindows() bool { - if a == Win386 || a == WinAMD64 { + if a == Win386 || a == WinAMD64 || a == WinARM64 { return true } return false @@ -79,4 +84,6 @@ const ( Win386 Arch = "windows_386" // WinAMD64 arch. WinAMD64 Arch = "windows_amd64" + // WinARM64 arch. + WinARM64 Arch = "windows_arm64" ) diff --git a/plugin-tooling.mk b/plugin-tooling.mk index 8ea0e06fa..7d68e8430 100644 --- a/plugin-tooling.mk +++ b/plugin-tooling.mk @@ -40,7 +40,7 @@ PLUGIN_DEBUG=false endif # Add supported OS-ARCHITECTURE combinations here -PLUGIN_BUILD_OS_ARCH ?= linux-amd64 windows-amd64 darwin-amd64 darwin-arm64 linux-arm64 +PLUGIN_BUILD_OS_ARCH ?= linux-amd64 windows-amd64 darwin-amd64 linux-arm64 darwin-arm64 windows-arm64 # Paths and Directory information ROOT_DIR := $(shell git rev-parse --show-toplevel) diff --git a/test/sample-plugin/plugin-tooling.mk b/test/sample-plugin/plugin-tooling.mk index 43cc4e06e..762103137 100644 --- a/test/sample-plugin/plugin-tooling.mk +++ b/test/sample-plugin/plugin-tooling.mk @@ -36,7 +36,7 @@ PLUGIN_DEBUG=false endif # Add supported OS-ARCHITECTURE combinations here -PLUGIN_BUILD_OS_ARCH ?= linux-amd64 windows-amd64 darwin-amd64 darwin-arm64 linux-arm64 +PLUGIN_BUILD_OS_ARCH ?= linux-amd64 windows-amd64 darwin-amd64 linux-arm64 darwin-arm64 windows-arm64 # Paths and Directory information SAMPLE_PLUGIN_ROOT_DIR := $(shell pwd)