@@ -5,7 +5,7 @@ ORG := pulumi
55PROJECT := github.com/$(ORG ) /pulumi-$(PACK )
66PROVIDER_PATH := provider/v5
77VERSION_PATH := $(PROVIDER_PATH ) /pkg/version.Version
8- TFGEN := pulumi-tfgen-$(PACK )
8+ CODEGEN := pulumi-tfgen-$(PACK )
99PROVIDER := pulumi-resource-$(PACK )
1010JAVA_GEN := pulumi-java-gen
1111TESTPARALLELISM := 10
@@ -14,11 +14,17 @@ PULUMI_PROVIDER_BUILD_PARALLELISM ?=
1414PULUMI_CONVERT := 1
1515PULUMI_MISSING_DOCS_ERROR := true
1616
17+ PULUMICTL_VERSION := v0.0.46
18+ PULUMICTL := $(shell which pulumictl || \
19+ (test ! -e $(WORKING_DIR ) /bin/pulumictl && \
20+ GOPATH="$(WORKING_DIR ) " go install "github.com/pulumi/pulumictl/cmd/pulumictl@$(PULUMICTL_VERSION ) "; \
21+ echo "$(WORKING_DIR ) /bin/puluimctl") )
22+
1723# Override during CI using `make [TARGET] PROVIDER_VERSION=""` or by setting a PROVIDER_VERSION environment variable
1824# Local & branch builds will just used this fixed default version unless specified
1925PROVIDER_VERSION ?= 5.0.0-alpha.0+dev
2026# Use this normalised version everywhere rather than the raw input to ensure consistency.
21- VERSION_GENERIC = $(shell pulumictl convert-version --language generic --version "$(PROVIDER_VERSION ) ")
27+ VERSION_GENERIC = $(shell $( PULUMICTL ) convert-version --language generic --version "$(PROVIDER_VERSION ) ")
2228
2329# Strips debug information from the provider binary to reduce its size and speed up builds
2430LDFLAGS_STRIP_SYMBOLS =-s -w
@@ -95,8 +101,8 @@ GEN_ENVS := PULUMI_HOME=$(GEN_PULUMI_HOME) PULUMI_CONVERT_EXAMPLES_CACHE_DIR=$(G
95101generate_dotnet : .make/generate_dotnet
96102build_dotnet : .make/build_dotnet
97103.make/generate_dotnet : export PATH := $(WORKING_DIR ) /.pulumi/bin:$(PATH )
98- .make/generate_dotnet : .make/install_plugins bin/$(TFGEN )
99- $(GEN_ENVS ) $(WORKING_DIR ) /bin/$(TFGEN ) dotnet --out sdk/dotnet/
104+ .make/generate_dotnet : .make/install_plugins bin/$(CODEGEN )
105+ $(GEN_ENVS ) $(WORKING_DIR ) /bin/$(CODEGEN ) dotnet --out sdk/dotnet/
100106 cd sdk/dotnet/ && \
101107 printf " module fake_dotnet_module // Exclude this directory from Go tools\n\ngo 1.17\n" > go.mod && \
102108 echo " $( VERSION_GENERIC) " > version.txt
@@ -109,8 +115,8 @@ build_dotnet: .make/build_dotnet
109115generate_go : .make/generate_go
110116build_go : .make/build_go
111117.make/generate_go : export PATH := $(WORKING_DIR ) /.pulumi/bin:$(PATH )
112- .make/generate_go : .make/install_plugins bin/$(TFGEN )
113- $(GEN_ENVS ) $(WORKING_DIR ) /bin/$(TFGEN ) go --out sdk/go/
118+ .make/generate_go : .make/install_plugins bin/$(CODEGEN )
119+ $(GEN_ENVS ) $(WORKING_DIR ) /bin/$(CODEGEN ) go --out sdk/go/
114120 @touch $@
115121.make/build_go : .make/generate_go
116122 cd sdk && go list " $$ (grep -e " ^module" go.mod | cut -d ' ' -f 2)/go/..." | xargs -I {} bash -c ' go build {} && go clean -i {}'
@@ -136,8 +142,8 @@ build_java: .make/build_java
136142generate_nodejs : .make/generate_nodejs
137143build_nodejs : .make/build_nodejs
138144.make/generate_nodejs : export PATH := $(WORKING_DIR ) /.pulumi/bin:$(PATH )
139- .make/generate_nodejs : .make/install_plugins bin/$(TFGEN )
140- $(GEN_ENVS ) $(WORKING_DIR ) /bin/$(TFGEN ) nodejs --out sdk/nodejs/
145+ .make/generate_nodejs : .make/install_plugins bin/$(CODEGEN )
146+ $(GEN_ENVS ) $(WORKING_DIR ) /bin/$(CODEGEN ) nodejs --out sdk/nodejs/
141147 printf " module fake_nodejs_module // Exclude this directory from Go tools\n\ngo 1.17\n" > sdk/nodejs/go.mod
142148 @touch $@
143149.make/build_nodejs : .make/generate_nodejs
@@ -151,8 +157,8 @@ build_nodejs: .make/build_nodejs
151157generate_python : .make/generate_python
152158build_python : .make/build_python
153159.make/generate_python : export PATH := $(WORKING_DIR ) /.pulumi/bin:$(PATH )
154- .make/generate_python : .make/install_plugins bin/$(TFGEN )
155- $(GEN_ENVS ) $(WORKING_DIR ) /bin/$(TFGEN ) python --out sdk/python/
160+ .make/generate_python : .make/install_plugins bin/$(CODEGEN )
161+ $(GEN_ENVS ) $(WORKING_DIR ) /bin/$(CODEGEN ) python --out sdk/python/
156162 printf " module fake_python_module // Exclude this directory from Go tools\n\ngo 1.17\n" > sdk/python/go.mod
157163 cp README.md sdk/python/
158164 @touch $@
@@ -168,8 +174,8 @@ build_python: .make/build_python
168174.PHONY : generate_python build_python
169175# Run the bridge's registry-docs command to generated the content of the installation docs/ folder at provider repo root
170176build_registry_docs : .make/build_registry_docs
171- .make/build_registry_docs : .make/install_plugins bin/$(TFGEN )
172- bin/$(TFGEN ) registry-docs --out $(WORKING_DIR ) /docs
177+ .make/build_registry_docs : .make/install_plugins bin/$(CODEGEN )
178+ bin/$(CODEGEN ) registry-docs --out $(WORKING_DIR ) /docs
173179 @touch $@
174180.PHONY : build_registry_docs
175181
@@ -199,7 +205,7 @@ install_nodejs_sdk: .make/install_nodejs_sdk
199205install_python_sdk :
200206.PHONY : install_dotnet_sdk install_go_sdk install_java_sdk install_nodejs_sdk install_python_sdk
201207
202- # Install Pulumi plugins required for TFGen to resolve references
208+ # Install Pulumi plugins required for CODEGEN to resolve references
203209install_plugins : .make/install_plugins
204210.make/install_plugins : export PULUMI_HOME := $(WORKING_DIR ) /.pulumi
205211.make/install_plugins : export PATH := $(WORKING_DIR ) /.pulumi/bin:$(PATH )
@@ -222,12 +228,12 @@ lint_provider.fix:
222228# `make provider_no_deps` builds the provider binary directly, without ensuring that
223229# `cmd/pulumi-resource-cloudflare/schema.json` is valid and up to date.
224230# To create a release ready binary, you should use `make provider`.
225- build_provider_cmd = cd provider && go build $(PULUMI_PROVIDER_BUILD_PARALLELISM ) -o $( WORKING_DIR ) /bin/ $( PROVIDER ) -ldflags "$(LDFLAGS ) " $(PROJECT ) /$(PROVIDER_PATH ) /cmd/$(PROVIDER )
231+ build_provider_cmd = cd provider && CGO_ENABLED=0 go build $(PULUMI_PROVIDER_BUILD_PARALLELISM ) -o " $( 1 ) " -ldflags "$(LDFLAGS ) " $(PROJECT ) /$(PROVIDER_PATH ) /cmd/$(PROVIDER )
226232provider : bin/$(PROVIDER )
227233provider_no_deps :
228- $(call build_provider_cmd)
234+ $(call build_provider_cmd, $( WORKING_DIR ) /bin/ $( PROVIDER ) )
229235bin/$(PROVIDER ) : .make/schema
230- $(call build_provider_cmd)
236+ $(call build_provider_cmd, $( WORKING_DIR ) /bin/ $( PROVIDER ) )
231237.PHONY : provider provider_no_deps
232238
233239test : export PATH := $(WORKING_DIR ) /bin:$(PATH )
@@ -253,13 +259,13 @@ tfgen_no_deps: .make/schema
253259.make/schema : export PULUMI_CONVERT_EXAMPLES_CACHE_DIR := $(WORKING_DIR ) /.pulumi/examples-cache
254260.make/schema : export PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION := $(PULUMI_CONVERT )
255261.make/schema : export PULUMI_MISSING_DOCS_ERROR := $(PULUMI_MISSING_DOCS_ERROR )
256- .make/schema : bin/$(TFGEN ) .make/install_plugins .make/upstream
257- $(WORKING_DIR ) /bin/$(TFGEN ) schema --out provider/cmd/$(PROVIDER )
262+ .make/schema : bin/$(CODEGEN ) .make/install_plugins .make/upstream
263+ $(WORKING_DIR ) /bin/$(CODEGEN ) schema --out provider/cmd/$(PROVIDER )
258264 (cd provider && VERSION=$( VERSION_GENERIC) go generate cmd/$( PROVIDER) /main.go)
259265 @touch $@
260- tfgen_build_only : bin/$(TFGEN )
261- bin/$(TFGEN ) : provider/* .go provider/go.* .make/upstream
262- (cd provider && go build $( PULUMI_PROVIDER_BUILD_PARALLELISM) -o $( WORKING_DIR) /bin/$( TFGEN ) -ldflags " $( LDFLAGS_PROJ_VERSION) $( LDFLAGS_EXTRAS) " $( PROJECT) /$( PROVIDER_PATH) /cmd/$( TFGEN ) )
266+ tfgen_build_only : bin/$(CODEGEN )
267+ bin/$(CODEGEN ) : provider/* .go provider/go.* .make/upstream
268+ (cd provider && go build $( PULUMI_PROVIDER_BUILD_PARALLELISM) -o $( WORKING_DIR) /bin/$( CODEGEN ) -ldflags " $( LDFLAGS_PROJ_VERSION) $( LDFLAGS_EXTRAS) " $( PROJECT) /$( PROVIDER_PATH) /cmd/$( CODEGEN ) )
263269.PHONY : tfgen schema tfgen_no_deps tfgen_build_only
264270
265271# Apply patches to the upstream submodule, if it exists
@@ -273,7 +279,7 @@ endif
273279.PHONY : upstream
274280
275281bin/pulumi-java-gen : .pulumi-java-gen.version
276- pulumictl download-binary -n pulumi-language-java -v v$(shell cat .pulumi-java-gen.version) -r pulumi/pulumi-java
282+ $( PULUMICTL ) download-binary -n pulumi-language-java -v v$(shell cat .pulumi-java-gen.version) -r pulumi/pulumi-java
277283
278284# To make an immediately observable change to .ci-mgmt.yaml:
279285#
@@ -305,7 +311,7 @@ ci-mgmt: .ci-mgmt.yaml
305311
306312# Start debug server for tfgen
307313debug_tfgen :
308- dlv --listen=:2345 --headless=true --api-version=2 exec $(WORKING_DIR ) /bin/$(TFGEN ) -- schema --out provider/cmd/$(PROVIDER )
314+ dlv --listen=:2345 --headless=true --api-version=2 exec $(WORKING_DIR ) /bin/$(CODEGEN ) -- schema --out provider/cmd/$(PROVIDER )
309315.PHONY : debug_tfgen
310316
311317# Provider cross-platform build & packaging
@@ -319,25 +325,24 @@ SKIP_SIGNING ?=
319325
320326# These targets assume that the schema-embed.json exists - it's generated by tfgen.
321327# We disable CGO to ensure that the binary is statically linked.
322- bin/linux-amd64/$(PROVIDER ) : TARGET := linux-amd64
323- bin/linux-arm64/$(PROVIDER ) : TARGET := linux-arm64
324- bin/darwin-amd64/$(PROVIDER ) : TARGET := darwin-amd64
325- bin/darwin-arm64/$(PROVIDER ) : TARGET := darwin-arm64
326- bin/windows-amd64/$(PROVIDER ) .exe : TARGET := windows-amd64
328+ bin/linux-amd64/$(PROVIDER ) : export GOOS := linux
329+ bin/linux-amd64/$(PROVIDER ) : export GOARCH := amd64
330+ bin/linux-arm64/$(PROVIDER ) : export GOOS := linux
331+ bin/linux-arm64/$(PROVIDER ) : export GOARCH := arm64
332+ bin/darwin-amd64/$(PROVIDER ) : export GOOS := darwin
333+ bin/darwin-amd64/$(PROVIDER ) : export GOARCH := amd64
334+ bin/darwin-arm64/$(PROVIDER ) : export GOOS := darwin
335+ bin/darwin-arm64/$(PROVIDER ) : export GOARCH := arm64
336+ bin/windows-amd64/$(PROVIDER ) .exe : export GOOS := windows
337+ bin/windows-amd64/$(PROVIDER ) .exe : export GOARCH := amd64
327338bin/% /$(PROVIDER ) bin/% /$(PROVIDER ) .exe : bin/jsign-6.0.jar
328- @# check the TARGET is set
329- @test $(TARGET )
330- @cd provider && \
331- export GOOS=$$(echo "$(TARGET ) " | cut -d "-" -f 1 ) && \
332- export GOARCH=$$(echo "$(TARGET ) " | cut -d "-" -f 2 ) && \
333- export CGO_ENABLED=0 && \
334- go build -o " ${WORKING_DIR} /$@ " $(PULUMI_PROVIDER_BUILD_PARALLELISM ) -ldflags " $( LDFLAGS) " " $( PROJECT) /$( PROVIDER_PATH) /cmd/$( PROVIDER) "
339+ $(call build_provider_cmd,$(WORKING_DIR ) /$@ )
335340
336341 @# Only sign windows binary if fully configured.
337342 @# Test variables set by joining with | between and looking for || showing at least one variable is empty.
338343 @# Move the binary to a temporary location and sign it there to avoid the target being up-to-date if signing fails.
339344 @set -e; \
340- if [[ "${TARGET }" = "windows-amd64" && "${SKIP_SIGNING}" != "true" ]]; then \
345+ if [[ "${GOOS}-${GOARCH }" = "windows-amd64" && "${SKIP_SIGNING}" != "true" ]]; then \
341346 if [[ "|${AZURE_SIGNING_CLIENT_ID}|${AZURE_SIGNING_CLIENT_SECRET}|${AZURE_SIGNING_TENANT_ID}|${AZURE_SIGNING_KEY_VAULT_URI}|" == *"||"* ]]; then \
342347 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"; \
343348 echo "To rebuild with signing delete the unsigned $@ and rebuild with the fixed configuration"; \
0 commit comments