From 5ac256d0f48b1ad2c719b63a4d514112cb7d9a0f Mon Sep 17 00:00:00 2001 From: Anton Tayanovskyy Date: Mon, 13 Jan 2025 14:08:50 -0500 Subject: [PATCH] make --- provider-ci/test-providers/eks/Makefile | 31 ++++++++++++------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/provider-ci/test-providers/eks/Makefile b/provider-ci/test-providers/eks/Makefile index e18d7bad1..1fe8ce605 100644 --- a/provider-ci/test-providers/eks/Makefile +++ b/provider-ci/test-providers/eks/Makefile @@ -212,12 +212,12 @@ lint_provider.fix: # `make provider_no_deps` builds the provider binary directly, without ensuring that # `cmd/pulumi-resource-eks/schema.json` is valid and up to date. # To create a release ready binary, you should use `make provider`. -build_provider_cmd = cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(PROVIDER) -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) +build_provider_cmd = cd provider && CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o "$(1)" -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) provider: bin/$(PROVIDER) provider_no_deps: - $(call build_provider_cmd) + $(call build_provider_cmd,$(WORKING_DIR)/bin/$(PROVIDER)) bin/$(PROVIDER): .make/schema - $(call build_provider_cmd) + $(call build_provider_cmd,$(WORKING_DIR)/bin/$(PROVIDER)) .PHONY: provider provider_no_deps test: export PATH := $(WORKING_DIR)/bin:$(PATH) @@ -304,25 +304,24 @@ SKIP_SIGNING ?= # These targets assume that the schema-embed.json exists - it's generated by tfgen. # We disable CGO to ensure that the binary is statically linked. -bin/linux-amd64/$(PROVIDER): TARGET := linux-amd64 -bin/linux-arm64/$(PROVIDER): TARGET := linux-arm64 -bin/darwin-amd64/$(PROVIDER): TARGET := darwin-amd64 -bin/darwin-arm64/$(PROVIDER): TARGET := darwin-arm64 -bin/windows-amd64/$(PROVIDER).exe: TARGET := windows-amd64 +bin/linux-amd64/$(PROVIDER): export GOOS := linux +bin/linux-amd64/$(PROVIDER): export GOARCH := amd64 +bin/linux-arm64/$(PROVIDER): export GOOS := linux +bin/linux-arm64/$(PROVIDER): export GOARCH := arm64 +bin/darwin-amd64/$(PROVIDER): export GOOS := darwin +bin/darwin-amd64/$(PROVIDER): export GOARCH := amd64 +bin/darwin-arm64/$(PROVIDER): export GOOS := darwin +bin/darwin-arm64/$(PROVIDER): export GOARCH := arm64 +bin/windows-amd64/$(PROVIDER).exe: export GOOS := windows +bin/windows-amd64/$(PROVIDER).exe: export GOARCH := amd64 bin/%/$(PROVIDER) bin/%/$(PROVIDER).exe: bin/jsign-6.0.jar - @# check the TARGET is set - @test $(TARGET) - @cd provider && \ - export GOOS=$$(echo "$(TARGET)" | cut -d "-" -f 1) && \ - export GOARCH=$$(echo "$(TARGET)" | cut -d "-" -f 2) && \ - export CGO_ENABLED=0 && \ - go build -o "${WORKING_DIR}/$@" $(PULUMI_PROVIDER_BUILD_PARALLELISM) -ldflags "$(LDFLAGS)" "$(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER)" + $(call build_provider_cmd,$(WORKING_DIR)/$@) @# Only sign windows binary if fully configured. @# Test variables set by joining with | between and looking for || showing at least one variable is empty. @# Move the binary to a temporary location and sign it there to avoid the target being up-to-date if signing fails. @set -e; \ - if [[ "${TARGET}" = "windows-amd64" && "${SKIP_SIGNING}" != "true" ]]; then \ + if [[ "${GOOS}-${GOARCH}" = "windows-amd64" && "${SKIP_SIGNING}" != "true" ]]; then \ if [[ "|${AZURE_SIGNING_CLIENT_ID}|${AZURE_SIGNING_CLIENT_SECRET}|${AZURE_SIGNING_TENANT_ID}|${AZURE_SIGNING_KEY_VAULT_URI}|" == *"||"* ]]; then \ echo "Can't sign windows binaries as required configuration not set: AZURE_SIGNING_CLIENT_ID, AZURE_SIGNING_CLIENT_SECRET, AZURE_SIGNING_TENANT_ID, AZURE_SIGNING_KEY_VAULT_URI"; \ echo "To rebuild with signing delete the unsigned $@ and rebuild with the fixed configuration"; \