-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·97 lines (79 loc) · 2.54 KB
/
bootstrap.sh
File metadata and controls
executable file
·97 lines (79 loc) · 2.54 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
#! /bin/bash
set -e
LIBS_DIR="./ext_libs"
mkdir -p ${LIBS_DIR}
# Any new libraries needed that are not made by us
# should be added here. We don't use git submodules :(.
# These functions are responbisble for downloading and extracting the
# needed library source. Other functions should be made to fetch the source.
#
# Those functions should follow this naming convention:
# FETCH: get_<LIB_NAME>();
# BUILD: build_<LIB_NAME>();
# SYMLINK: symlink_<LIB_NAME>_<LINK_TARGET_NAME>();
function get_libsodium() {
local BASE_URL="https://download.libsodium.org/libsodium/releases/"
local LATEST_RELEASE=$(curl -s $BASE_URL | grep -oE 'libsodium-[0-9.]+-stable.tar.gz' | sort -V | tail -n 1)
if [ -z "$LATEST_RELEASE" ]; then
echo "Failed to determine the latest stable release of libsodium."
exit 1
fi
local DOWNLOAD_URL="$BASE_URL$LATEST_RELEASE"
echo "Downloading $LATEST_RELEASE..."
curl -O "$DOWNLOAD_URL"
echo "Download complete: $LATEST_RELEASE"
echo "Extracting $LATEST_RELEASE..."
tar -xzf "$LATEST_RELEASE" -C "${LIBS_DIR}"
echo "Extraction complete."
rm "${LATEST_RELEASE}"
}
function bootstrap_external_libs() {
echo "Cloning mINI"
git clone https://github.com/metayeti/mINI.git ${LIBS_DIR}/mINI
echo "Cloning imgui"
git clone https://github.com/ocornut/imgui.git ${LIBS_DIR}/imgui
echo "Cloning doctest"
git clone https://github.com/doctest/doctest.git ${LIBS_DIR}/doctest
get_libsodium
}
function clean_ext_libs() {
echo "cleaning up..."
rm -rf "${LIBS_DIR}"
}
#====[ Compile Library Functions ]====
function symlink_imgui_cmake() {
echo "sym-linking imgui CMakeLists.txt file..."
ln -sf $(pwd)/external_cmake/imgui/CMakeLists.txt "${LIBS_DIR}/imgui"
if [ -L "${LIBS_DIR}/imgui/CMakeLists.txt" ]; then
local target=$(readlink -f "${LIBS_DIR}/imgui/CMakeLists.txt")
if [ -e "$target" ]; then
echo "Symlink ${LIBS_DIR}/imgui/CMakeLists.txt is valid and points to $target"
else
echo "Symlink ${LIBS_DIR}/imgui/CMakeLists.txt is broken (points to non-existent target)"
fi
else
echo "${LIBS_DIR}/imgui/CMakeLists.txt is not a symlink"
fi
}
function build_imgui() {
symlink_imgui_cmake
echo "Compiling imgui lib"
cmake -S "${LIBS_DIR}/imgui" -B "${LIBS_DIR}/imgui/.build"
pushd "${LIBS_DIR}/imgui/.build"
make
popd
}
function build_libsodium() {
echo "Compiling libsodium"
pushd "${LIBS_DIR}/libsodium-stable/"
/bin/bash -- ./configure
make && make check
sudo make install
popd
}
#====[ MAIN ]====
echo "bootstraping CipherSafe dev environment..."
clean_ext_libs
bootstrap_external_libs
build_imgui
build_libsodium