-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
192 lines (147 loc) · 5.78 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# This file is part of the GNU MCU Eclipse distribution.
# (https://gnu-mcu-eclipse.github.io)
# Copyright (c) 2019 Liviu Ionescu.
#
# Permission to use, copy, modify, and/or distribute this software
# for any purpose is hereby granted, under the terms of the MIT license.
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Safety settings (see https://gist.github.com/ilg-ul/383869cbb01f61a51c4d).
if [[ ! -z ${DEBUG} ]]
then
set ${DEBUG} # Activate the expand mode if DEBUG is anything but empty.
else
DEBUG=""
fi
set -o errexit # Exit if command failed.
set -o pipefail # Exit if pipe failed.
set -o nounset # Exit if variable not set.
# Remove the initial space and instead use '\n'.
IFS=$'\n\t'
# -----------------------------------------------------------------------------
# Identify the script location, to reach, for example, the helper scripts.
build_script_path="$0"
if [[ "${build_script_path}" != /* ]]
then
# Make relative path absolute.
build_script_path="$(pwd)/$0"
fi
script_folder_path="$(dirname "${build_script_path}")"
script_folder_name="$(basename "${script_folder_path}")"
# =============================================================================
# Script to build the GNU MCU Eclipse OpenOCD distribution packages.
#
# Developed on macOS 10.13 High Sierra, but intended to run on
# macOS 10.10 Yosemite and CentOS 6 XBB.
# -----------------------------------------------------------------------------
echo
echo "GNU MCU Eclipse OpenOCD distribution build script."
host_functions_script_path="${script_folder_path}/helper/host-functions-source.sh"
source "${host_functions_script_path}"
# -----------------------------------------------------------------------------
# Array where the remaining args will be stored.
declare -a rest
host_options " bash $0 [--win32] [--win64] [--linux32] [--linux64] [--osx] [--all] [clean|cleanlibs|cleanall|preload-images] [--env-file file] [--date YYYYmmdd-HHMM] [--disable-strip] [--without-pdf] [--with-html] [--develop] [--debug] [--jobs N] [--help]" $@
echo
echo "Host helper functions source script: \"${host_functions_script_path}\"."
host_detect
# docker_linux64_image="ilegeul/centos:6-xbb-v2.1"
# docker_linux32_image="ilegeul/centos32:6-xbb-v2.1"
host_common
CONTAINER_RUN_AS_ROOT="y"
# -----------------------------------------------------------------------------
if [ ! -z "${DO_BUILD_LINUX64}${DO_BUILD_WIN64}${DO_BUILD_LINUX32}${DO_BUILD_WIN32}" ]
then
host_prepare_docker
fi
if [ -z "${DO_BUILD_ANY}" ]
then
# ----- Build the native distribution. --------------------------------------
host_build_target "Creating the native distribution..." \
--script "${HOST_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
--env-file "${ENV_FILE}" \
-- \
${rest[@]-}
else
# ----- Build the OS X distribution. ----------------------------------------
if [ "${DO_BUILD_OSX}" == "y" ]
then
if [ "${HOST_UNAME}" == "Darwin" ]
then
host_build_target "Creating the OS X distribution..." \
--script "${HOST_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
--env-file "${ENV_FILE}" \
--target-platform "darwin" \
-- \
${rest[@]-}
else
echo "Building the macOS image is not possible on this platform."
exit 1
fi
fi
# ----- Build the GNU/Linux 64-bit distribution. ----------------------------
linux_distribution="centos"
if [ "${DO_BUILD_LINUX64}" == "y" ]
then
host_build_target "Creating the GNU/Linux 64-bit distribution..." \
--script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
--env-file "${ENV_FILE}" \
--target-platform "linux" \
--target-arch "x64" \
--target-bits 64 \
--docker-image "${docker_linux64_image}" \
-- \
${rest[@]-}
fi
# ----- Build the Windows 64-bit distribution. ------------------------------
if [ "${DO_BUILD_WIN64}" == "y" ]
then
host_build_target "Creating the Windows 64-bit distribution..." \
--script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
--env-file "${ENV_FILE}" \
--target-platform "win32" \
--target-arch "x64" \
--target-bits 64 \
--docker-image "${docker_linux64_image}" \
-- \
${rest[@]-}
fi
# ----- Build the GNU/Linux 32-bit distribution. ----------------------------
if [ "${DO_BUILD_LINUX32}" == "y" ]
then
host_build_target "Creating the GNU/Linux 32-bit distribution..." \
--script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
--env-file "${ENV_FILE}" \
--target-platform "linux" \
--target-arch "x32" \
--target-bits 32 \
--docker-image "${docker_linux32_image}" \
-- \
${rest[@]-}
fi
# ----- Build the Windows 32-bit distribution. ------------------------------
# Since the actual container is a 32-bit, use the debian32 binaries.
if [ "${DO_BUILD_WIN32}" == "y" ]
then
host_build_target "Creating the Windows 32-bit distribution..." \
--script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
--env-file "${ENV_FILE}" \
--target-platform "win32" \
--target-arch "x32" \
--target-bits 32 \
--docker-image "${docker_linux32_image}" \
-- \
${rest[@]-}
fi
fi
host_show_sha
# -----------------------------------------------------------------------------
host_stop_timer
host_notify_completed
echo
echo "Use --date ${DISTRIBUTION_FILE_DATE} if needed for a related build."
# Completed successfully.
exit 0
# -----------------------------------------------------------------------------