This repository has been archived by the owner on May 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.sh
executable file
·112 lines (86 loc) · 2.33 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
#!/bin/bash
##################################
# Iverilog toolchain builder #
##################################
# Generate toolchain-iverilog-arch-ver.tar.gz from source code
# sources: http://iverilog.icarus.com/
VERSION=1.2.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-iverilog
# -- Debug flags
INSTALL_DEPS=1
COMPILE_IVERILOG=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
# --------- Compile iverilog ---------------------------------------
if [ $COMPILE_IVERILOG == "1" ]; then
print ">> Compile iverilog"
. $WORK_DIR/scripts/compile_iverilog.sh
fi
# --------- Create the package -------------------------------------
if [ $CREATE_PACKAGE == "1" ]; then
print ">> Create package"
. $WORK_DIR/scripts/create_package.sh
fi