github.com/anjalikarhana/fabric@v2.1.1+incompatible/integration/externalbuilders/golang/bin/build (about) 1 #!/bin/bash 2 3 # Copyright IBM Corp. All Rights Reserved. 4 # 5 # SPDX-License-Identifier: Apache-2.0 6 7 set -euo pipefail 8 9 if [ "$#" -ne 3 ]; then 10 >&2 echo "Expected 3 directories got $#" 11 exit 1 12 fi 13 14 SOURCE=$1 15 METADATA=$2 16 OUTPUT=$3 17 18 >&2 jq . "$2/metadata.json" 19 20 if [[ "$(jq -r .label "$METADATA/metadata.json")" == *fail* ]]; then 21 >&2 echo "Exiting with failure..." 22 exit 1 23 fi 24 25 GO_PACKAGE_PATH="$(jq -r .path "$METADATA/metadata.json")" 26 if [ -f "$SOURCE/src/go.mod" ]; then 27 cd "$SOURCE/src" 28 go build -v -mod=readonly -o "$OUTPUT/chaincode" "$GO_PACKAGE_PATH" 29 else 30 GO111MODULE=off go build -v -o "$OUTPUT/chaincode" "$GO_PACKAGE_PATH" 31 fi 32 33 # copy index metadata if present 34 if [ -d "$SOURCE/META-INF" ]; then 35 cp -a "$SOURCE/META-INF" "$OUTPUT" 36 fi