ncdns-repro/projects/ncdns/build
Jeremy Rand 34f7041be9
Add generate_nmc_cert project
It's no longer a component of ncdns.
2021-05-19 05:24:21 +00:00

102 lines
3.0 KiB
Bash

#!/bin/bash
[% c("var/set_default_env") -%]
[% pc('go', 'var/setup', { go_tarfile => c('input_files_by_name/go') }) %]
[% IF c("var/cgo") %]
[% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
[% IF c("var/linux") %]
tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/binutils') %]
export PATH="/var/tmp/dist/binutils/bin:$PATH"
[% END -%]
[% IF c("var/osx") -%]
export CGO_CFLAGS="[% c("var/FLAGS") %] -mmacosx-version-min=10.7"
export CGO_CXXFLAGS="[% c("var/FLAGS") %] -stdlib=libc++ -mmacosx-version-min=10.7"
export CGO_LDFLAGS="[% c("var/FLAGS") %] -stdlib=libc++ -mmacosx-version-min=10.7"
export CC="$clangdir/bin/clang"
export CXX="$clangdir/bin/clang++"
[% END -%]
[% END -%]
export CGO_ENABLED=[% c("var/cgo") %]
distdir=/var/tmp/dist/[% project %]
mkdir -p $distdir
[% FOREACH dep = c("var/go_lib_deps") -%]
tar -C /var/tmp/dist -xf [% c('input_files_by_name/' _ dep) %]
[% END -%]
[% FOREACH dep = c("var/os_go_lib_deps") -%]
tar -C /var/tmp/dist -xf [% c('input_files_by_name/' _ dep) %]
[% END -%]
[% FOREACH dep = c("var/optional_go_lib_deps") -%]
tar -C /var/tmp/dist -xf [% c('input_files_by_name/' _ dep) %]
[% END -%]
mkdir -p $GOPATH/src/github.com/namecoin
tar -C $GOPATH/src/github.com/namecoin -xf [% project %]-[% c('version') %].tar.gz
mv $GOPATH/src/github.com/namecoin/ncdns-[% c('version') %] $GOPATH/src/github.com/namecoin/ncdns
[% IF c("var/enable_namecoin_tlsa") %]
TAGS=""
[% ELSE %]
TAGS="-tags no_namecoin_tls"
[% END %]
[% FOREACH inst IN c("var/go_lib_install") %]
# TODO: Remove static build ID after migrating to Go 1.13.3+
go install $TAGS -ldflags '-s -buildid=' [% inst %]
[% END %]
[% FOREACH inst IN c("var/optional_go_lib_install") %]
# TODO: Remove static build ID after migrating to Go 1.13.3+
go install $TAGS -ldflags '-s -buildid=' [% inst %]
[% END %]
#mkdir -p /var/tmp/build
#tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
#cd /var/tmp/build/[% project %]-[% c('version') %]
#mkdir -p "$GOPATH/src/github.com/namecoin"
#ln -sf "$PWD" "$GOPATH/src/github.com/namecoin/ncdns"
#mkdir -p out
#cd out
#for x in .. ../ncdumpzone ../generate_nmc_cert; do
# go build -ldflags '-s' "$x"
#done
[% IF c("var/linux-x86_64") -%]
GOPATHBIN="${GOPATH}/bin"
[% ELSE -%]
GOPATHBIN="${GOPATH}/bin/${GOOS}_${GOARCH}"
[% END -%]
cd /var/tmp/dist
[% IF !c("var/go_lib_no_output") -%]
# Build as library
[% c('tar', {
tar_src => [ 'gopath' ],
tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
}) %]
[% ELSE %]
# Build as executable
ls $GOPATHBIN
for x in ncdns ncdt; do
cp -a $GOPATHBIN/"$x"[% IF c("var/windows") %].exe[% END %] $distdir/
done
[% IF c("var/enable_namecoin_tlsa") %]
for x in ncdumpzone tlsrestrict_chromium_tool; do
cp -a $GOPATHBIN/"$x"[% IF c("var/windows") %].exe[% END %] $distdir/
done
[% END %]
cd $distdir
[% c('tar', {
tar_src => [ '.' ],
tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
}) %]
[% END %]