forked from SINTEF/dlite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap-win.sh
137 lines (122 loc) · 3.66 KB
/
bootstrap-win.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
#
# Check and modify the path of the variables below.
#
# To play nice with git, leave this file untouched and add your updated
# variables to bootstrap-win-user.sh
#
# Run this script with (tested with git bash)
#
# sh bootstrap-win.sh
#
#
# Init environment variables
#
GENERATOR="Visual Studio 15 2017 Win64"
BUILD_DIR=build-VS
ROOT_PATH="$(realpath $(pwd)/..)"
PATH="$CMAKE_PATH:$SWIG_PATH:$MAKE_PROGRAM_PATH:$ROOT_PATH/local/bin:$PATH"
INSTALL_PREFIX="$ROOT_PATH/local"
CMAKE_PATH="/c/Program Files/CMake/bin/cmake"
WITH_HDF5=OFF
HDF5_VERSION="1.10.4"
WITH_PYTHON=ON
SWIG_DIR="$INSTALL_PREFIX/swigwin-4.0.2/Lib"
SWIG_EXECUTABLE="$INSTALL_PREFIX/swigwin-4.0.2/swig"
SWIG_PATH="$HOME/source/repos/local/swigwin-4.0.1"
#
# Setup the shell
#
set -e # Stop on first error
set -x # Print commands as they are executed
#
# You normally don't need to modify the lines below
# =================================================
#
# Source user defaults from bootstrap-win-user.sh
#
if [ -f bootstrap-win-user.sh ]; then
source bootstrap-win-user.sh
fi
#
# Build and install jansson
#
if [ ! "$WITH_JSON" = OFF ] && [ ! -f $INSTALL_PREFIX/lib/jansson.lib ]; then
cd "$ROOT_PATH"
if [ ! -d jansson ]; then
git clone https://github.com/akheron/jansson.git
fi
cd jansson
mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
cmake \
-G "$GENERATOR" \
-DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_PREFIX" \
-DJANSSON_BUILD_SHARED_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DJANSSON_BUILD_DOCS=OFF \
..
cmake --build . --config Debug --target install
cmake --build . --config Release --target install
fi
#
# Build and install hdf5
#
if [ ! "$WITH_HDF5" = OFF ] && [ ! -f $INSTALL_PREFIX/lib/libhdf5.lib ]; then
cd $ROOT_PATH
if [ ! -d hdf5-$HDF5_VERSION ]; then
TARFILE=hdf5-$HDF5_VERSION.tar.gz
if [ ! -f $TARFILE ]; then
curl https://support.hdfgroup.org/ftp/HDF5/current/src/$TARFILE \
--output $TARFILE
fi
tar -zxvf $TARFILE
fi
cd hdf5-$HDF5_VERSION
mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
cmake \
-G "$GENERATOR" \
-DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_PREFIX" \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DBUILD_SHARED_LIBS=OFF \
..
cmake --build . --config Debug --target install
cmake --build . --config Release --target install
fi
#
# Configure and generate dlite project
#
cd $ROOT_PATH/dlite
git submodule update --init
mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
#
# Set up environment
config=Release
export PATH="src/$config:src/utils/$config:$PATH"
export LD_LIBRARY_PATH="src/$config:src/utils/$config:$LD_LIBRARY_PATH"
export PYTHONPATH="bindings/python/dlite"
export DLITE_STORAGE_PLUGIN_DIRS="storages/json/$config:storages/hdf5/$config:storages/python/$config"
export DLITE_MAPPING_PLUGIN_DIRS="src/pyembed"
export DLITE_PYTHON_STORAGE_PLUGIN_DIRS="storages/python/python-storage-plugins"
export DLITE_PYTHON_MAPPING_PLUGIN_DIRS="bindings/python/mapping-plugins"
export DLITE_TEMPLATE_DIRS="../tools/templates"
export DLITE_STORAGES="../examples/storages/*.json"
#
# Build
cmake \
-G "$GENERATOR" \
-DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_PREFIX" \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DWITH_HDF5=$WITH_HDF5 \
-DHDF5_DIR="$INSTALL_PREFIX/cmake/hdf5" \
-DHDF5_ROOT="$INSTALL_PREFIX" \
-DWITH_PYTHON=$WITH_PYTHON \
-DSWIG_DIR="$SWIG_DIR" \
-DSWIG_EXECUTABLE="$SWIG_EXECUTABLE" \
..
cmake --build . --config $config
# Build in Debug mode doesn't work since we then will try to link to
# python37_d.lib which doesn't exists
#cmake --build . --config Debug
#
# Tests
#
ctest