<commit_before>#!/bin/bash

set -e

CWD=`pwd`

echo "Downloading CORE.json"
curl https://raw.githubusercontent.com/nsip/registration-data-set/master/core.json > harness/schemas/core.json
echo "Downloading gnatsd"
go get github.com/nats-io/gnatsd

do_build() {
	mkdir -p $OUTPUT
	cd ../../nats-io/gnatsd
	GOOS="$GOOS" GOARCH="$GOARCH" go build -ldflags="$LDFLAGS" -o $OUTPUT/$GNATS
	cd $CWD
	cd ./harness
	go get
	GOOS="$GOOS" GOARCH="$GOARCH" go build -ldflags="$LDFLAGS" -o $OUTPUT/$HARNESS
	cd ..
	rsync -a harness/nias.toml harness/public harness/schemas harness/schoolslist harness/templates $OUTPUT/
}

do_shells() {
	cp bin/gonias.sh $OUTPUT/
	cp bin/shutdown.sh $OUTPUT/
}

do_bats() {
	cp bin/gonias.bat $OUTPUT/
}

do_upx() {
	upx $OUTPUT/$GNATS
	upx $OUTPUT/$HARNESS
}

do_goupx() {
	goupx $OUTPUT/$GNATS
	goupx $OUTPUT/$HARNESS
}

do_zip() {
	cd $OUTPUT
	cd ..
	zip -qr ../$ZIP go-nias
	cd $CWD
}

build_mac64() {
	# MAC OS X (64 only)
	echo "Building Mac binaries..."
	LDFLAGS="-s -w"
	OUTPUT=$CWD/build/Mac/go-nias
	GNATS=gnatsd
	HARNESS=harness
	ZIP=go-nias-Mac.zip
	do_build
	do_upx
	do_zip
	echo "...all Mac binaries built..."
}


build_windows64() {
	# WINDOWS 64
	echo "Building Windows64 binaries..."
	GOOS=windows
	GOARCH=amd64
	LDFLAGS="-s -w"
	OUTPUT=$CWD/build/Win64/go-nias
	GNATS=gnatsd.exe
	HARNESS=harness.exe
	ZIP=go-nias-Win64.zip
	do_build
	do_zip
	echo "...all Windows64 binaries built..."
}

build_windows32() {
	# WINDOWS 32
	echo "Building Windows32 binaries..."
	GOOS=windows
	GOARCH=386
	LDFLAGS="-s -w"
	OUTPUT=$CWD/build/Win32/go-nias
	GNATS=gnatsd.exe
	HARNESS=harness.exe
	ZIP=go-nias-Win32.zip
	do_build
	do_upx
	do_zip
	echo "...all Windows32 binaries built..."
}

build_linux64() {
	# LINUX 64
	echo "Building Linux64 binaries..."
	GOOS=linux
	GOARCH=amd64
	LDFLAGS="-s -w"
	OUTPUT=$CWD/build/Linux64/go-nias
	GNATS=gnatsd
	HARNESS=harness
	ZIP=go-nias-Linux64.zip
	do_build
	do_goupx
	do_zip
	echo "...all Linux64 binaries built..."
}

build_linux32() {
	# LINUX 32
	echo "Building Linux32 binaries..."
	GOOS=linux
	GOARCH=386
	LDFLAGS="-s -w"
	OUTPUT=$CWD/build/Linux64/go-nias
	GNATS=gnatsd
	HARNESS=harness
	ZIP=go-nias-Linux32.zip
	do_build
	do_goupx
	do_zip
	echo "...all Linux32 binaries built..."
}

# TODO ARM
# GOOS=linux GOARCH=arm GOARM=7 go build -o $CWD/build/LinuxArm7/go-nias/aggregator

build_mac64
build_windows64
build_windows32
build_linux64
build_linux32
<commit_msg>Build shells and bat files<commit_after>#!/bin/bash

set -e

CWD=`pwd`

echo "Downloading CORE.json"
curl https://raw.githubusercontent.com/nsip/registration-data-set/master/core.json > harness/schemas/core.json
echo "Downloading gnatsd"
go get github.com/nats-io/gnatsd

do_build() {
	mkdir -p $OUTPUT
	cd ../../nats-io/gnatsd
	GOOS="$GOOS" GOARCH="$GOARCH" go build -ldflags="$LDFLAGS" -o $OUTPUT/$GNATS
	cd $CWD
	cd ./harness
	go get
	GOOS="$GOOS" GOARCH="$GOARCH" go build -ldflags="$LDFLAGS" -o $OUTPUT/$HARNESS
	cd ..
	rsync -a harness/nias.toml harness/public harness/schemas harness/schoolslist harness/templates $OUTPUT/
}

do_shells() {
	cp bin/gonias.sh $OUTPUT/
	cp bin/shutdown.sh $OUTPUT/
}

do_bats() {
	cp bin/gonias.bat $OUTPUT/
}

do_upx() {
	upx $OUTPUT/$GNATS
	upx $OUTPUT/$HARNESS
}

do_goupx() {
	goupx $OUTPUT/$GNATS
	goupx $OUTPUT/$HARNESS
}

do_zip() {
	cd $OUTPUT
	cd ..
	zip -qr ../$ZIP go-nias
	cd $CWD
}

build_mac64() {
	# MAC OS X (64 only)
	echo "Building Mac binaries..."
	LDFLAGS="-s -w"
	OUTPUT=$CWD/build/Mac/go-nias
	GNATS=gnatsd
	HARNESS=harness
	ZIP=go-nias-Mac.zip
	do_build
	do_upx
	do_shells
	do_zip
	echo "...all Mac binaries built..."
}


build_windows64() {
	# WINDOWS 64
	echo "Building Windows64 binaries..."
	GOOS=windows
	GOARCH=amd64
	LDFLAGS="-s -w"
	OUTPUT=$CWD/build/Win64/go-nias
	GNATS=gnatsd.exe
	HARNESS=harness.exe
	ZIP=go-nias-Win64.zip
	do_build
	do_bats
	do_zip
	echo "...all Windows64 binaries built..."
}

build_windows32() {
	# WINDOWS 32
	echo "Building Windows32 binaries..."
	GOOS=windows
	GOARCH=386
	LDFLAGS="-s -w"
	OUTPUT=$CWD/build/Win32/go-nias
	GNATS=gnatsd.exe
	HARNESS=harness.exe
	ZIP=go-nias-Win32.zip
	do_build
	do_upx
	do_bats
	do_zip
	echo "...all Windows32 binaries built..."
}

build_linux64() {
	# LINUX 64
	echo "Building Linux64 binaries..."
	GOOS=linux
	GOARCH=amd64
	LDFLAGS="-s -w"
	OUTPUT=$CWD/build/Linux64/go-nias
	GNATS=gnatsd
	HARNESS=harness
	ZIP=go-nias-Linux64.zip
	do_build
	do_goupx
	do_shells
	do_zip
	echo "...all Linux64 binaries built..."
}

build_linux32() {
	# LINUX 32
	echo "Building Linux32 binaries..."
	GOOS=linux
	GOARCH=386
	LDFLAGS="-s -w"
	OUTPUT=$CWD/build/Linux64/go-nias
	GNATS=gnatsd
	HARNESS=harness
	ZIP=go-nias-Linux32.zip
	do_build
	do_goupx
	do_shells
	do_zip
	echo "...all Linux32 binaries built..."
}

# TODO ARM
# GOOS=linux GOARCH=arm GOARM=7 go build -o $CWD/build/LinuxArm7/go-nias/aggregator

build_mac64
build_windows64
build_windows32
build_linux64
build_linux32

{'fraction_non_alphanumeric': 0.14332115306536744, 'fraction_numerical': 0.030044660982541615, 'mean_word_length': 3.751205400192864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '578056', 'n_tokens_mistral': 2320, 'n_tokens_neox': 2116, 'n_words': 431}