This repository has been archived by the owner on Jan 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate
executable file
·162 lines (135 loc) · 4.2 KB
/
create
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/bash
srcpath="$( cd "$( dirname "$0" )" && pwd )"
relink=''
update=''
ios=''
android=''
print_usage() {
printf "
Usage: [-d destinationPath] [-l] [-u] [-i] [-a] projectName
projectName Name of the project
-d destinationPath The destination path of the project, Projects/projectName if omitted
-l To relink the Cacao directory if it is broken
-u To update the old Cacao project to new
-i To add support for ios project
-a To add support for android project
For Example:
./create
./create MyProject
./create -l -d ./cloned_path/cloned_project
-h Show the help text
"
}
fix_link() {
if [ -L "$copypath/Cacao" ]; then
rm "$copypath/Cacao"
fi
relpath=`python -c "import os.path; print(os.path.relpath('$srcpath/Source/Cacao', '$copypath'))"`
cd "$copypath"
ln -s $relpath Cacao
}
copy_files() {
cp "$srcpath/Template/.gitignore" "$copypath"
cp "$srcpath/Template/README.md" "$copypath"
cp "$srcpath/Template/CacTemplate.sublime-project" "$copypath/$projname.sublime-project"
sed -i '' "s/CacTemplate/$projname/g" "$copypath/CMakeLists.txt"
sed -i '' "s/CacTemplate/$projname/g" "$copypath/README.md"
sed -i '' "s/CacTemplate/$projname/g" "$copypath/$projname.sublime-project"
}
copy_not_custom() {
cp "$srcpath/Template/CMakeLists.txt" "$copypath"
sed -i '' "s/# sdk//g" "$copypath/CMakeLists.txt"
sed -i '' "s/# platform//g" "$copypath/CMakeLists.txt"
}
copy_android() {
cp "$srcpath/Template/Android/CMakeLists.txt" "$copypath"
if [ -z ${CACAO_ANDROID_NDK+x} ]; then
echo "Note: set the \$CACAO_ANDROID_NDK environment variable to remove this prompt"
read -p "Android NDK Location (required) " CACAO_ANDROID_NDK
fi
if [ -z ${CACAO_GD_APK_FILE+x} ]; then
echo "Note: set the \$CACAO_GD_APK_FILE environment variable to remove this prompt"
read -p "Geometry Dash APK Location (required) " CACAO_GD_APK_FILE
fi
sed -i '' "s/_ndk/$CACAO_ANDROID_NDK/g" "$copypath/CMakeLists.txt"
sed -i '' "s/_apk/$CACAO_GD_APK_FILE/g" "$copypath/CMakeLists.txt"
}
copy_ios() {
cp "$srcpath/Template/iOS/CMakeLists.txt" "$copypath"
cp "$srcpath/Template/iOS/control" "$copypath"
if [ -z ${CACAO_IOS_SDK+x} ]; then
echo "Note: set the \$CACAO_IOS_SDK environment variable to remove this prompt"
read -p "iPhoneOS SDK Location (required) " CACAO_IOS_SDK
fi
bundle=""
read -p "Bundle Identifier [com.example.gdmod] " bundle
bundle=${bundle:-"com.example.gdmod"}
author=""
read -p "Author [Someone] " author
author=${author:-Someone}
desc=""
read -p "Description [My cool gd mod] " desc
desc=${desc:-"My cool gd mod"}
sed -i '' "s&_sdk&$CACAO_IOS_SDK&g" "$copypath/CMakeLists.txt"
sed -i '' "s/%name/$projname/g" "$copypath/control"
sed -i '' "s/%author/$author/g" "$copypath/control"
sed -i '' "s/%bundle/$bundle/g" "$copypath/control"
sed -i '' "s/%desc/$desc/g" "$copypath/control"
}
while getopts 'd:lhuia' flag; do
case "${flag}" in
d) copypath="${OPTARG}" ;;
l) relink='true' ;;
u) update='true' ;;
i) ios='true' ;;
a) android='true' ;;
h) print_usage
exit 0 ;;
*) print_usage
exit 1 ;;
esac
done
shift $((OPTIND-1))
projname="${1:-Default Project}"
if [ -z "$copypath" ]; then
if [[ -z "${CACAO_PROJECT_FOLDER}" ]]; then
copypath="$projname"
else
copypath="${CACAO_PROJECT_FOLDER}/$projname"
fi
fi
if (( $# + $OPTIND > 1 )); then
echo $projname
if [ "$relink" = 'true' ]; then
echo "Fixing link"
fix_link
elif [ "$update" = 'true' ]; then
echo "Updating project"
copy_files
fix_link
else
if [ ! -d "$copypath" ]; then
echo "Creating folder"
mkdir -p "$copypath"
fi
echo "Copying files"
touch "$copypath/main.cpp"
echo "#define PROJECT_NAME \"$projname\"" >> "$copypath/main.cpp"
cat "$srcpath/Template/main.cpp" >> "$copypath/main.cpp"
copy_files
if [ "$ios" = 'true' ]; then
echo 'ios mode'
copy_ios
elif [ "$android" = 'true' ]; then
echo 'android mode'
copy_android
else
copy_not_custom
fi
fix_link
fi
echo "Done."
else
print_usage
exit 1
fi