-
Notifications
You must be signed in to change notification settings - Fork 0
/
silly-mac.sh
executable file
·118 lines (94 loc) · 2.84 KB
/
silly-mac.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
#!/bin/bash
set -xv
#gnu_version="${GNU_VERSION:-"11"}"
#clang_version="${CLANG_VERSION:-"11"}"
make="${MAKE:-"make"}"
shopt -s nocasematch
case "${make}" in
*ninja*)
generator_name="${GENERATOR_NAME:-"Ninja Multi-Config"}"
job="0"
;;
*make*)
generator_name="${GENERATOR_NAME:-"Unix Makefiles"}"
job=""
;;
esac
cmake_options="-D CMAKE_EXPORT_COMPILE_COMMANDS=ON"
files="a.cpp main.cpp CMakeLists.txt"
for d in "${@}"
do (
if [[ -e "${d}" ]]
then
printf "%q exists; ABORTING!" "${d}" >&2
exit 1
fi
mkdir -p "${d}"
cp -npv ${files} "${d}"
cd "${d}"
chmod -v +w ${files}
for gccroot in "${HOMEBREW_PREFIX}"/opt/gcc "${HOMEBREW_PREFIX}"/opt/gcc@*
do (
version="$(readlink "${gccroot}")"
version="${version##*/}"
version="${version%_*}"
major="${version%%.*}"
cxx="${gccroot}"/bin/g++-"${major}"
cc="${gccroot}"/bin/gcc-"${major}"
build=gcc"${major}"
mkdir -p "${build}"
echo "${build}"/ >> .gitignore
if [[ "${gccroot##*/}" == gcc ]]
then
ln -s "${build}"/ gcc
echo gcc >> .gitignore
fi
cd "${build}"
CC="${cc}" CXX="${cxx}" cmake ${cmake_options} -G "${generator_name}" ~-
${make} -j ${job}
)& done
for clangroot in "${HOMEBREW_PREFIX}"/opt/llvm "${HOMEBREW_PREFIX}"/opt/llvm@*
do (
version="$(readlink "${clangroot}")"
version="${version##*/}"
version="${version%%_*}"
major="${version%%.*}"
cxx="${clangroot}"/bin/clang++
cc="${clangroot}"/bin/clang
build=clang"${major}"
mkdir -p "${build}"
echo "${build}"/ >> .gitignore
cd "${build}"
CC="${cc}" CXX="${cxx}" cmake ${cmake_options} -D "CLANG_LINK_DIRECTORIES:PATH=${clang_root}/lib" -G "${generator_name}" ~-
${make} -j ${job}
)& done
(
cxx=/usr/bin/clang++
version="$("${cxx}" --version)"
version="${version#*(}"
version="${version%%)*}"
build="${version}"
mkdir -p "${build}"
echo "${build}"/ >> .gitignore
ln -s "${build}"/ clang
echo clang >> .gitignore
cd "${build}"
CC="${cc}" CXX="${cxx}" cmake ${cmake_options} -G "${generator_name}" ~-
${make} -j ${job}
)&
wait
# Create symlink for compilecommands
compilecommands="compile_commands.json"
for build in clang gcc clangapple clang* gcc*
do
if [[ -r "${build}"/"${compilecommands}" ]]
then
ln -s "${build}"/"${compilecommands}" "${compilecommands}"
echo "${compilecommands}" >> .gitignore
break
fi
done
git init --initial-branch "${d}"
git add --verbose .
git commit --verbose --allow-empty-message --no-edit
) done