#!/bin/bash
[% c("var/set_default_env") -%]
distdir=/var/tmp/dist/[% project %]
mkdir -p $distdir

# Do not use our standard setup for Go, as we are building a host-only tool
# which does not need to be cross-compiled.
tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/go') %]
export PATH=/var/tmp/dist/go/bin:/var/tmp/dist/gopath/bin:"$PATH"

mkdir -p /var/tmp/build
tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.[% c('compress_tar') %]
cd /var/tmp/build/[% project %]-[% c('version') %]

tar -xf $rootdir/[% c('input_files_by_name/go_vendor') %]

go build -mod=vendor
cp -a go-licenses $distdir

cd /var/tmp/dist
[% c('tar', {
        tar_src => [ project ],
        tar_args => '-caf ' _ dest_dir _ '/' _ c('filename'),
    }) %]
