From 912f23e81f132fae3623987cc696add23062981f Mon Sep 17 00:00:00 2001 From: Daniel Bradley Date: Fri, 22 Nov 2024 09:47:28 +0000 Subject: [PATCH] Add file target for provider target If we make the file target depend on _no_deps, it will never be up-to-date. If we make _no_deps depend on the file target it will pull in all dependencies. Instead we extract the build provider command to a variable so it's re-used from both the file target and _no_deps versions. --- .../internal/pkg/templates/bridged-provider/Makefile | 9 ++++++--- provider-ci/test-providers/acme/Makefile | 9 ++++++--- provider-ci/test-providers/aws/Makefile | 9 ++++++--- provider-ci/test-providers/cloudflare/Makefile | 9 ++++++--- provider-ci/test-providers/docker/Makefile | 9 ++++++--- 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/provider-ci/internal/pkg/templates/bridged-provider/Makefile b/provider-ci/internal/pkg/templates/bridged-provider/Makefile index 4246ccbeba..64634df4fc 100644 --- a/provider-ci/internal/pkg/templates/bridged-provider/Makefile +++ b/provider-ci/internal/pkg/templates/bridged-provider/Makefile @@ -174,10 +174,13 @@ lint_provider.fix: # `make provider_no_deps` builds the provider binary directly, without ensuring that # `cmd/pulumi-resource-#{{ .Config.Provider }}#/schema.json` is valid and up to date. # To create a release ready binary, you should use `make provider`. +.PHONY: provider provider_no_deps +build_provider_cmd = cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(PROVIDER) -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) +provider: bin/$(PROVIDER) provider_no_deps: - (cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(PROVIDER) -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER)) - -provider: tfgen provider_no_deps + $(call build_provider_cmd) +bin/$(PROVIDER): .make/schema + $(call build_provider_cmd) test: export PATH := $(WORKING_DIR)/bin:$(PATH) test: diff --git a/provider-ci/test-providers/acme/Makefile b/provider-ci/test-providers/acme/Makefile index 481ca4fcc1..a4c1924c90 100644 --- a/provider-ci/test-providers/acme/Makefile +++ b/provider-ci/test-providers/acme/Makefile @@ -138,10 +138,13 @@ lint_provider.fix: # `make provider_no_deps` builds the provider binary directly, without ensuring that # `cmd/pulumi-resource-acme/schema.json` is valid and up to date. # To create a release ready binary, you should use `make provider`. +.PHONY: provider provider_no_deps +build_provider_cmd = cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(PROVIDER) -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) +provider: bin/$(PROVIDER) provider_no_deps: - (cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(PROVIDER) -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER)) - -provider: tfgen provider_no_deps + $(call build_provider_cmd) +bin/$(PROVIDER): .make/schema + $(call build_provider_cmd) test: export PATH := $(WORKING_DIR)/bin:$(PATH) test: diff --git a/provider-ci/test-providers/aws/Makefile b/provider-ci/test-providers/aws/Makefile index fe06626130..063c3a17c8 100644 --- a/provider-ci/test-providers/aws/Makefile +++ b/provider-ci/test-providers/aws/Makefile @@ -148,10 +148,13 @@ lint_provider.fix: # `make provider_no_deps` builds the provider binary directly, without ensuring that # `cmd/pulumi-resource-aws/schema.json` is valid and up to date. # To create a release ready binary, you should use `make provider`. +.PHONY: provider provider_no_deps +build_provider_cmd = cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(PROVIDER) -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) +provider: bin/$(PROVIDER) provider_no_deps: - (cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(PROVIDER) -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER)) - -provider: tfgen provider_no_deps + $(call build_provider_cmd) +bin/$(PROVIDER): .make/schema + $(call build_provider_cmd) test: export PATH := $(WORKING_DIR)/bin:$(PATH) test: diff --git a/provider-ci/test-providers/cloudflare/Makefile b/provider-ci/test-providers/cloudflare/Makefile index d11a9b7d5e..dc8896d7d6 100644 --- a/provider-ci/test-providers/cloudflare/Makefile +++ b/provider-ci/test-providers/cloudflare/Makefile @@ -148,10 +148,13 @@ lint_provider.fix: # `make provider_no_deps` builds the provider binary directly, without ensuring that # `cmd/pulumi-resource-cloudflare/schema.json` is valid and up to date. # To create a release ready binary, you should use `make provider`. +.PHONY: provider provider_no_deps +build_provider_cmd = cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(PROVIDER) -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) +provider: bin/$(PROVIDER) provider_no_deps: - (cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(PROVIDER) -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER)) - -provider: tfgen provider_no_deps + $(call build_provider_cmd) +bin/$(PROVIDER): .make/schema + $(call build_provider_cmd) test: export PATH := $(WORKING_DIR)/bin:$(PATH) test: diff --git a/provider-ci/test-providers/docker/Makefile b/provider-ci/test-providers/docker/Makefile index 645d420c9a..5f63f283c2 100644 --- a/provider-ci/test-providers/docker/Makefile +++ b/provider-ci/test-providers/docker/Makefile @@ -151,10 +151,13 @@ lint_provider.fix: # `make provider_no_deps` builds the provider binary directly, without ensuring that # `cmd/pulumi-resource-docker/schema.json` is valid and up to date. # To create a release ready binary, you should use `make provider`. +.PHONY: provider provider_no_deps +build_provider_cmd = cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(PROVIDER) -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER) +provider: bin/$(PROVIDER) provider_no_deps: - (cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM) -o $(WORKING_DIR)/bin/$(PROVIDER) -ldflags "$(LDFLAGS)" $(PROJECT)/$(PROVIDER_PATH)/cmd/$(PROVIDER)) - -provider: tfgen provider_no_deps + $(call build_provider_cmd) +bin/$(PROVIDER): .make/schema + $(call build_provider_cmd) test: export PATH := $(WORKING_DIR)/bin:$(PATH) test: