From 20cd1176dd677301f2a90feb7b219e12fa04b993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Peso?= Date: Fri, 31 Mar 2023 10:27:43 +0200 Subject: [PATCH] New secret rudder (#232) After some name changing, MM_RUDDER_WRITE_KEY has become MM_RUDDER_PLUGINS_PROD. Fix custom.mk so we get the right data. --- Makefile | 24 ++++++++++++++++++++---- build/custom.mk | 12 ++++++++---- plugin.json | 2 +- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index bd6e1c03..6bd0c68a 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,8 @@ GOPATH ?= $(shell go env GOPATH) GO_TEST_FLAGS ?= -race GO_BUILD_FLAGS ?= MM_UTILITIES_DIR ?= ../mattermost-utilities +DEFAULT_GOOS := $(shell go env GOOS) +DEFAULT_GOARCH := $(shell go env GOARCH) export GO111MODULE=on @@ -22,6 +24,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. all: check-style test dist @@ -50,14 +58,22 @@ golangci-lint: @echo Running golangci-lint golangci-lint run ./... -## Builds the server, if it exists, including support for multiple 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; - 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 + 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 ## Ensures NPM dependencies are installed without having to run this all the time. diff --git a/build/custom.mk b/build/custom.mk index 2839dab0..1c9ce79f 100644 --- a/build/custom.mk +++ b/build/custom.mk @@ -1,5 +1,7 @@ # Include custom targets and environment variables here + + default: all i18n-extract-server: @@ -15,8 +17,10 @@ i18n-merge-server: @rm -f assets/i18n/translate.*.json @echo "Translations merged, please verify your "git diff" before you submit the changes" -ifndef MM_RUDDER_WRITE_KEY - MM_RUDDER_WRITE_KEY = 1d5bMvdrfWClLxgK1FvV3s4U1tg -endif -GO_BUILD_FLAGS += -ldflags '-X "github.com/mattermost/mattermost-plugin-api/experimental/telemetry.rudderWriteKey=$(MM_RUDDER_WRITE_KEY)"' +# 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=$(RUDDER_WRITE_KEY)"' diff --git a/plugin.json b/plugin.json index 64e90e7f..8ce06477 100644 --- a/plugin.json +++ b/plugin.json @@ -93,4 +93,4 @@ } ] } -} \ No newline at end of file +}