From 0c4dbfb58a72f8392ea66e101996afd06fdb2913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Peso?= Date: Thu, 30 Mar 2023 16:56:28 +0200 Subject: [PATCH] fix rudder key (#205) After some name changing, MM_RUDDER_WRITE_KEY has become MM_RUDDER_PLUGINS_PROD. Fix custom.mk so we get the right data. --- Makefile | 28 ++++++++++++++++++---------- build/custom.mk | 10 +++++++--- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index fb077bb9..eaf99353 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,8 @@ GO_TEST_FLAGS ?= -race GO_BUILD_FLAGS ?= MM_UTILITIES_DIR ?= ../mattermost-utilities DLV_DEBUG_PORT := 2346 +DEFAULT_GOOS := $(shell go env GOOS) +DEFAULT_GOARCH := $(shell go env GOARCH) export GO111MODULE=on @@ -28,6 +30,12 @@ ifneq ($(wildcard build/custom.mk),) include build/custom.mk endif +ifneq ($(MM_DEBUG),) + GO_BUILD_GCFLAGS = -gcflags "all=-N -l" +else + GO_BUILD_GCFLAGS = +endif + ## Checks the code style, tests, builds and bundles the plugin. .PHONY: all all: check-style test dist @@ -57,21 +65,21 @@ ifneq ($(HAS_SERVER),) golangci-lint run ./... endif -## Builds the server, if it exists, for all supported architectures. +## Builds the server, if it exists, for all supported architectures, unless MM_SERVICESETTINGS_ENABLEDEVELOPER is set .PHONY: server server: ifneq ($(HAS_SERVER),) +ifneq ($(MM_DEBUG),) + $(info DEBUG mode is on; to disable, unset MM_DEBUG) +endif mkdir -p server/dist; -ifeq ($(MM_DEBUG),) - cd server && env GOOS=linux GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -o dist/plugin-linux-amd64; - cd server && env GOOS=darwin GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -o dist/plugin-darwin-amd64; - cd server && env GOOS=windows GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -o dist/plugin-windows-amd64.exe; +ifneq ($(MM_SERVICESETTINGS_ENABLEDEVELOPER),) + @echo Building plugin only for $(DEFAULT_GOOS)-$(DEFAULT_GOARCH) because MM_SERVICESETTINGS_ENABLEDEVELOPER is enabled + cd server && env CGO_ENABLED=0 $(GO) build $(GO_BUILD_FLAGS) $(GO_BUILD_GCFLAGS) -trimpath -o dist/plugin-$(DEFAULT_GOOS)-$(DEFAULT_GOARCH); else - $(info DEBUG mode is on; to disable, unset MM_DEBUG) - - cd server && env GOOS=darwin GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -gcflags "all=-N -l" -o dist/plugin-darwin-amd64; - cd server && env GOOS=linux GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -gcflags "all=-N -l" -o dist/plugin-linux-amd64; - cd server && env GOOS=windows GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -gcflags "all=-N -l" -o dist/plugin-windows-amd64.exe; + cd server && env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) $(GO_BUILD_GCFLAGS) -trimpath -o dist/plugin-linux-amd64; + cd server && env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) $(GO_BUILD_GCFLAGS) -trimpath -o dist/plugin-darwin-amd64; + cd server && env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) $(GO_BUILD_GCFLAGS) -trimpath -o dist/plugin-windows-amd64.exe; endif endif diff --git a/build/custom.mk b/build/custom.mk index d0d3fd67..db31e67d 100644 --- a/build/custom.mk +++ b/build/custom.mk @@ -1,5 +1,9 @@ # Include custom targets and environment variables here -ifndef MM_RUDDER_WRITE_KEY - MM_RUDDER_WRITE_KEY = 1d5bMvdrfWClLxgK1FvV3s4U1tg + +# If there's no MM_RUDDER_PLUGINS_PROD, add DEV data +RUDDER_WRITE_KEY = 1d5bMvdrfWClLxgK1FvV3s4U1tg +ifdef MM_RUDDER_PLUGINS_PROD + RUDDER_WRITE_KEY = $(MM_RUDDER_PLUGINS_PROD) endif -GO_BUILD_FLAGS += -ldflags '-X "github.com/mattermost/mattermost-plugin-api/experimental/telemetry.rudderWriteKey=$(MM_RUDDER_WRITE_KEY)"' + +GO_BUILD_FLAGS += -ldflags '-X "github.com/mattermost/mattermost-plugin-api/experimental/telemetry.rudderWriteKey=$(RUDDER_WRITE_KEY)"'