-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·78 lines (73 loc) · 1.52 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
#!/bin/bash -e
# define variables
ROOT=$PWD
STAGE=${2:-1}
if [ $STAGE == 1 ]; then
PREFIX=$ROOT/tools
elif [ $STAGE == 2 ]; then
PREFIX=$ROOT/sysroot
elif [ $STAGE == 3 ]; then
PREFIX=/
ldconfig
fi
if command -v nproc &>/dev/null; then
J=$(nproc)
else
J=$(grep -c '^processor' /proc/cpuinfo)
fi
# config and helper functions
source config.sh
source scripts/utils.sh
linuxarch=""
case $ARCH in
riscv*)
linuxarch="riscv"
;;
x86_64*)
linuxarch="x86_64"
;;
i386*)
linuxarch="i386"
;;
aarch64*)
linuxarch="aarch64"
;;
armv7hl*)
linuxarch="arm"
;;
*)
linuxarch=""
;;
esac
# get dependencies recursively
get_dependencies() {
local varname=$1
local pkg=$2
local dir=$(dirname $2)
local depends=$(source $pkg; echo ${DEPENDS[@]})
for dep in $depends; do
get_dependencies $varname $dir/$dep
done
contains $varname $pkg || eval "$varname+=($pkg)"
}
# main program
case "$1" in
"" )
# collect all packages
builds=()
for pkg in $ROOT/stage$STAGE/*; do
get_dependencies builds $pkg
done
# to build
for build in ${builds[@]}; do
# echo $build
$(realpath $0) $build $STAGE
done
;;
* )
PATH=$ROOT/tools/bin:$PATH
source $1
echo "===== build $PKGNAME.$STAGE start ====="
source scripts/pkg.sh
echo "===== build $PKGNAME.$STAGE done ====="
esac