-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvcpkg.sh
More file actions
executable file
·86 lines (74 loc) · 2.49 KB
/
Copy pathvcpkg.sh
File metadata and controls
executable file
·86 lines (74 loc) · 2.49 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
#!/bin/bash
# search search paths for a compiler version that is 13 or higher
# set CC or CXX to the compiler path if found
# return 0 if a compiler is found, 1 otherwise
function find_compiler() {
program_names=$1
search_paths="/usr/bin /usr/local/bin /opt/bin /opt/homebrew/bin"
for program_name in $program_names; do
found=false # Flag to track if a program is found
for path in $search_paths; do
if [[ -x "$path/$program_name" ]]; then
# get version
program="$path/$program_name"
out=$($program --version 2>&1)
if [[ ! "$out" =~ "Apple clang version" ]]; then
out=$($program -dumpversion 2>&1)
# Extract the major version using parameter expansion and slicing
major_version=${out%%.*}
if [[ "$major_version" -ge 13 ]]; then
echo "Found GCC version 13 or higher: $program"
found=true
break
fi
fi
fi
done
if [[ $found = true ]]; then
break
fi
done
if [[ $found = true ]]; then
if [[ "$program_name" =~ ^gcc.* ]]; then
echo "Setting CC to $program"
export CC=$program
else
echo "Setting CXX to $program"
export CXX=$program
fi
return 0
fi
return 1
}
if [ -e '/.dockerenv' ]; then
DOCKER=1
else
DOCKER=0
fi
DIR=external/vcpkg
if [ ! -d ${DIR} ]
then
if [ $DOCKER -eq 1 ]; then
echo "Building inside a container; symlinking external dir"
ln -s /home/dev/external external
fi
program_names="gcc gcc-14"
if ! find_compiler "$program_names"; then
echo "No suitable gcc compiler found."
exit 1
fi
program_names="g++ g++-14"
if ! find_compiler "$program_names"; then
echo "No suitable g++ compiler found."
exit 1
fi
git clone https://github.com/Microsoft/vcpkg.git "${DIR}"
cd "$DIR"
# Locks it down to a specific commit
# Commit 3db09f58b750b9d097d2eb2223b4dba220ee5275 is latest known working commit
# The one after it: https://github.com/microsoft/vcpkg/commit/11972bdacefc3eaade76df037b0f5fa112c0d36e
# breaks the logic to find the installed packages.
git reset --hard "${VCPKG_COMMIT_HASH:-120deac3062162151622ca4860575a33844ba10b}"
./bootstrap-vcpkg.sh
./vcpkg integrate install
fi