-
Notifications
You must be signed in to change notification settings - Fork 1
/
generateXcodeProject.sh
executable file
·61 lines (53 loc) · 2.12 KB
/
generateXcodeProject.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
#!/bin/bash
################################################################################
# Script for generating Xcode project files. #
# #
# (C) 2024 Marc Schöndorf #
# Licensed under the zlib License. See LICENSE.md #
################################################################################
################################################################################
# Predefine colors
BOLDYELLOW="\033[1;33m"
ITALICYELLOW="\033[3;33m"
BOLDRED="\033[1;31m"
ITALICRED="\033[3;31m"
BOLD="\033[1m"
ITALIC="\033[3m"
ENDCOLOR="\033[0m"
################################################################################
# Print help text
PrintHelp()
{
echo
echo -e "${BOLD}Usage:${ENDCOLOR}"
echo
echo "generateXcodeProject.sh BUILD_TYPE"
echo
echo -e " ${BOLD}BUILD_TYPE:${ENDCOLOR} Debug, Release, RelWithDebInfo"
echo -e " If no ${ITALIC}BUILD_TYPE${ENDCOLOR} is specified (left empty), ${ITALIC}Release${ENDCOLOR} will be used as default."
echo
echo -e "Pass ${ITALIC}-h${ENDCOLOR} or ${ITALIC}--help${ENDCOLOR} to print this help text."
echo
}
################################################################################
# Read first parameter
BUILD_TYPE="$1"
# Should we print the help text?
if [[ "$BUILD_TYPE" == "-h" ]] || [[ "$BUILD_TYPE" == "--help" ]]
then
PrintHelp
exit 0
fi
# Do we have a build type argument?
if [[ -z "$BUILD_TYPE" ]]
then
echo -e "${ITALICYELLOW}Info: No build type specified. Using ${BOLDYELLOW}Release${ENDCOLOR}${ITALICYELLOW} as default build type.${ENDCOLOR}"
BUILD_TYPE="Release"
fi
# Check if BUILD_TYPE has a valid value
if [[ "$BUILD_TYPE" != "Debug" ]] && [[ "$BUILD_TYPE" != "Release" ]] && [[ "$BUILD_TYPE" != "RelWithDebInfo" ]]
then
echo -e "${BOLDRED}Error: Invalid BUILD_TYPE specified. Valid options are: ${ENDCOLOR}${ITALICRED}Debug, Release, RelWithDebInfo${ENDCOLOR}"
exit 1
fi
cmake -DCMAKE_CONFIGURATION_TYPES="${BUILD_TYPE}" -G Xcode -T buildsystem=12 -S . -B projects/