-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·52 lines (45 loc) · 1.16 KB
/
build.sh
File metadata and controls
executable file
·52 lines (45 loc) · 1.16 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
#!/usr/bin/env bash
# Fetch the latest version of the library
fetch() {
if [ -d "json" ]; then return; fi
URL="https://github.com/open-source-parsers/jsoncpp/archive/refs/heads/master.zip"
ZIP="${URL##*/}"
DIR="jsoncpp-master"
mkdir -p .build
cd .build
# Download the release
if [ ! -f "$ZIP" ]; then
echo "Downloading $ZIP from $URL ..."
curl -L "$URL" -o "$ZIP"
echo ""
fi
# Unzip the release
if [ ! -d "$DIR" ]; then
echo "Unzipping $ZIP to .build/$DIR ..."
cp "$ZIP" "$ZIP.bak"
unzip -q "$ZIP"
rm "$ZIP"
mv "$ZIP.bak" "$ZIP"
echo ""
fi
cd ..
# Copy the libs to the package directory
echo "Copying libs to json/ ..."
rm -rf json
mkdir -p json
cp -rf ".build/$DIR/include/json"/* json/
cp -rf ".build/$DIR/src/lib_json"/* json/
rm -f json/*.txt
echo ""
}
# Test the project
test() {
echo "Running 01-read-from-string.cxx ..."
clang++ -I. -o 01.exe examples/01-read-from-string.cxx && ./01.exe && echo -e "\n"
echo "Running 02-string-write.cxx ..."
clang++ -I. -o 02.exe examples/02-string-write.cxx && ./02.exe && echo -e "\n"
}
# Main script
if [[ "$1" == "test" ]]; then test
elif [[ "$1" == "fetch" ]]; then fetch
else echo "Usage: $0 {fetch|test}"; fi