forked from nanoboard/nanoboard
/
build.sh
165 lines (129 loc) · 5.78 KB
/
build.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
#!/bin/bash
# RUN THIS AS:
# sh build.sh compiler_name program_name
# or as ./build.sh compiler_name program_name
#where compiler_name "msbuild" or "xbuild",
#program_name "nanodb", "fractalgen", "nbpack", or dll's ("chaos", or "newtonsoft"), or "all" - to build this all.
echo "Usage. RUN THIS AS:"
echo " \"sh build.sh compiler_name program_name\""
echo " or as \"./build_all compiler_name program_name\""
echo ", where:"
echo " compiler_name \"msbuild\" or \"xbuild\""
echo " program_name:"
echo " (programs)"
echo " \"nanodb\","
echo " \"fractalgen\","
echo " \"nbpack\", "
echo " (or DLLs)"
echo " \"chaos\" or \"newtonsoft\","
echo " or \"all\" - to build this all (DLLs and programs)."
echo ""
echo "Press Ctrl+C to exit, and specify arguments, or wait 10 seconds to start building process..."
#sleep 10 seconds, after show usage...
sleep 1
echo "Start building..."
# install xbuild
#sudo apt-get install monodevelop mono-gmcs
# if mono-gmcs not installed, try this
#sudo apt-get update -y
#sudo apt-get install -y mono-gmcs
# or this
#sudo apt-get install mono-reference-assemblies-4.0 mono-devel mono-xbuild mono-mcs mono-devel
# or just this:
#sudo apt update
#sudo apt install mono-xbuild
# then
if [ "$1" = "xbuild" ] ; then
#if "xbuild" build with xbuild
compiler="xbuild"
elif [ "$1" = "msbuild" ] || [ -z "$1" ] ; then
#else, build with msbuild
compiler="msbuild"
fi
#use value for "$program" from second argument
program="$2"
# combine as a string, the compilation command
if [ -z "$program" ] || [ "$program" = "nanodb" ] ; then
# to compile "nanodb.exe", with Main Class: NBC.MainClass
cmd="$compiler /p:Configuration=Release /property:StartupObject=NDB.MainClass /property:AssemblyName=nanodb nanodb.csproj"
dir="obj/x86/Release/"
outfile="nanodb.exe"
elif [ "$program" = "fractalgen" ] ; then
# or to compile "FractalGen.exe", with Main Class: fractalgen.Program
cmd="$compiler /p:Configuration=Release /property:StartupObject=fractalgen.Program /property:AssemblyName=FractalGen nanodb.csproj"
dir="obj/x86/Release/"
outfile="FractalGen.exe"
elif [ "$program" = "nbpack" ] ; then
# or to compile "NBPack.exe" with Main Class: nbpack.NBPackMain
cmd="$compiler /p:Configuration=Release /property:StartupObject=nbpack.NBPackMain /property:AssemblyName=NBPack nanodb.csproj"
dir="obj/x86/Release/"
outfile="NBPack.exe"
elif [ "$program" = "chaos" ] ; then
# or to compile "Chaos.NaCl.dll" from the source code
cmd="$compiler /property:Configuration=Release Chaos.NaCl.dll/Chaos.NaCl-master/Chaos.NaCl/Chaos.NaCl.csproj"
dir="bin/Release/"
outfile="Chaos.NaCl.dll"
elif [ "$program" = "newtonsoft" ] ; then
# or to compile "NewtonSoft.Json.dll" from the source code
cmd="$compiler /property:Configuration=Release Newtonsoft.JSON.dll/Newtonsoft.Json-7.0.1/Src/Newtonsoft.Json/Newtonsoft.Json.Net40.csproj"
dir="Newtonsoft.JSON.dll/Newtonsoft.Json-7.0.1/Src/Newtonsoft.Json/bin/Release/Net40/"
outfile="Newtonsoft.Json.dll"
cp "$dir$outfile" "bin/Release/$outfile"
dir="bin/Release/"
elif [ "$program" = "all" ] ; then
# ELSE - BUILD THIS ALL.
# compile "Chaos.NaCl.dll" from the source code
cmd="$compiler /property:Configuration=Release Chaos.NaCl.dll/Chaos.NaCl-master/Chaos.NaCl/Chaos.NaCl.csproj"
dir="bin/Release/"
outfile="Chaos.NaCl.dll"
eval $cmd
cp "$dir$outfile" "../$outfile"
# compile "NewtonSoft.Json.dll" from the source code
cmd="$compiler /property:Configuration=Release Newtonsoft.JSON.dll/Newtonsoft.Json-7.0.1/Src/Newtonsoft.Json/Newtonsoft.Json.Net40.csproj"
dir="Newtonsoft.JSON.dll/Newtonsoft.Json-7.0.1/Src/Newtonsoft.Json/bin/Release/Net40/"
outfile="Newtonsoft.Json.dll"
cp "$dir$outfile" "bin/Release/$outfile"
dir="bin/Release/"
eval $cmd
cp "$dir$outfile" "../$outfile"
# compile "NBPack.exe" with Main Class: nbpack.NBPackMain
cmd="$compiler /p:Configuration=Release /property:StartupObject=nbpack.NBPackMain /property:AssemblyName=NBPack nanodb.csproj"
dir="obj/x86/Release/"
outfile="NBPack.exe"
eval $cmd
cp "$dir$outfile" "../$outfile"
# compile "FractalGen.exe", with Main Class: fractalgen.Program
cmd="$compiler /p:Configuration=Release /property:StartupObject=fractalgen.Program /property:AssemblyName=FractalGen nanodb.csproj"
dir="obj/x86/Release/"
outfile="FractalGen.exe"
eval $cmd
cp "$dir$outfile" "../$outfile"
# compile "nanodb.exe", with Main Class: NBC.MainClass
cmd="$compiler /p:Configuration=Release /property:StartupObject=NDB.MainClass /property:AssemblyName=nanodb nanodb.csproj"
dir="obj/x86/Release/"
outfile="nanodb.exe"
fi
# Run command from this combined string:
eval $cmd
# After this, "$outfile" must to be exists in "obj/x86/Release/nanodb.exe" and in "bin/Release/nanodb.exe"
# Copy this in the main folder
cp "$dir$outfile" "../$outfile"
# Copy Newtonsoft.Json.dll and put it near program:
cp "bin/Debug/Newtonsoft.Json.dll" "bin/Release/Newtonsoft.Json.dll"
cp "bin/Debug/Newtonsoft.Json.dll" "../Newtonsoft.Json.dll"
# Copy Chaos.NaCl.dll and put it near program:
cp "bin/Debug/Chaos.NaCl.dll" "bin/Release/Chaos.NaCl.dll"
cp "bin/Debug/Chaos.NaCl.dll" "../Chaos.NaCl.dll"
# Copy nanodb.sqlite3.sql and put it near program:
cp "Database/nanodb.sqlite3.sql" "../nanodb.sqlite3.sql"
# Copy Mono.Data.Sqlite.dll and put it near program:
cp "bin/Debug/Mono.Data.Sqlite.dll" "../Mono.Data.Sqlite.dll"
# Copy System.Data.SQLite.dll with SQLite.Interop.dll, inside, and rename System.Data.SQLite.dll to sqlite3.dll, to allow access this sqlite3.dll, from Mono.Data.SQLite.dll, when nanodb running on windows.
cp "bin/Debug/System.Data.Sqlite.dll" "../sqlite3.dll"
# Go to this folder
cd ../
# and run program_name after compilation
if [ "$2" != "chaos" ] && [ "$2" != "newtonsoft" ]; then
# if not dll, then ".exe", run this
mono --runtime=v4.0.30319 $outfile
fi