Skip to content

Commit

Permalink
Build plugins for Windows ARM64 (#611)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
marckhouzam authored Dec 21, 2023
1 parent a8d192a commit ac8d95e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
11 changes: 11 additions & 0 deletions cmd/plugin/builder/command/cli_compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 12 additions & 5 deletions pkg/cli/arch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand All @@ -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
Expand Down Expand Up @@ -79,4 +84,6 @@ const (
Win386 Arch = "windows_386"
// WinAMD64 arch.
WinAMD64 Arch = "windows_amd64"
// WinARM64 arch.
WinARM64 Arch = "windows_arm64"
)
2 changes: 1 addition & 1 deletion plugin-tooling.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/sample-plugin/plugin-tooling.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ac8d95e

Please sign in to comment.