forked from jfnavarro/st_viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_cygwin.sh
executable file
·132 lines (102 loc) · 4.09 KB
/
build_cygwin.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
#!/bin/bash
# Normally the ST Viewer is built like this:
# sh build_cygwin.sh /path/to/stviewer/source production_build /your/result/dir
#
# If you need to edit the ST Viewer source code you can save compilation time if you run
# sh build_cygwin.sh /path/to/stviewer/source build_only_run_make /your/result/dir
set -ex
# THESE VARIABLES NEEDED TO BE CONFIGURED TO BE CORRECT FOR YOUR SYSTEM.
#
# Instead of hard coding the following paths we should be able to use something like
# what is described here: http://stackoverflow.com/a/15335686
# The cmake that is found in cygwin does not contain the "NMake Makefiles" generator
# so we need to use the version of cmake installed on Windows.
cmake_install_dir='/cygdrive/C/Program Files (x86)/CMake'
windows_cmake_filepath=`cygpath -w "${cmake_install_dir}/bin/cmake.exe"`
windows_ctest_filepath=`cygpath -w "${cmake_install_dir}/bin/ctest.exe"`
# Path to Visual Studio
msvc_vars_filepath='/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/vcvarsall.bat'
# Path to Qt
qt_bin='/cygdrive/c/Qt/5.7/msvc2013_64/bin'
qt_env_filepath="$qt_bin/qtenv2.bat"
# Shows the user the expected arguments.
function print_usage_and_exit {
echo "Usage: build_cygwin.sh path_to_st_client_source [ production_build | development_build | build_only ] result_dir" >&2
exit 1
}
# Check we have the correct number of args to the script:
if [ $# -ne 3 ]; then
echo -e "\nERROR: Incorrect number of arguments: expected 3.\n"
print_usage_and_exit
fi
# Check the user settings are correct:
if [ ! -f "$windows_cmake_filepath" ]; then
echo -e "\nERROR: CMake path '${windows_cmake_filepath}' was not found.\n"
exit 1
fi
if [ ! -f "$windows_ctest_filepath" ]; then
echo -e "\nERROR: CTest path '${windows_ctest_filepath}' was not found.\n"
exit 1
fi
if [ ! -f "$msvc_vars_filepath" ]; then
echo -e "\nERROR: Visual Studio's vcvarsall.bat file was not found at '$msvc_vars_filepath'.\n"
exit 1
fi
if [ ! -f "$qt_env_filepath" ]; then
echo -e "\nERROR: Qt env file 'qtenv2.bat' was not found at '$qt_env_filepath'.\n"
exit 1
fi
if ! [ $2 = "production_build" -o $2 = "development_build" -o $2 = "build_only" ]; then
print_usage_and_exit
fi
result_dir=`cygpath -w -a $3`
if [ ! -d "$result_dir" ]; then
echo "\nERROR: Result directory '$result_dir' does not exist.\n" >&2
print_usage_and_exit
fi
stclient_srcdir="$1"
if [ ! -d "$stclient_srcdir" ]; then
echo "\nERROR: Source code directory '$stclient_srcdir' does not exist.\n" >&2
print_usage_and_exit
fi
if [ $2 = "build_only" ]; then
stclient_builddir=`ls -dt1 /tmp/stclient.* | head -1`
if [ -z $stclient_builddir ]; then
echo -e "nERROR: could not find the last build dir for the stclient under /tmp/stclient.*\n" >&2
exit
fi
else
stclient_builddir=`mktemp -d /tmp/stclient.XXX`
fi
stclient_builddir_windows=`cygpath -w -a "$stclient_builddir"`
stclient_srcdir_windows=`cygpath -w -a "$stclient_srcdir"`
#"Visual Studio 11 Win64"
if [ $2 = "development_build" ]; then
build_type=Debug
fi
if [ $2 = "production_build" ]; then
build_type=Release
fi
# Paths to qcustomplot, openssl and the config file (public key is optional)
qcustomplot='/cygdrive/C/QCustomPlot'
ssl=
config=$stclient_srcdir_windows\\assets\\stviewer.conf
publickey=
if [ $2 = "build_only" ]; then
cmd="echo skipping running cmake"
else
cmd=""
fi
# When running ctest there was a problem with missing dll. The files were on the system but couldn't be found.
# A good command to diagnose this is "cygcheck".
# By setting the PATH environment variable, the missing dll files can be found.
export PATH="$ssl:$qcustomplot:$qt_bin:$PATH"
windows_msvc_vars_filepath=`cygpath -w "$msvc_vars_filepath"`
cmd /Q /C call "$windows_msvc_vars_filepath" x86_amd64 "&&" \
`cygpath -w "$qt_env_filepath"` "&&" \
cd "$stclient_builddir_windows" "&&" \
$cmd "$windows_cmake_filepath" -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=$build_type -DPUBLICKEY=$publickey -DCONFIG_FILE=$config "$stclient_srcdir_windows" "&&" \
nmake "&&" \
"$windows_ctest_filepath" "&&" \
nmake package
cp "$stclient_builddir"/*.exe "$result_dir"