This repository was archived by the owner on Sep 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheasy-builder
More file actions
executable file
·132 lines (110 loc) · 2.38 KB
/
easy-builder
File metadata and controls
executable file
·132 lines (110 loc) · 2.38 KB
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
#! /usr/bin/env bash
# This script is meant to be kept small and simple
# If you think about adding features, it's probably a bad idea
set -e # exit if a command fails
set -o pipefail # Will return the exit status of make if it fails
project_source_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
build_dir="${project_source_dir}/build${SUBDIR:+/${SUBDIR}}"
install_dir="${project_source_dir}/install${SUBDIR:+/${SUBDIR}}"
install_target='install/strip'
build_type='Release'
case "$(uname -s)" in
# Stripping is known to make FreeBSD binaries unusable.
# Maybe that's related to the way we patch rpath?
'FreeBSD')
install_target='install'
;;
esac
_job_count=4
_nproc () {
if command -v 'nproc' >/dev/null
then
nproc
else
case "$(uname -s)" in
'Linux')
egrep "^processor" /proc/cpuinfo | wc -l
;;
'FreeBSD')
sysctl -n hw.ncpu
;;
'Darwin')
sysctl -n hw.logicalcpu \
|| sysctl -n hw.ncpu
;;
'MSYS_NT-'*|'CYGWIN_NT-'*|'MINGW'*'_NT-'*)
if command -v 'wmic' >/dev/null
then
wmic cpu get NumberOfLogicalProcessors/Format:List \
| grep -m1 '=' | cut -f2 -d'='
else
echo "${NUMBER_OF_PROCESSORS:-${_job_count}}"
fi
;;
*)
echo "${_job_count}"
;;
esac
fi
}
job_count="$(_nproc)" 2>/dev/null
job_count="${job_count:-${_job_count}}"
declare -a cmake_user_opts
while [ ! -z "${1}" ]
do
case "${1}" in
'-j'*)
job_count="${1:2}"
shift
;;
'--debug')
install_target='install'
build_type='Debug'
shift
;;
*)
cmake_user_opts[${#cmake_user_opts[@]}]="${1}"
shift
;;
esac
done
declare -a fetch_submodules_cmd
for submodule_file in 'libs/recastnavigation/RecastDemo/Source/ChunkyTriMesh.cpp'
do
if ! [ -f "${project_source_dir}/${submodule_file}" ]
then
fetch_submodules_cmd=(git -C "${project_source_dir}" submodule update --init --recursive)
fi
done
task_enter_build_dir () {
sync
mkdir -pv "${build_dir}"
cd "${build_dir}"
}
task_fetch_submodules () {
sync
"${fetch_submodules_cmd[@]}"
}
task_configure () {
sync
cmake \
-G'Unix Makefiles' \
-D'CMAKE_INSTALL_PREFIX'="${install_dir}" \
-D'CMAKE_BUILD_TYPE'="${build_type}" \
"${cmake_user_opts[@]}" \
"${project_source_dir}"
}
task_build () {
sync
make -j"${job_count}"
}
task_install () {
sync
make "${install_target}"
}
set -x
task_enter_build_dir
task_fetch_submodules
task_configure
task_build
task_install