This repository has been archived by the owner on May 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
build.sh
executable file
·156 lines (115 loc) · 3.3 KB
/
build.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/bin/bash
##################################
# Icestorm toolchain builder #
##################################
# Set english language for propper pattern matching
export LC_ALL=C
# Generate toolchain-icestorm-arch-ver.tar.gz from source code
# sources: http://www.clifford.at/icestorm/
VERSION=1.11.1
# -- Target architectures
ARCH=$1
TARGET_ARCHS="linux_x86_64 linux_i686 linux_armv7l linux_aarch64 windows_x86 windows_amd64 darwin"
# -- Toolchain name
NAME=toolchain-icestorm
# -- Debug flags
INSTALL_DEPS=1
COMPILE_ICESTORM=1
COMPILE_ARACHNE=1
COMPILE_YOSYS=1
COMPILE_ICOTOOLS=1
COMPILE_ICEPROGDUINO=1
CREATE_PACKAGE=1
# -- Store current dir
WORK_DIR=$PWD
# -- Folder for building the source code
BUILDS_DIR=$WORK_DIR/_builds
# -- Folder for storing the generated packages
PACKAGES_DIR=$WORK_DIR/_packages
# -- Folder for storing the source code from github
UPSTREAM_DIR=$WORK_DIR/_upstream
# -- Create the build directory
mkdir -p $BUILDS_DIR
# -- Create the packages directory
mkdir -p $PACKAGES_DIR
# -- Create the upstream directory and enter into it
mkdir -p $UPSTREAM_DIR
# -- Test script function
function test_bin {
. $WORK_DIR/test/test_bin.sh $1
if [ $? != "0" ]; then
exit 1
fi
}
# -- Print function
function print {
echo ""
echo $1
echo ""
}
# -- Check ARCH
if [[ $# > 1 ]]; then
echo ""
echo "Error: too many arguments"
exit 1
fi
if [[ $# < 1 ]]; then
echo ""
echo "Usage: bash build.sh TARGET"
echo ""
echo "Targets: $TARGET_ARCHS"
exit 1
fi
if [[ $ARCH =~ [[:space:]] || ! $TARGET_ARCHS =~ (^|[[:space:]])$ARCH([[:space:]]|$) ]]; then
echo ""
echo ">>> WRONG ARCHITECTURE \"$ARCH\""
exit 1
fi
echo ""
echo ">>> ARCHITECTURE \"$ARCH\""
# -- Directory for compiling the tools
BUILD_DIR=$BUILDS_DIR/build_$ARCH
# -- Directory for installation the target files
PACKAGE_DIR=$PACKAGES_DIR/build_$ARCH
# --------- Instal dependencies ------------------------------------
if [ $INSTALL_DEPS == "1" ]; then
print ">> Install dependencies"
. $WORK_DIR/scripts/install_dependencies.sh
fi
# -- Create the build dir
mkdir -p $BUILD_DIR
# -- Create the package folders
mkdir -p $PACKAGE_DIR/$NAME/bin
mkdir -p $PACKAGE_DIR/$NAME/share
# --------- Compile icestorm ---------------------------------------
if [ $COMPILE_ICESTORM == "1" ]; then
print ">> Compile icestorm"
. $WORK_DIR/scripts/compile_icestorm.sh
fi
# --------- Compile arachne-pnr ------------------------------------
if [ $COMPILE_ARACHNE == "1" ]; then
print ">> Compile arachne-pnr"
. $WORK_DIR/scripts/compile_arachnepnr.sh
fi
# --------- Compile iceprogduino ------------------------------------
if [ $COMPILE_ICEPROGDUINO == "1" ]; then
print ">> Compile iceprogduino"
. $WORK_DIR/scripts/compile_iceprogduino.sh
fi
# --------- Compile yosys ------------------------------------------
if [ $COMPILE_YOSYS == "1" ]; then
print ">> Compile yosys"
. $WORK_DIR/scripts/compile_yosys.sh
fi
# --------- Compile icotools ----------------------------------------
if [ $COMPILE_ICOTOOLS == "1" ]; then
if [ $ARCH == "linux_armv7l" ]; then
print ">> Compile icotools for RPI"
. $WORK_DIR/scripts/compile_icotools.sh
fi
fi
# --------- Create the package -------------------------------------
if [ $CREATE_PACKAGE == "1" ]; then
print ">> Create package"
. $WORK_DIR/scripts/create_package.sh
fi