-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmake_build.sh
executable file
·142 lines (137 loc) · 4.1 KB
/
cmake_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
#!/bin/sh
USE_JAVA=0
USE_DOTNET=0
USE_PHP=0
WORKING_DIR=
MG_CPU=32
MG_ARCH=x86
DOTNET_RID=unknown
DISTRO=$(./get_distro.sh)
while [ $# -gt 0 ]; do # Until you run out of parameters...
case "$1" in
--with-java)
USE_JAVA=1
;;
--with-dotnet)
USE_DOTNET=1
;;
--with-php)
USE_PHP=1
;;
--cpu)
if [ "$2" = "64" ]; then
MG_CPU=64
MG_ARCH=x64
fi
shift
;;
--working-dir)
WORKING_DIR=$2
shift
;;
--version)
MG_VERSION=$2
MG_VER_MAJOR=`echo "$2" | cut -d "." -f 1`
MG_VER_MINOR=`echo "$2" | cut -d "." -f 2`
MG_VER_REV=`echo "$2" | cut -d "." -f 3`
MG_VER_BUILD=`echo "$2" | cut -d "." -f 4`
shift
;;
--help)
echo "Usage: $0 (options)"
echo "Options:"
echo " --version [major.minor.rev.build]"
echo " --cpu [32|64]"
echo " --working-dir [build working directory]"
echo " --with-java [build with java support]"
echo " --with-dotnet [build with .net Core support]"
echo " --with-php [build with PHP support]"
echo " --help [Display usage]"
exit
;;
esac
shift # Check next set of parameters.
done
if [ -z $DISTRO ]; then
DISTRO=linux-generic
echo "[warning]: Could not determine distro, falling back to linux-generic"
fi
if test $USE_DOTNET -eq 1; then
echo "Checking for dotnet CLI"
which dotnet
if test "$?" -ne 0; then
exit 1
fi
DOTNET_RID=`dotnet --info | grep "RID:" | awk '{print $2}'`
fi
echo "Testing for CMake"
which cmake
if test "$?" -ne 0; then
echo "[error]: Not found: cmake"
echo "[error]: Please install CMake"
exit 1
fi
THIS_DIR=`pwd`
if [ -z $WORKING_DIR ]; then
echo "[error]: Please set working directory"
echo "Usage: cmake_build.sh --working-dir <path_to_working_directory>"
exit 1
fi
PACKAGE_DIR=$THIS_DIR/packages
if [ ! -d $WORKING_DIR/${MG_ARCH}_release ]; then
mkdir -p $WORKING_DIR/${MG_ARCH}_release
fi
if [ ! -d $PACKAGE_DIR ]; then
mkdir -p $PACKAGE_DIR
fi
cd $WORKING_DIR/${MG_ARCH}_release
if test "$?" -ne 0; then
exit 1
fi
cmake -DCMAKE_BUILD_TYPE=Release -DMG_DISTRO=$DISTRO -DMG_DOTNET_RID=$DOTNET_RID -DMG_CPU=$MG_CPU -DWITH_JAVA=$USE_JAVA -DWITH_DOTNET=$USE_DOTNET -DWITH_PHP=$USE_PHP $THIS_DIR
if test "$?" -ne 0; then
exit 1
fi
make
if test "$?" -ne 0; then
exit 1
fi
make install
if test "$?" -ne 0; then
exit 1
fi
echo "Building Sample dataset"
cd $THIS_DIR/src/TestData/Samples/Sheboygan
./build.sh
if test "$?" -ne 0; then
exit 1
fi
if test $USE_JAVA -eq 1; then
if [ -f $THIS_DIR/packages/Java/Release/${MG_ARCH}/${DISTRO}/libMapGuideJavaApi.so ]; then
echo "Stripping Java glue library"
strip -s $THIS_DIR/packages/Java/Release/${MG_ARCH}/${DISTRO}/libMapGuideJavaApi.so
else
echo "No Java glue library found to strip"
fi
cd $THIS_DIR/src/Managed/Java
echo "Building java classes..."
$JAVA_HOME/bin/javac -classpath . org/osgeo/mapguide/*.java
echo "Building JAR file"
$JAVA_HOME/bin/jar cf $THIS_DIR/packages/Java/Release/${MG_ARCH}/MapGuideApi.jar org/osgeo/mapguide/*.class
echo "Building -sources JAR file"
$JAVA_HOME/bin/jar cf $THIS_DIR/packages/Java/Release/${MG_ARCH}/MapGuideApi-sources.jar org/osgeo/mapguide/*.java
fi
if test $USE_DOTNET -eq 1; then
if [ -f $THIS_DIR/src/Managed/DotNet/MapGuideDotNetApi/runtimes/${DOTNET_RID}/native/libMapGuideDotNetUnmanagedApi.so ]; then
echo "Stripping .net glue library"
strip -s $THIS_DIR/src/Managed/DotNet/MapGuideDotNetApi/runtimes/${DOTNET_RID}/native/libMapGuideDotNetUnmanagedApi.so
else
echo "No .net glue library found to strip"
fi
cd $THIS_DIR/src/Managed/DotNet/MapGuideDotNetApi
dotnet restore
if test "$?" -ne 0; then
exit 1
fi
dotnet pack --configuration Release --output "$THIS_DIR/packages"
fi