forked from phoenix-rtos/phoenix-rtos-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·144 lines (122 loc) · 2.88 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
#!/bin/bash
#
# Shell script for building Phoenix-RTOS based firmware
#
# Main builder
#
# Copyright 2018, 2019 Phoenix Systems
# Author: Kaja Swat, Aleksander Kaminski, Pawel Pisarczyk
#
set -e
. ./phoenix-rtos-build/build.subr
. ./build.project
TOPDIR="$(pwd)"
PREFIX_BUILD="$(pwd)/_build/$TARGET"
PREFIX_BUILD_HOST="$(pwd)/_build/host-pc"
PREFIX_FS="$(pwd)/_fs/$TARGET"
PREFIX_BOOT="$(pwd)/_boot"
PREFIX_PROG="$PREFIX_BUILD/prog/"
PREFIX_PROG_STRIPPED="$PREFIX_BUILD/prog.stripped/"
PREFIX_A="$PREFIX_BUILD/lib/"
PREFIX_H="$PREFIX_BUILD/include/"
PREFIX_ROOTFS="$PREFIX_FS/root/"
PREFIX_ROOTSKEL="$(pwd)/_fs//root-skel/"
LDFLAGS="$LDFLAGS -L$PREFIX_A"
CC=${CROSS}gcc
AS=${CROSS}as
LD=${CROSS}ld
AR=${CROSS}ar
MAKEFLAGS="--no-print-directory -j 9"
export TARGET TARGET_FAMILY TOPDIR PREFIX_BUILD PREFIX_BUILD_HOST\
PREFIX_FS PREFIX_BOOT PREFIX_PROG PREFIX_PROG_STRIPPED PREFIX_A\
PREFIX_H PREFIX_ROOTFS PREFIX_ROOTSKEL CROSS CFLAGS LDFLAGS CC LD\
AR AS CLEAN MAKEFLAGS DEVICE_FLAGS
#
# Parse command line
#
if [ $# -lt 1 ]; then
echo "Build options should be specified!"
echo "Usage: build.sh [clean] [all] [fs] [core] [ports] [project] [image]";
exit 1;
fi
B_FS="n"
B_CORE="n"
B_PORTS="n"
B_PROJECT="n"
B_IMAGE="n"
for i in "$@"; do
case "$i"
in
clean)
CLEAN="clean";;
fs)
B_FS="y";;
core)
B_CORE="y";;
ports)
B_PORTS="y";;
project)
B_PROJECT="y";;
image)
B_IMAGE="y";;
all)
B_FS="y"; B_CORE="y"; B_PORTS="y"; B_PROJECT="y"; B_IMAGE="y";;
esac;
done
#
# Clean if requested
#
if [ -n "$CLEAN" ]; then
b_log "Cleaning build dir"
rm -rf "$PREFIX_BUILD" "$PREFIX_BUILD_HOST"
rm -rf "$PREFIX_FS"
#FIXME: this should also remove unpacked sources in 'ports' (the easiest option is to move them to _boot)
#TODO: remove per-component CLEAN var dependency
fi
#
# Prepare
#
mkdir -p "$PREFIX_BUILD"
mkdir -p "$PREFIX_BUILD_HOST"
mkdir -p "$PREFIX_BOOT"
if declare -f "b_prepare" > /dev/null; then
b_prepare
fi
echo " $(git rev-parse HEAD) $(basename "$(git rev-parse --show-toplevel)") ($(git describe --always --dirty))" > "${PREFIX_BUILD}/git-version"
git submodule status --recursive >> "${PREFIX_BUILD}/git-version"
#
# Preparing filesystem
#
if [ "${B_FS}" = "y" ] && [ -d "${PREFIX_ROOTSKEL}" ]; then
b_log "Preparing filesystem"
mkdir -p "${PREFIX_ROOTFS}"
cp -a "${PREFIX_ROOTSKEL}/." "${PREFIX_ROOTFS}"
mkdir -p "$PREFIX_ROOTFS/"{dev,local,data,mnt,var}
b_log "Saving git-version"
install -m 664 "${PREFIX_BUILD}/git-version" "$PREFIX_FS/root/etc"
fi
#
# Build core part
#
if [ "${B_CORE}" = "y" ]; then
"./phoenix-rtos-build/build-core-${TARGET_FAMILY}-${TARGET_SUBFAMILY}.sh"
fi
#
# Build ports
#
if [ "${B_PORTS}" = "y" ] && [ -d phoenix-rtos-ports ]; then
./phoenix-rtos-ports/build.sh
fi
#
# Build project part
#
if [ "${B_PROJECT}" = "y" ]; then
b_build
fi
#
# Build final filesystems
#
if [ "${B_IMAGE}" = "y" ]; then
mkdir -p "${PREFIX_BOOT}"
b_image
fi