#!/bin/sh -e

[ -d cmd/pp ] || {
    echo must be in keks/go/ >&2
    exit 1
}

GO_LDFLAGS="${GO_LDFLAGS:--s}"
root="$(dirname "$(realpath -- "$0")")"
cd "$root/.."
mkdir -p bin
bin=$(realpath bin)
[ -d vendor ] && mod_vendor="-mod=vendor"
go build $mod_vendor -o $bin/keks-schema-validate -ldflags "$GO_LDFLAGS" ./cmd/schema-validate
cd cmd/pp
go build $mod_vendor -o $bin/kekspp -ldflags "$GO_LDFLAGS"
