...
1#!/bin/bash
2#
3# Copyright (c) SAS Institute Inc.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17set -ex -o pipefail
18version=$(./scripts/version.sh)
19commit=$(git rev-parse HEAD)
20ldflags="-s -w -X github.com/sassoftware/relic/config.Version=$version -X github.com/sassoftware/relic/config.Commit=$commit"
21
22rm -rf build
23mkdir build
24
25## non-cgo build of client
26docker rmi relic-build 2>/dev/null ||:
27docker build \
28 -f scripts/Dockerfile.clientbuild \
29 --build-arg ldflags="$ldflags" \
30 -t relic-build .
31container=$(docker create relic-build)
32docker cp $container:out build/
33docker rm $container
34docker rmi relic-build
35
36## cgo build of full program
37# build libtool-ltdl as a static library so no deps other than libc are needed
38xgo \
39 --targets=linux/amd64,darwin/amd64,windows/amd64 \
40 --deps="http://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz" \
41 --depsargs=--disable-shared \
42 --out="build/relic" \
43 -ldflags "$ldflags" \
44 .
45sudo chown $(id -u) build/*
46
47mv build/relic-darwin-*-amd64 build/relic-darwin-amd64
48mv build/relic-windows-*-amd64.exe build/relic-windows-amd64.exe
49mv build/out/* build/
50rmdir build/out
View as plain text