Skip to content

Commit 3f81e47

Browse files
committed
🔀 Merge branch 'generate-script' into 'dev'
Compatibility update for generate.sh See merge request perun/go-perun!392
2 parents 429a893 + dca443f commit 3f81e47

File tree

2 files changed

+34
-30
lines changed

2 files changed

+34
-30
lines changed

.gitlab-ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,21 @@
66
- merge_requests
77

88
stages:
9+
- bindings
910
- vetting
1011
- tests
1112

13+
variables:
14+
GIT_SUBMODULE_STRATEGY: recursive
15+
16+
bindings:
17+
<<: *only-default
18+
stage: bindings
19+
image: perunnetwork/solc-abigen
20+
script:
21+
- cd backend/ethereum/bindings
22+
- ./generate.sh
23+
1224
code_quality:
1325
<<: *only-default
1426
stage: vetting
Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/bin/sh
1+
#!/usr/bin/env sh
22

3-
# Copyright 2020 - See NOTICE file for copyright holders.
3+
# Copyright 2021 - See NOTICE file for copyright holders.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -16,47 +16,39 @@
1616

1717
set -e
1818

19-
ABIGEN=abigen
20-
SOLC=solc
19+
# Define ABIGEN and SOLC default values.
20+
ABIGEN="${ABIGEN-abigen}"
21+
SOLC="${SOLC-solc}"
2122

22-
# Download solc.
23-
if [ `uname` == "Linux" ]; then
24-
# GNU Linux
25-
wget -nc "https://github.com/ethereum/solidity/releases/download/v0.7.4/solc-static-linux"
26-
chmod +x solc-static-linux
27-
SOLC=./solc-static-linux
28-
29-
elif [ `uname` == "Darwin" ]; then
30-
# Mac OSX
31-
curl -L "https://github.com/ethereum/solidity/releases/download/v0.7.4/solc-macos" -o solc-macos
32-
chmod +x solc-macos
33-
SOLC=./solc-macos
23+
if ! $ABIGEN --version
24+
then
25+
echo "Please install abigen v1.9.25+ or the environment varables AGIBEN."
26+
exit 1
27+
fi
3428

35-
else
36-
# Unsupported
37-
echo "Unsupported operating system: `uname`. Exiting."
29+
if ! $SOLC --version
30+
then
31+
echo "Please install abigen v0.7.4 or the environment varables SOLC."
3832
exit 1
3933
fi
4034

41-
echo "Exec 'git submodule update --init --recursive' once after cloning."
42-
echo "Ensure that the newest version of abigen is installed."
35+
echo "Please ensure that the repository was cloned with submodules: 'git submodule update --init --recursive'."
4336

4437
# Generates optimized golang bindings and runtime binaries for sol contracts.
4538
# $1 solidity file path, relative to ../contracts/contracts/.
4639
# $2 golang package name.
47-
function generate() {
40+
generate() {
4841
FILE=$1; PKG=$2; CONTRACT=$FILE
49-
echo "generate package $PKG"
42+
echo "Generating $PKG bindings..."
5043

51-
mkdir -p $PKG
44+
rm -r $PKG
45+
mkdir $PKG
5246

53-
# generate abi
47+
# Generate bindings
5448
$ABIGEN --pkg $PKG --sol ../contracts/contracts/$FILE.sol --out $PKG/$FILE.go --solc $SOLC
5549

56-
# generate go bindings
57-
$SOLC --bin-runtime --optimize --allow-paths *, ../contracts/contracts/$FILE.sol --overwrite -o $PKG/
58-
59-
# generate binary runtime
50+
# Generate binary runtime
51+
$SOLC --bin-runtime --optimize --allow-paths ../contracts/vendor, ../contracts/contracts/$FILE.sol -o $PKG/
6052
BIN_RUNTIME=`cat ${PKG}/${CONTRACT}.bin-runtime`
6153
OUT_FILE="$PKG/${CONTRACT}BinRuntime.go"
6254
echo "package $PKG // import \"perun.network/go-perun/backend/ethereum/bindings/$PKG\"" > $OUT_FILE
@@ -79,4 +71,4 @@ generate "PerunToken" "peruntoken"
7971
# Applications
8072
generate "TrivialApp" "trivialapp"
8173

82-
echo "Generated bindings"
74+
echo "Bindings generated successfully."

0 commit comments

Comments
 (0)