This repository has been archived by the owner on Apr 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnewproject.sh
executable file
·199 lines (164 loc) · 5.96 KB
/
newproject.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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/usr/bin/env bash
# Copyright (c) 2020-2021 Eli Aloni a.k.a elix22.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ********************************************************************
#
# newproject.sh
#
# This script generates a set of project files.
# The new project will be based of the template project and
# it will be generated with the name and location that is specified
# as input parameters.
#
# IMPORTANT: This script must be run from the root of the
# source tree.
#
# ********************************************************************
#Find out which OS we're on.
unamestr=$(uname)
# Switch-on alias expansion within the script
shopt -s expand_aliases
#Alias the sed in-place command for OSX and Linux - incompatibilities between BSD and Linux sed args
if [[ "$unamestr" == "Darwin" ]]; then
alias aliassedinplace='sed -i ""'
else
#For Linux, notice no space after the '-i'
alias aliassedinplace='sed -i""'
fi
if [ ! -f ~/.urhonet_config/urhonethome ]; then
echo "1 Urho.Net is not configured , configuring now "
./configure.sh
fi
URHONET_HOME_ROOT=$(cat ~/.urhonet_config/urhonethome)
if [ ! -d "$URHONET_HOME_ROOT" ]; then
echo "Urho.Net is not configured , please run configure.sh (configure.bat on Windows) from Urho.Net installation folder "
exit -1
else
echo "URHONET_HOME_ROOT=$URHONET_HOME_ROOT"
fi
echo
echo "1. Enter a name for the new project."
echo
echo " This name will be given to the project"
echo " executable and a folder with this name"
echo " will be created to store all project files."
echo " Ex. foobar"
echo
read -p "Project Name: " projName
if [[ "$projName" == "" ]]; then
echo
echo "ERROR: No project name specified."
echo
exit -1;
fi
echo
projName="$(echo -e "${projName}" | tr -d '[:space:]')"
projectNameLower=$(echo ${projName} | tr 'A-Z' 'a-z')
title=${projName}
className=${projName}
echo
echo "3. Enter a unique identifier for your project."
echo
echo " This should be a human readable package name,"
echo " containing at least two words separated by a"
echo " period."
echo " Ex. com.example.foobar"
echo
read -p "Unique ID: " uuid
if [[ "$uuid" == "" ]]; then
echo
echo "ERROR: No uuid specified."
echo
exit -1;
fi
echo
uuid=$(echo ${uuid} | sed 's/'${projectNameLower}'//g' )
uuid=${uuid}.${projectNameLower}
uuid=$(echo "$uuid" | tr . /)
for i in {1..10}
do
uuid=`echo "$uuid" | sed 's_//_/_g'`
done
uuid=$(echo "$uuid" | tr / .)
java_package_path=$(echo "$uuid" | tr . /)
for i in {1..10}
do
java_package_path=`echo "$java_package_path" | sed 's_//_/_g'`
done
java_package_path=`echo "java/$java_package_path"`
echo
echo "5. Enter the project path."
echo
echo " This can be a relative path, absolute path,"
echo " or empty for the current folder. Note that"
echo " a project folder named $projName will also"
echo " be created inside this folder."
echo " Ex. ./samples"
echo
read -p "Path: " location
if [[ "$location" == "" ]]; then
projPath=$projName
else
projPath="$location/$projName"
fi
echo
# Verify Path and eliminate double '//'
projPath=`echo "$projPath" | sed 's_//_/_g'`
if [ -e $projPath ]; then
echo
echo "ERROR: Path '$projPath' already exists, aborting."
echo
exit -2
fi
# Make required source folder directories
mkdir -p "$projPath"
currPwd=`pwd`
projPath=`cd $projPath; pwd`
`cd $currPwd`
mkdir "-p" "$projPath/References"
cp "-f" "template/libs/dotnet/urho/desktop/UrhoDotNet.dll" "$projPath/References/"
cp "-f" "template/libs/dotnet/urho/desktop/UrhoDotNet.xml" "$projPath/References/"
cp "-r" "template/.vscode" "$projPath"
cp "-r" "template/script" "$projPath"
aliassedinplace "s*TEMPLATE_PROJECT_UUID*$uuid*g" "$projPath/script/project_vars.sh"
aliassedinplace "s*TEMPLATE_PROJECT_NAME*$projName*g" "$projPath/script/project_vars.sh"
aliassedinplace "s*TEMPLATE_JAVA_PACKAGE_PATH*$java_package_path*g" "$projPath/script/project_vars.sh"
aliassedinplace "s*TEMPLATE_PROJECT_UUID*$uuid*g" "$projPath/script/build-android.sh"
cp "-r" "template/Assets" "$projPath"
cp "-r" "template/include" "$projPath"
cp "-r" "template/Source" "$projPath"
mv "$projPath/Source/template.cs" "$projPath/Source/${projName}.cs"
aliassedinplace "s*TEMPLATE_PROJECT_NAME*$projName*g" "$projPath/Source/${projName}.cs"
aliassedinplace "s*TEMPLATE_CLASS_NAME*$className*g" "$projPath/Source/${projName}.cs"
aliassedinplace "s*TEMPLATE_PROJECT_NAME*$projName*g" "$projPath/Source/Sample.cs"
aliassedinplace "s*TEMPLATE_PROJECT_NAME*$projName*g" "$projPath/Source/JoystickLayoutPatches.cs"
cp "template/Program.cs" "$projPath/Program.cs"
aliassedinplace "s*TEMPLATE_PROJECT_NAME*$projName*g" "$projPath/Program.cs"
aliassedinplace "s*TEMPLATE_CLASS_NAME*$className*g" "$projPath/Program.cs"
cp "template/template.csproj" "$projPath/$projName.csproj"
mkdir "-p" "$projPath/tools"
cp "-r" "tools/ReferenceAssemblyResolver" "$projPath/tools"
cp "-R" "tools/bash_mini/." "$projPath/tools/bash"
echo "Successful creation"
echo "Project name : '$projName'"
echo "Unique identifier : '$uuid'"
echo "Project path : '$projPath'"
code $projPath