From 93701284e6e669388aef9c42a59d19a03e660689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9mi=20V=C3=A1nyi?= Date: Tue, 17 Mar 2020 13:12:54 +0100 Subject: [PATCH] Remove Makefile which ruins builds from vendor (#17013) ## What does this PR do? This PR adds the option to remove files from the vendor folder during `mage update`. ## Why is it important? `yacc` is triggered from time to time when `mage vendor` copies files in a particular order. It leads to build failures unexpectedly. --- dev-tools/mage/gomod.go | 13 ++++++++++++- libbeat/scripts/Makefile | 12 +++--------- vendor/github.com/yuin/gopher-lua/parse/Makefile | 4 ---- 3 files changed, 15 insertions(+), 14 deletions(-) delete mode 100644 vendor/github.com/yuin/gopher-lua/parse/Makefile diff --git a/dev-tools/mage/gomod.go b/dev-tools/mage/gomod.go index 9d785b47971..ae136665b1b 100644 --- a/dev-tools/mage/gomod.go +++ b/dev-tools/mage/gomod.go @@ -46,6 +46,9 @@ var ( }, }, } + filesToRemove = []string{ + filepath.Join("vendor", "github.com", "yuin", "gopher-lua", "parse", "Makefile"), + } ) // Vendor cleans up go.mod and copies the files not carried over from modules cache. @@ -75,7 +78,7 @@ func Vendor() error { // copy packages which require the whole tree for _, p := range copyAll { - path, err := gotool.ListModuleVendorDir(p.name) + path, err := gotool.ListModuleCacheDir(p.name) if err != nil { return err } @@ -90,5 +93,13 @@ func Vendor() error { } } } + + for _, p := range filesToRemove { + p = filepath.Join(repo.RootDir, p) + err = os.RemoveAll(p) + if err != nil { + return err + } + } return nil } diff --git a/libbeat/scripts/Makefile b/libbeat/scripts/Makefile index 941fc2f8cc4..97df237f194 100755 --- a/libbeat/scripts/Makefile +++ b/libbeat/scripts/Makefile @@ -134,20 +134,14 @@ include $(ES_BEATS)/dev-tools/make/mage.mk .DEFAULT_GOAL := ${BEAT_NAME} -${BEAT_NAME}: $(GOFILES_ALL) update-yacc-vendor ## @build build the beat application +${BEAT_NAME}: $(GOFILES_ALL) ## @build build the beat application go build $(GOBUILD_FLAGS) # Create test coverage binary -${BEAT_NAME}.test: $(GOFILES_ALL) update-yacc-vendor +${BEAT_NAME}.test: $(GOFILES_ALL) @go build -o /dev/null @go test $(RACE) -c -coverpkg ${GOPACKAGES_COMMA_SEP} -# Avoid running yacc to generate a parser for dependency. -.PHONY: update-yacc-vendor -update-yacc-vendor: - touch -c ../vendor/github.com/yuin/gopher-lua/parse/parser.go.y - touch -c ../vendor/github.com/yuin/gopher-lua/parse/parser.go - .PHONY: crosscompile crosscompile: ## @build Cross-compile beat for the OS'es specified in GOX_OS variable. The binaries are placed in the build/bin directory. crosscompile: $(GOFILES) @@ -200,7 +194,7 @@ ci: ## @build Shortcut for continuous integration. This should always run befor # Preparation for tests .PHONY: prepare-tests -prepare-tests: update-yacc-vendor +prepare-tests: mkdir -p ${COVERAGE_DIR} # gotestcover is needed to fetch coverage for multiple packages go ${INSTALL_CMD} ${COVERAGE_TOOL_REPO} diff --git a/vendor/github.com/yuin/gopher-lua/parse/Makefile b/vendor/github.com/yuin/gopher-lua/parse/Makefile deleted file mode 100644 index b5b69096086..00000000000 --- a/vendor/github.com/yuin/gopher-lua/parse/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -all : parser.go - -parser.go : parser.go.y - go tool yacc -o $@ parser.go.y; [ -f y.output ] && ( rm -f y.output )