generated from Uniswap/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathcreate_briefcase.sh
executable file
·55 lines (41 loc) · 1.51 KB
/
create_briefcase.sh
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash -e
target_dir=${1:-src/briefcase/protocols}
rm -rf $target_dir
tmp_dir="$(mktemp -q -d -t "$(basename "$0").XXXXXX")"
compile_and_flatten() {
local source_path=$1
local project=$2
local subpath=$3
local input_dir="$source_path/$project/$subpath"
local output_dir="$tmp_dir/$project/${subpath##*/}"
local flatten_command="forge flatten"
echo "processing $project/$subpath"
echo ""
find "$input_dir" -type f -name "*.sol" | while read -r sol_file; do
relative_path=$(echo "$sol_file" | sed -E "s|^$input_dir/||")
output_file="$output_dir$relative_path"
echo "Flattening $sol_file"
$flatten_command "$sol_file" -o "$output_file"
done
echo ""
}
forge clean
forge build --skip script --skip "src/briefcase/**"
# flatten packages
pkgs=$(ls src/pkgs/);
for pkg in $pkgs
do
subpaths=$(find src/pkgs/$pkg -type d \( -path "src/pkgs/$pkg/lib" -o -path "src/pkgs/$pkg/test" \) -prune -o \( -name "interface" -o -name "interfaces" -o -name "libraries" -o -name "types" -o -name "util" -o -name "utils" \) -print | sed "s|src/pkgs/$pkg/||")
for subpath in $subpaths
do
compile_and_flatten "src/pkgs" "$pkg" "$subpath"
done
done
echo "Inserting current initcode into deployers"
python3 script/util/insert_initcode.py "src/briefcase/deployers" "out"
echo "Processing source files and writing to briefcase"
python3 script/util/process_briefcase_files.py "$tmp_dir" "$(pwd)" "$target_dir"
rm -rf "$tmp_dir"
forge fmt "src/briefcase"
# build the generated files
forge build