From fa6b7e55a8dbbf67e6b0b9b5c319364e3a5ee05d Mon Sep 17 00:00:00 2001 From: Jason Dellaluce Date: Mon, 17 Jan 2022 10:24:20 +0000 Subject: [PATCH] build: remove debug flags from release go plugins Signed-off-by: Jason Dellaluce Co-authored-by: Leonardo Grasso --- Makefile | 4 +++- plugins/cloudtrail/Makefile | 19 +++++++++++++------ plugins/dummy/Makefile | 19 +++++++++++++------ plugins/json/Makefile | 19 +++++++++++++------ 4 files changed, 42 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 9bfbea7e..eec5c45c 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ CURL = curl FALCOSECURITY_LIBS_REVISION=e25e44b3ba4cb90ba9ac75bf747978e41fb6b221 +DEBUG = 1 OUTPUT_DIR := output SOURCE_DIR := plugins ARCH ?=$(shell uname -m) @@ -31,7 +32,7 @@ all: plugin_info.h $(plugins) .PHONY: $(plugins) $(plugins): - cd plugins/$@ && make + cd plugins/$@ && make DEBUG=$(DEBUG) .PHONY: clean clean: clean/plugin_info.h $(plugins-clean) clean/packages clean/build/utils/version @@ -67,6 +68,7 @@ $(plugins-packages): all build/utils/version cp -r plugins/$(PLUGIN_NAME)/README.md $(OUTPUT_DIR)/$(PLUGIN_NAME)/ tar -zcvf $(OUTPUT_DIR)/$(PLUGIN_NAME)-$(PLUGIN_VERSION)-${ARCH}.tar.gz -C ${OUTPUT_DIR}/$(PLUGIN_NAME) . +release/%: DEBUG=0 release/%: plugin_info.h clean/% % build/utils/version $(eval PLUGIN_NAME := $(shell basename $@)) $(eval PLUGIN_PATH := plugins/$(PLUGIN_NAME)/lib$(PLUGIN_NAME).so) diff --git a/plugins/cloudtrail/Makefile b/plugins/cloudtrail/Makefile index ef6b6b29..9072af8b 100755 --- a/plugins/cloudtrail/Makefile +++ b/plugins/cloudtrail/Makefile @@ -12,14 +12,21 @@ # SHELL=/bin/bash -o pipefail - GO ?= go -all: libcloudtrail.so +NAME := cloudtrail +OUTPUT := lib$(NAME).so -clean: - rm -f *.so *.h +ifeq ($(DEBUG), 1) + GODEBUGFLAGS= GODEBUG=cgocheck=2 +else + GODEBUGFLAGS= GODEBUG=cgocheck=0 +endif -libcloudtrail.so: cloudtrail.go extract.go source.go - GODEBUG=cgocheck=2 $(GO) build -buildmode=c-shared -o libcloudtrail.so *.go +all: $(OUTPUT) + +clean: + @rm -f *.so *.h +$(OUTPUT): *.go + @$(GODEBUGFLAGS) $(GO) build -buildmode=c-shared -o $(OUTPUT) \ No newline at end of file diff --git a/plugins/dummy/Makefile b/plugins/dummy/Makefile index e4ddb1af..df5c23f4 100755 --- a/plugins/dummy/Makefile +++ b/plugins/dummy/Makefile @@ -12,14 +12,21 @@ # SHELL=/bin/bash -o pipefail - GO ?= go -all: libdummy.so +NAME := dummy +OUTPUT := lib$(NAME).so -clean: - rm -f *.so *.h +ifeq ($(DEBUG), 1) + GODEBUGFLAGS= GODEBUG=cgocheck=2 +else + GODEBUGFLAGS= GODEBUG=cgocheck=0 +endif -libdummy.so: dummy.go - GODEBUG=cgocheck=2 $(GO) build -buildmode=c-shared -o libdummy.so *.go +all: $(OUTPUT) + +clean: + @rm -f *.so *.h +$(OUTPUT): *.go + @$(GODEBUGFLAGS) $(GO) build -buildmode=c-shared -o $(OUTPUT) \ No newline at end of file diff --git a/plugins/json/Makefile b/plugins/json/Makefile index f243de82..6420ac9b 100755 --- a/plugins/json/Makefile +++ b/plugins/json/Makefile @@ -12,14 +12,21 @@ # SHELL=/bin/bash -o pipefail - GO ?= go -all: libjson.so +NAME := json +OUTPUT := lib$(NAME).so -clean: - rm -f *.h *.so +ifeq ($(DEBUG), 1) + GODEBUGFLAGS= GODEBUG=cgocheck=2 +else + GODEBUGFLAGS= GODEBUG=cgocheck=0 +endif -libjson.so: json.go - GODEBUG=cgocheck=2 $(GO) build -buildmode=c-shared -o libjson.so *.go +all: $(OUTPUT) + +clean: + @rm -f *.so *.h +$(OUTPUT): *.go + @$(GODEBUGFLAGS) $(GO) build -buildmode=c-shared -o $(OUTPUT) \ No newline at end of file