Repository navigation
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·107 lines (90 loc) · 2.72 KB
/
Copy pathbootstrap.sh
File metadata and controls
executable file
·107 lines (90 loc) · 2.72 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
#!/usr/bin/env bash
# Copyright Chad Engler
# Resolve the project path
if [[ $# -eq 0 ]]; then
PROJECT_PATH=$(realpath "he_project.toml")
else
PROJECT_PATH=$(realpath $1)
shift
fi
if [[ ! -f "$PROJECT_PATH" ]]; then
echo "Project file not found: $PROJECT_PATH"
exit 1
fi
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
pushd "$SCRIPT_DIR" > /dev/null
# Check for the '-h' or '--help' argument
if echo "$@" | grep -q -w -i -E "\-h|--help"; then
echo "Usage: bootstrap.sh <project_path> [premake_args]"
popd > /dev/null
exit 1
fi
PROJECT_DIR=$(dirname $PROJECT_PATH)
BUILD_DIR="$PROJECT_DIR/build"
#PREMAKE_VERSION="nightly"
PREMAKE_VERSION="5.0.0-beta2"
OS_NAME="$(uname -s)"
case $OS_NAME in
Linux*)
PREMAKE_OS="linux"
PREMAKE_EXT=".tar.gz"
PREMAKE_ACTION="gmake2"
PREMAKE_EXE="premake5"
;;
MSYS_NT*)
;&
CYGWIN*)
;&
MINGW*)
PREMAKE_OS="windows"
PREMAKE_EXT=".zip"
PREMAKE_ACTION="vs2022"
PREMAKE_EXE="premake5.exe"
;;
*)
echo "Unknown OS, you'll have to get and run premake yourself."
popd > /dev/null
exit 1
esac
if [[ "$PREMAKE_VERSION" != "nightly" ]]; then
PREMAKE_DL_FILE="premake-${PREMAKE_VERSION}-${PREMAKE_OS}${PREMAKE_EXT}"
PREMAKE_DL_URL="https://github.com/premake/premake-core/releases/download/v${PREMAKE_VERSION}/${PREMAKE_DL_FILE}"
else
PREMAKE_EXT=".zip"
PREMAKE_DL_FILE="premake-${PREMAKE_OS}-x64.zip"
PREMAKE_DL_URL="https://nightly.link/premake/premake-core/workflows/ci-workflow/master/${PREMAKE_DL_FILE}"
fi
if [[ "$PREMAKE_EXT" == ".tar.gz" ]]; then
EXTRACT_CMD="tar -xzf"
EXTRACT_FLAG="-C"
else
EXTRACT_CMD="unzip -qq"
EXTRACT_FLAG="-d"
fi
PREMAKE_DIR="$BUILD_DIR/premake/$PREMAKE_OS"
PREMAKE_PATH="$PREMAKE_DIR/$PREMAKE_DL_FILE"
mkdir -p $PREMAKE_DIR
if [[ ! -f "$PREMAKE_PATH" ]]; then
echo "Downloading premake..."
if command -v "curl" &> /dev/null; then
curl -L -s -o $PREMAKE_PATH $PREMAKE_DL_URL
elif command -v "wget" &> /dev/null; then
wget -O $PREMAKE_PATH $PREMAKE_DL_URL
else
echo "Unable to download premake because neither wget nor curl are available."
popd > /dev/null
exit 1
fi
fi
if [[ ! -f "$PREMAKE_DIR/$PREMAKE_EXE" ]]; then
echo "Extracting premake..."
$EXTRACT_CMD "$PREMAKE_PATH" $EXTRACT_FLAG "$PREMAKE_DIR"
chmod +x "$PREMAKE_DIR/$PREMAKE_EXE"
fi
if [[ $# -eq 0 ]]; then
"$PREMAKE_DIR/$PREMAKE_EXE" $PREMAKE_ACTION --file="$SCRIPT_DIR/premake5.lua" --he_project="$PROJECT_PATH"
else
"$PREMAKE_DIR/$PREMAKE_EXE" $@ --file="$SCRIPT_DIR/premake5.lua" --he_project="$PROJECT_PATH"
fi
popd > /dev/null
exit 0