Skip to content

Commit

Permalink
Remove Makefile which ruins builds from vendor (#17013) (#17053)
Browse files Browse the repository at this point in the history
This PR adds the option to remove files from the vendor folder during `mage update`.

`yacc` is triggered from time to time when `mage vendor` copies files in a particular order. It leads to build failures unexpectedly.
(cherry picked from commit 9370128)
  • Loading branch information
kvch authored Mar 17, 2020
1 parent 16681f6 commit 0f31732
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
13 changes: 12 additions & 1 deletion dev-tools/mage/gomod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
11 changes: 3 additions & 8 deletions libbeat/scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,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

.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)
Expand Down Expand Up @@ -194,7 +189,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}
Expand Down
4 changes: 0 additions & 4 deletions vendor/github.com/yuin/gopher-lua/parse/Makefile

This file was deleted.

0 comments on commit 0f31732

Please sign in to comment.