-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathflatten.sh
More file actions
executable file
·36 lines (25 loc) · 867 Bytes
/
flatten.sh
File metadata and controls
executable file
·36 lines (25 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
#
# Flattens contracts to build/flattened/
#
set -eu
set -o pipefail
if [[ $# > 0 && "$1" == "__file" ]]; then
FLATTEN_LOG="$TARGET_SUBDIR/flatten.log"
solidity_flattener \
--solc-allow-paths "$(readlink -f "$BIN_DIR/contracts")" \
--solc-paths "zeppelin-solidity=$NODE_MODULES/zeppelin-solidity" \
--solc-paths "mixbytes-solidity=$NODE_MODULES/mixbytes-solidity" \
--output "$TARGET_SUBDIR/$(basename "$2")" \
"$2" \
2>>"$FLATTEN_LOG" \
|| echo failed to flatten $2, see $FLATTEN_LOG
exit 0
fi
export TARGET_SUBDIR='build/flattened'
export BIN_DIR="$(cd $(dirname $0) && pwd)"
cd "$BIN_DIR"
export NODE_MODULES="$(readlink -f "$BIN_DIR/node_modules")"
rm -rf "$TARGET_SUBDIR"
mkdir -p "$TARGET_SUBDIR"
find contracts/ -name \*.sol -print0 | xargs -0 -L 1 "$0" __file