-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcreate-project.sh
executable file
·128 lines (110 loc) · 3.77 KB
/
create-project.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
#!/usr/bin/env bash
windows=false
# Used to automatically find and add the Visual Studio MSBuild.exe directory to the environment variables!
function find_visual_studio_directory()
{
env | grep "OS=Windows" > /dev/null && windows=true
if [ "${windows}" = true ]; then
wd=$(pwd)
cd "C:/Program Files (x86)/Microsoft Visual Studio/Installer/" || exit
find "vswhere.exe" -maxdepth 0 &> /dev/null || (cd "${wd}" && download_vswhere)
VSShortVer=$(./vswhere.exe | grep "catalog_productLine: Dev17")
VSShortVer="${VSShortVer:24}"
VSVer=$(./vswhere.exe | grep "catalog_productLineVersion:")
VSVer="${VSVer:28}"
cd "${wd}" || exit
fi
return
}
function create_folders()
{
cd Projects/ || exit
mkdir "${prjname}" || echo "Project already exists!"
cd "${prjname}" || exit
# Create folders and files to be used as configs
mkdir Source || echo "Project already exists!"
mkdir Generated || echo "Project already exists!"
mkdir build || echo "Project already exists!"
mkdir Exported || echo "Project already exists!"
# Copy the config template we want
cp -r ../../Config .
cp -r ../../Content .
cp ../../export.sh .
mkdir Config/cmake || die
touch Config/cmake/"${prjname}".cmake && echo "\
function(custom_setup_step)
endfunction()
function(custom_compile_step)
endfunction()" > Config/cmake/"${prjname}".cmake
# We create a project file which will be used to configure our generated files
touch uvproj.yaml && echo "\
name: \"${prjname}\"
version: \"1.0.0.0\"
engine-version: \"1.0.0.0\"
build-mode-static: false
build-mode-vendor: true
system-wide: false
enabled-modules:
os: false
dbus: false
uexec: false
theming: false
ufont: false
i18n: false
undo-redo: false
plotting: false
knobs: false
spinners: false
toggles: false
text-utils: false
cli-parser: false
xdg: false
open: false" > uvproj.yaml
# Create symbolic links
if [ "${windows}" == true ]; then
cmd //c mklink //d .\\Framework ..\\..\\Framework && cmd //c mklink //d .\\UVKBuildTool ..\\..\\UVKBuildTool && return
fi
ln -s "../../Framework/" Framework 2> /dev/null || cp -r ../../Framework .
ln -s "../../UVKBuildTool/" UVKBuildTool 2> /dev/null || cp -r ../../UVKBuildTool .
}
function generate_files()
{
cd ../../UVKBuildTool/build || exit
if [ "${windows}" == true ]; then
./UVKBuildTool.exe --install ../../Projects/"${prjname}" || exit
else
./UVKBuildTool --install ../../Projects/"${prjname}" || exit
fi
cd ../../Projects/"${prjname}" || exit
}
function compile()
{
cd build || exit
if [ "${windows}" == true ]; then
cmake .. -G "Visual Studio ${VSShortVer} ${VSVer}" -DCMAKE_BUILD_TYPE=RELEASE || exit
MSBuild.exe "${prjname}".sln -property:Configuration=Release -property:Platform=x64 -property:maxCpuCount="${cpus}" || exit
cp ../UVKBuildTool/build/Release/UVKBuildToolLib.dll . || exit
elif [ "$2" == "wasm" ]; then
emcmake cmake .. -DCMAKE_BUILD_TYPE=RELEASE || exit
make -j "${cpus}" || exit
else
cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE || exit
make -j "${cpus}" || exit
fi
}
if [ "$1" != "" ]; then
prjname="$1"
headless=true
else
read -rp "Enter your application's name: " prjname # read the project name
fi
prjname=${prjname/ /} # Remove any spaces if the name contains them
cpus=$(grep -c processor /proc/cpuinfo 2> /dev/null) || cpus=$(sysctl -n hw.ncpu) # get the cpu threads for maximum performance when compiling. The second command is for macOS systems if we even try to support them
echo -e "\x1B[32mCopiling with ${cpus} compute jobs!\033[0m"
find_visual_studio_directory
create_folders "${prjname}"
generate_files "${prjname}"
if [ "$2" != "--skip-compilation" ]; then
compile "${prjname}" "$3"
fi
echo -e "\x1B[32mFramework and project successfully installed! \033[0m"