-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathbuild.project
79 lines (63 loc) · 1.97 KB
/
build.project
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
#!/bin/bash
#
# Shell script for building Phoenix-RTOS microdistribution
#
# Copyright 2018, 2019, 2020 Phoenix Systems
# Author: Kaja Swat, Aleksander Kaminski, Pawel Pisarczyk, Lukasz Kosinski, Hubert Buczynski
#
[ "${BASH_SOURCE[0]}" -ef "$0" ] && echo "You should source this script, not execute it!" && exit 1
# extend path with build scripts dir
PATH="$PATH:$(realpath phoenix-rtos-build/scripts/)"
# optional args will be printed in red
b_list_available_targets() {
[ "$#" -gt 0 ] && echo -e "\e[1;31m$*\e[0m"
echo -e "Please specify a valid target by setting TARGET variable to one of:"
find _projects/*/build.project 2>/dev/null | cut -d/ -f 2
}
# it's best to provide TARGET by env variable
if [ -z "$TARGET" ]; then
b_list_available_targets "TARGET variable not set"
exit 1
fi
TARGET_FAMILY=$(echo "$TARGET" | awk -F- '{ print $1 }')
TARGET_SUBFAMILY="$(echo "$TARGET" | awk -F- '{ print $2 }')"
TARGET_PROJECT="$(echo "$TARGET" | awk -F- '{ print $3 }')"
if [ -z "$TARGET_FAMILY" ] || [ -z "$TARGET_SUBFAMILY" ] || [ -z "$TARGET_PROJECT" ] || [ "$TARGET" != "$TARGET_FAMILY"-"$TARGET_SUBFAMILY"-"$TARGET_PROJECT" ]; then
b_list_available_targets "TARGET='$TARGET' has invalid format"
exit 1
fi
TARGET_FILE=$(realpath "_targets/$TARGET_FAMILY/$TARGET_SUBFAMILY/build.project")
PROJECT_PATH=$(realpath "_projects/$TARGET")
PROJECT_FILE="$PROJECT_PATH/build.project"
if [ ! -f "$TARGET_FILE" ]; then
b_list_available_targets "TARGET='$TARGET' target file is unavailable"
exit 1
fi
if [ ! -f "$PROJECT_FILE" ]; then
b_list_available_targets "TARGET='$TARGET' project file is missing"
exit 1
fi
. "$TARGET_FILE"
. "$PROJECT_FILE"
#
# Project specific build
#
b_build() {
declare -F b_build_project >/dev/null && b_build_project
b_build_target
}
#
# Project specific image
#
b_image() {
b_image_target
declare -F b_image_project >/dev/null && b_image_project
# Always return 0 to prevent CI from failing
return 0
}
#
# Project specific build test
#
b_build_test() {
b_test_target
}