<commit_before># This Makefile is mainly useful for cross-compilation
# In order to be able to cross-compile you need to have
# built GO for all the compilation targets.
# Under Ubuntu Linux those are already available in the repo:
#  sudo apt-get install golang-$GOOS-$GOARCH

.PHONY: cross-compile clean install

cross-compile:
	mkdir -p build
# Linux 32bit:
	GOOS=linux GOARCH=386 go build -o build/mocleaner-linux32 mocleaner.go
# Linux 64bit:
	GOOS=linux GOARCH=amd64 go build -o build/mocleaner-linux64 mocleaner.go
# Windows 32bit:
	GOOS=windows GOARCH=386 go build -o build/mocleaner-win32.exe mocleaner.go
# Windows 64bit:
	GOOS=windows GOARCH=amd64 go build -o build/mocleaner-win64.exe mocleaner.go
# MacOSX 64bit:
	GOOS=darwin GOARCH=amd64 go build -o build/mocleaner-darwin64 mocleaner.go

clean:
	rm -rf build/*

# Some standard commands though the original go commands are shorter :-)
test:
	go test

install:
	go install<commit_msg>Adds automatic upload to Makefile functions<commit_after># This Makefile is mainly useful for cross-compilation
# and upload to the GitHub release sections
# It is based on https://github.com/aktau/github-release/Makefile
# In order to be able to cross-compile you need to have
# built GO for all the compilation targets.
# Under Ubuntu Linux those are already available in the repo:
#  $ sudo apt-get install golang-$GOOS-$GOARCH
# For upload you need to have github-release installed
#  $ go get github.com/aktau/github-release

LAST_TAG := $(shell git describe --abbrev=0 --tags)

USER := dietmarw
EXECUTABLE := mocleaner
GITHUB_RELEASE = github-release

# only include the amd64 binaries, otherwise the github release will become
# too big
UNIX_EXECUTABLES := \
	darwin/amd64/$(EXECUTABLE) \
	freebsd/386/$(EXECUTABLE) \
	freebsd/amd64/$(EXECUTABLE) \
	linux/386/$(EXECUTABLE) \
	linux/amd64/$(EXECUTABLE)
WIN_EXECUTABLES := \
	windows/amd64/$(EXECUTABLE).exe

COMPRESSED_EXECUTABLES=$(UNIX_EXECUTABLES:%=%.tar.xz) $(WIN_EXECUTABLES:%.exe=%.zip)
COMPRESSED_EXECUTABLE_TARGETS=$(COMPRESSED_EXECUTABLES:%=build/%)

UPLOAD_CMD = $(GITHUB_RELEASE) upload -u $(USER) -r $(EXECUTABLE) -t $(LAST_TAG) -n $(subst /,-,$(FILE)) -f build/$(FILE)

all: $(EXECUTABLE)

# 386
build/darwin/386/$(EXECUTABLE):
	GOARCH=386 GOOS=darwin go build -o "$@"
build/freebsd/386/$(EXECUTABLE):
	GOARCH=386 GOOS=freebsd go build -o "$@"
build/linux/386/$(EXECUTABLE):
	GOARCH=386 GOOS=linux go build -o "$@"
build/windows/386/$(EXECUTABLE):
	GOARCH=386 GOOS=windows go build -o "$@"

# amd64
build/freebsd/amd64/$(EXECUTABLE):
	GOARCH=amd64 GOOS=freebsd go build -o "$@"
build/darwin/amd64/$(EXECUTABLE):
	GOARCH=amd64 GOOS=darwin go build -o "$@"
build/linux/amd64/$(EXECUTABLE):
	GOARCH=amd64 GOOS=linux go build -o "$@"
build/windows/amd64/$(EXECUTABLE).exe:
	GOARCH=amd64 GOOS=windows go build -o "$@"

# compressed artifacts, makes a huge difference (Go executable is ~9MB,
# after compressing ~2MB)
%.tar.xz: %
	tar -Jcvf "$<.tar.xz" "$<"
%.zip: %.exe
	zip -j "$@" "$<"

# git tag -a v$(RELEASE) -m 'release $(RELEASE)'
release: $(EXECUTABLE) $(COMPRESSED_EXECUTABLE_TARGETS)
	git push && git push --tags
	 $(GITHUB_RELEASE) release -u $(USER) -r $(EXECUTABLE) \
		-t $(LAST_TAG) -n $(LAST_TAG) || true
	$(foreach FILE,$(COMPRESSED_EXECUTABLES),$(UPLOAD_CMD);)

# install and/or update all dependencies, run this from the project directory
# go get -u ./...
# go test -i ./
dep:
	go list -f '{{join .Deps "\n"}}' | xargs go list -e -f '{{if not .Standard}}{{.ImportPath}}{{end}}' | xargs go get -u

$(EXECUTABLE): dep
	go build -o "$@"

install:
	go install

clean:
#	rm go-app || true
	rm $(EXECUTABLE) || true
	rm -rf build/

.PHONY: clean release dep install
{'fraction_non_alphanumeric': 0.1394907908992416, 'fraction_numerical': 0.02600216684723727, 'mean_word_length': 4.438880706921944, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1228301', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1341, 'n_words': 390}