Skip to content

Commit fa9688e

Browse files
Addition of windows build (#19)
Co-authored-by: nmcdonnell-kx <nmcdonnell@kx.com>
1 parent fc5fb70 commit fa9688e

File tree

17 files changed

+269
-124
lines changed

17 files changed

+269
-124
lines changed

.travis.yml

Lines changed: 88 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,105 @@
1+
matrix:
2+
include:
3+
- dist: xenial
4+
os: linux
5+
- dist: trusty
6+
os: linux
7+
- dist: bionic
8+
os: linux
9+
- os: osx
10+
- os: windows
111
language: c
2-
os:
3-
- linux
4-
- osx
5-
git:
6-
depth: 1
12+
compiler: gcc
713

8-
env:
9-
global:
10-
- HDF5_RELEASE_URL = "https://support.hdfgroup.org/ftp/HDF5/releases"
11-
- HDF5_HOME="/usr"
14+
before_install:
15+
- export FILE_ROOT="hdf5"
16+
- export TESTS="True"
17+
- export BUILD="True"
1218

13-
before_install:
14-
- chmod +x travis_setup.sh
15-
- ./travis_setup.sh
19+
# Run instructions to install the C/C++ requirements (BUILD_HOME) set in place of PAHO_HOME/HDF5_HOME etc.
20+
# Files in this case are unzipped into cbuild within travis_setup.sh
21+
- if [[ $BUILD == "True" ]]; then
22+
chmod +x travis_setup.sh;
23+
./travis_setup.sh;
24+
export BUILD_HOME=$TRAVIS_BUILD_DIR/cbuild
25+
export LIB="cmake/$FILE_ROOT/lib";
26+
mkdir cmake
27+
else
28+
export LIB="";
29+
fi
1630

17-
install:
18-
# We do this conditionally because it saves us some downloading if the
19-
# version is the same.
20-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
21-
wget https://repo.continuum.io/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh -O miniconda.sh;
31+
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then
32+
QLIBDIR=l64; OD=$L64;
33+
elif [[ $TRAVIS_OS_NAME == "osx" ]]; then
34+
QLIBDIR=m64; OD=$M64;
35+
elif [[ $TRAVIS_OS_NAME == "windows" ]]; then
36+
QLIBDIR=w64; OD=$W64;
2237
else
23-
wget https://repo.continuum.io/miniconda/Miniconda3-4.5.4-MacOSX-x86_64.sh -O miniconda.sh;
38+
echo "unknown OS ('$TRAVIS_OS_NAME')" >&2; exit 1;
2439
fi
25-
- bash miniconda.sh -b -p $HOME/miniconda
26-
- ls /usr/local/lib
27-
- export PATH="$HOME/miniconda/bin:$PATH"
28-
- echo $LD_LIBRARY_PATH
29-
- export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
30-
- hash -r
31-
- conda config --set always_yes yes --set changeps1 no
32-
- conda update -q conda
33-
# Useful for debugging any issues with conda
34-
- conda info -a
35-
- if [ $TRAVIS_OS_NAME = linux ]; then
36-
QLIBDIR=l64;
37-
elif [ $TRAVIS_OS_NAME = osx ]; then
38-
QLIBDIR=m64;
39-
else
40-
echo "unknown OS ('$TRAVIS_OS_NAME')" >&2; exit 1;
41-
fi; export QLIBDIR
42-
- conda install -c kx embedpy # grab kdb+ with conda
43-
- cp -r $(conda info --base)/q q && export QHOME=$(pwd)/q && export PATH=$QHOME/$QLIBDIR:$PATH
44-
# grab latest embedpy
45-
- if [[ "x$QLIC_KC" != "x" ]]; then
46-
echo -n $QLIC_KC |base64 --decode > q/kc.lic;
40+
41+
- export LD_LIBRARY_PATH=$BUILD_HOME/lib:$LD_LIBRARY_PATH
42+
- export DYLD_LIBRARY_PATH=$BUILD_HOME/lib:$DYLD_LIBRARY_PATH
43+
- export PATH=$BUILD_HOME/lib:$PATH
44+
- export PATH=$BUILD_HOME/bin:$PATH
45+
- export PATH=$BUILD_HOME/include:$PATH
46+
- export QLIBDIR
47+
- mkdir qhome
48+
- export QHOME=$(pwd)/qhome
49+
- export PATH=$QHOME/$QLIBDIR:$PATH
50+
51+
# Set up q for testing and execute tests on multiple
52+
- if [[ $TESTS == "True" && "x$OD" != "x" && "x$QLIC_KC" != "x" ]]; then
53+
curl -o qhome/q.zip -L $OD;
54+
unzip -d qhome qhome/q.zip;
55+
rm qhome/q.zip;
56+
echo -n $QLIC_KC |base64 --decode > qhome/kc.lic;
57+
else
58+
echo No kdb+, no tests;
4759
fi
48-
- mkdir build
49-
- cd build
50-
- cmake .. -DCMAKE_BUILD_TYPE=Release && make && make install
51-
- cd ..
5260

53-
script:
54-
- echo "Preparing version $TRAVIS_BRANCH-$TRAVIS_COMMIT"
55-
- cd build
56-
- tar -zcvf hdf5_$TRAVIS_OS_NAME-$TRAVIS_BRANCH.tgz hdf5
57-
- cd ..
58-
- echo "Packaged as hdf5_$TRAVIS_OS_NAME-$TRAVIS_BRANCH.zip"
59-
- if [[ "x$QLIC_KC" != "x" ]]; then
60-
curl -fsSL -o test.q https://github.com/KxSystems/embedpy/raw/master/test.q;
61-
q test.q tests/ -q;
61+
- if [[ $TRAVIS_OS_NAME == "windows" ]]; then
62+
export FILE_TAIL="zip";
63+
else
64+
export FILE_TAIL="tgz";
65+
fi
66+
- export FILE_NAME=$FILE_ROOT-$TRAVIS_OS_NAME-$TRAVIS_BRANCH.$FILE_TAIL
6267

63-
else
64-
echo No kdb+, no tests;
65-
fi
68+
# Make binaries for the library as appropriate
69+
- if [[ $BUILD == "True" && $TRAVIS_OS_NAME == "windows" ]]; then
70+
cd cmake && cmake -G "Visual Studio 15 2017 Win64" .. ;
71+
cmake --build . --config Release;
72+
cmake --build . --config Release --target install;
73+
cd ..;
74+
elif [[ $BUILD == "True" && ( $TRAVIS_OS_NAME == "linux" || $TRAVIS_OS_NAME == "osx" ) ]]; then
75+
cd cmake && cmake .. -DCMAKE_BUILD_TYPE=Release && make install && cd .. ;
76+
fi
77+
78+
script:
79+
- if [[ $TESTS == "True" && "x$OD" != "x" && "x$QLIC_KC" != "x" ]]; then
80+
q test.q tests/ -q;
81+
fi
82+
- if [[ $TRAVIS_OS_NAME == "windows" && $BUILD == "True" ]]; then
83+
7z a -tzip -r $FILE_NAME ./cmake/$FILE_ROOT/*;
84+
elif [[ $BUILD == "True" && ( $TRAVIS_OS_NAME == "linux" || $TRAVIS_OS_NAME == "osx" ) ]]; then
85+
tar -zcvf $FILE_NAME -C cmake/$FILE_ROOT .;
86+
elif [[ $TRAVIS_OS_NAME == "windows" ]]; then
87+
7z a -tzip $FILE_NAME README.md install.bat LICENSE q examples;
88+
elif [[ $TRAVIS_OS_NAME == "linux" || $TRAVIS_OS_NAME == "osx" ]]; then
89+
tar -zcvf $FILE_NAME README.md install.sh LICENSE q examples;
90+
fi
6691

6792
deploy:
6893
provider: releases
69-
api_key: "$GH_APIKEY"
70-
file_glob: true
71-
file: build/hdf5_$TRAVIS_OS_NAME-$TRAVIS_BRANCH.tgz
72-
skip_cleanup: true
94+
api_key: "$GITHUB_APIKEY"
95+
file: "$FILE_NAME"
7396
on:
7497
tags: true
98+
condition: $TRAVIS_OS_NAME = windows || $TRAVIS_OS_NAME = osx || ($TRAVIS_DIST = trusty && $TRAVIS_OS_NAME = linux)
99+
skip_cleanup: 'true'
75100

76101
notifications:
77102
slack:
78-
secure: "fDsGcgmkYyndvlN2NQlfqPrk0rfKVbDlp2Wg5pr/PZYCRY7rjXEwdby9T/tOpulQ6HXpdnqFN1zJ+5ih3XCwtLa4mPYRGWK3GvLNFvINTQDsYrCpgfQKxC6snBiGrUA0DoSAhS1nlB2igGoZSUSGi+sROsLiDn5aIqi3+Wz3JcFytISncWovO2bhedRjrFZXt4zmrDRpJ2BCShQdg2kppPGIDUHS0/xDElGtaHizLijeJjX/49xtABn7cLrv3wbVvejHU6yu5OdxOqtc98NYLV1lVPxiUIrjmvs/tlV4C6peGc1H9GioExThoWxW/KrMEL7biRxtTZzgqr+2W6+NWkzL74pMhqROOGvULH9DkfQxkjNNN6aLhN98oYswOgzg/UxM/F+Qolf948EWgcbg4USlAotd779YOfYPymYEeJlZTrvuYSazUdjUh6FkJtDYeiu7ZHkc75c4Fm8RNpxC6Kc4fO1Aq9ga0A8VoEzwIEscsMDvNC0hJjeFvglN0wie+jT23nNXnucTdgqxH9aCdub+ARcDEIXMS99WiYApHjbNK2WcTJYVDIKy1g1dO49oQMNLaHofaoO14OHw3OcWBlnHKhU2OWPuB0v0vqTeW8YAhGUewEmc5uwg6hYeVmE4ThDr4tiNDDyeCA6uTTN87oCguvlwrLF56vIEg0Sh4ok="
79-
103+
secure: "Czkq4kk2Pl2TyWnW1y7KP7YLndCyb3Qai+ISPikf1VyBZp358apYRkiQZC7D8wwgCG4V+HjDj9+XJK9SBYyXGVsEnA+KEKS+9YG0K/UIuo6gv8IOj3962chaB4HfZn5LO34oLuhIjZJA0u8s5lPFoLJktfcHFvJibc6kXlET6ZMt/tZIHhztMGSyCqL46oidnTGZJFGO3Gb9FkBB8NOPduvROZAa9mF0CBNdd2gzig5lPG7eXjQSbKxVDbKWW81zEs8CSmM/guC+2Ar+rpPO4RAFq7UgrK6Gdg2GN863L0tMTttxDYdTLD+Bjk6mUZVnr5vPvtgvqKU801pjqtSEjNjeV3ZN+E19359mlH1eQ/9Uv5HaB05i3CIvWUTodp1eQDFGsvixQMnD9PrzD+SbY5v6oDg/R0+pEHhPhRJ6v23OAmFyU90kn3VQQIFDMKufKSJE4jItoUBXhmavSHHU/sysH1n8YXCU0kuOFtWIK+t5RIFrhYuDvVcz8O4xF95oCdKXjX/jWTO+qGc+YU9WKieCwS8PXwqBJJA4V5D4KkzmJAX5Y2SqODYF/KOD59AedX9u7nlnTD3EHK5iGnnIVhAKyJq0kwLp3ikP7uZupddMg/6J8s0zg3r61GvxXaoPDTAzTn7MDEX7HQonX+IiUvfRQFIuT3VmQvv+pEeoDOw="
104+
105+

CMakeLists.txt

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,44 @@
11
# Environment variable for HDF5_HOME is required
2-
if(NOT DEFINED ENV{HDF5_HOME})
3-
message(FATAL_ERROR "HDF5_HOME must be set to the location of your installed hdf5-group repository")
2+
if(NOT DEFINED ENV{BUILD_HOME})
3+
message(FATAL_ERROR "BUILD_HOME must be set to the location of your installed hdf5-group repository")
44
endif()
55

66
# Default such that 'make install' moves binary & q script to QHOME
77
IF(NOT CMAKE_BUILD_TYPE)
88
SET(CMAKE_BUILD_TYPE MinSizeRel)
99
ENDIF()
1010

11-
cmake_minimum_required(VERSION 2.8)
11+
cmake_minimum_required(VERSION 3.0)
1212
project(hdf5 C)
1313

14-
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-strict-aliasing -DKXVER=3")
14+
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -DKXVER=3")
1515

16-
set(MY_LIBRARY_NAME hdf5)
16+
set(MY_LIBRARY_NAME kdbhdf5)
1717
file(GLOB C_FILES src/*.c)
1818
set_source_files_properties(${C_FILES} PROPERTIES LANGUAGE C)
1919

20-
include_directories($ENV{HDF5_HOME}/include)
20+
message(STATUS "Generator : ${CMAKE_GENERATOR}")
21+
message(STATUS "Build Tool : ${CMAKE_BUILD_TOOL}")
22+
message(STATUS "HDF5 API : $ENV{BUILD_HOME}")
23+
24+
include_directories($ENV{BUILD_HOME}/include)
2125

2226
find_library(HDF5_LIBRARY
2327
NAMES hdf5 libhdf5
24-
HINTS "$ENV{HDF5_HOME}/lib/"
28+
HINTS "$ENV{BUILD_HOME}/lib/"
2529
)
2630

31+
if (MSVC)
32+
file(DOWNLOAD "https://github.com/KxSystems/kdb/raw/master/w64/q.lib" "${CMAKE_BINARY_DIR}/q.lib" )
33+
set(LINK_LIBS "${CMAKE_BINARY_DIR}/q.lib")
34+
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3 /D H5_BUILT_AS_DYNAMIC_LIB /D WIN32_LEAN_AND_MEAN /D _CRT_SECURE_NO_WARNINGS")
35+
else()
36+
set(LINK_LIBS "")
37+
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-strict-aliasing")
38+
endif()
39+
2740
add_library (${MY_LIBRARY_NAME} SHARED ${C_FILES})
28-
target_link_libraries(${MY_LIBRARY_NAME} ${HDF5_LIBRARY})
41+
target_link_libraries(${MY_LIBRARY_NAME} ${HDF5_LIBRARY} ${LINK_LIBS})
2942

3043
# "-undefined dynamic_lookup" needed for building shared libraries on Mac
3144
# MacOS also produces binaries as .dylib, for kdb these should be ".so"
@@ -36,6 +49,7 @@ if(APPLE)
3649
set(INSTALL_SCRIPT install.sh)
3750
set(OSFLAG m)
3851
elseif(WIN32)
52+
set_target_properties(${MY_LIBRARY_NAME} PROPERTIES PREFIX lib)
3953
set(INSTALL_SCRIPT install.bat)
4054
set(OSFLAG w)
4155
else()
@@ -49,14 +63,14 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
4963
set(BITNESS 64)
5064
endif()
5165

66+
message(STATUS "Installing package to : ${PROJECT_BINARY_DIR}/hdf5")
67+
5268
# Minimum build/install move binary and q-script to $QHOME & $QHOME/<QARCH>
53-
install(TARGETS ${MY_LIBRARY_NAME} DESTINATION "$ENV{QHOME}/${OSFLAG}${BITNESS}/" CONFIGURATIONS MinSizeRel Release)
54-
install(FILES hdf5.q DESTINATION "$ENV{QHOME}" CONFIGURATIONS MinSizeRel Release)
69+
file(TO_CMAKE_PATH "$ENV{QHOME}" QHOME_PATH)
70+
install(TARGETS ${MY_LIBRARY_NAME} DESTINATION "${QHOME_PATH}/${OSFLAG}${BITNESS}/" CONFIGURATIONS MinSizeRel Release)
71+
install(DIRECTORY "q/" DESTINATION "${QHOME_PATH}" CONFIGURATIONS MinSizeRel Release FILES_MATCHING PATTERN "*.q")
5572

56-
# Required objects for release packaging
57-
install(FILES LICENSE DESTINATION ${PROJECT_BINARY_DIR}/hdf5 CONFIGURATIONS Release)
58-
install(FILES README.md DESTINATION ${PROJECT_BINARY_DIR}/hdf5 CONFIGURATIONS Release)
73+
install(FILES README.md LICENSE ${INSTALL_SCRIPT} DESTINATION ${PROJECT_BINARY_DIR}/hdf5 CONFIGURATIONS Release)
5974
install(DIRECTORY examples DESTINATION ${PROJECT_BINARY_DIR}/hdf5 CONFIGURATIONS Release)
60-
install(FILES install.sh DESTINATION ${PROJECT_BINARY_DIR}/hdf5 CONFIGURATIONS Release)
61-
install(FILES hdf5.q DESTINATION ${PROJECT_BINARY_DIR}/hdf5 CONFIGURATIONS Release)
75+
install(DIRECTORY q DESTINATION ${PROJECT_BINARY_DIR}/hdf5 CONFIGURATIONS Release)
6276
install(TARGETS ${MY_LIBRARY_NAME} DESTINATION ${PROJECT_BINARY_DIR}/hdf5/lib CONFIGURATIONS Release)

README.md

Lines changed: 69 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,49 +38,68 @@ If you have any HDF5 related questions, you can raise them on the [HDF Forum](ht
3838

3939
### Third-Party Library Installation
4040

41-
The following outlines instructions for installing the HDF5 group's C api for supported architectures.
41+
1. Install the HDF group's C api for your architecture
4242

4343
**Linux**
4444
- Download a supported release of hdf5 and install, instructions are provided [here](https://support.hdfgroup.org/HDF5/HDF5-FAQ.html#10).
4545

4646
**MacOS**
4747
- Run `brew install hdf5`
4848

49-
### Installing a release
49+
**Windows**
50+
- Install the windows C api for HDF5 following the instructions provided [here](https://support.hdfgroup.org/HDF5/faq/windows.html)
5051

51-
It is recommended that a user install this interface through a release. Installation of the interface from a release is completed in a number of steps
52+
2. Set an environment variable `$BUILD_HOME`/`%BUILD_HOME%` pointing to the location of the installed HDF group C api
53+
3. Make the HDF group C api for HDF5 available to kdb
5254

53-
1. Ensure you have downloaded/installed the HDF5 C api following the instructions [here](#third-party-library-installation)
54-
2. Download a release from [here](https://github.com/KxSystems/hdf5/releases) for your system architecture.
55-
3. Add the location of the 'lib' directory for the HDF5 C api to `LD_LIBRARY_PATH`/`DYLD_LIBRARY_PATH` for Linux or MacOS respectively.
55+
For Linux and MacOS, add the location of the 'lib' directory to `LD_LIBRARY_PATH`/`DYLD_LIBRARY_PATH` as appropriate
5656

57-
```
58-
## Linux
59-
export LD_LIBRARY_PATH=/usr/local/hdf5-c-api/lib/:$LD_LIBRARY_PATH
57+
```
58+
## Linux
59+
export LD_LIBRARY_PATH=$BUILD_HOME/lib/:$LD_LIBRARY_PATH
6060
61-
## MacOS
62-
export DYLD_LIBRARY_PATH=/Users/bob/hdf5-c-api/lib/:$DYLD_LIBRARY_PATH
63-
```
61+
## MacOS
62+
export DYLD_LIBRARY_PATH=$BUILD_HOME/lib/:$DYLD_LIBRARY_PATH
63+
```
6464

65-
4. Install required q executable script `hdf5.q` and binary file `lib/libhdf5.so` to `$QHOME` and `$QHOME/[ml](64)` respectively by executing the following from the Release directory
65+
For Windows, create links to the paho dll's in the %QHOME%\w64 directory. e.g.
6666

67-
```
68-
chmod +x install.sh
67+
```
68+
cd %QHOME%\w64
69+
MKLINK libhdf5.dll %BUILD_HOME%\lib\libhdf5.dll
70+
MKLINK hdf5.dll %BUILD_HOME%\lib\hdf5.dll
71+
```
72+
73+
### Installing a release
74+
75+
It is recommended that a user install this interface through a release. This is completed in a number of steps
76+
77+
1. Ensure you have downloaded/installed the HDF groups C api for HDF5 following the instructions [here](https://github.com/KxSystems/hdf5#third-party-library-installation)
78+
2. Download a release from [here](https://github.com/KxSystems/hdf5/releases)
79+
4. Install required q executable script `q/hdf5.q` and binary file `lib/libkdbhdf5.(so|dll)` to `$QHOME` and `$QHOME/[mlw](64)`, by executing the following from the Release directory
80+
81+
```
82+
## Linux/MacOS
83+
chmod +x install.sh && ./install.sh
84+
85+
## Windows
86+
install.bat
87+
```
6988

70-
./install.sh
71-
```
7289

7390
### Building interface from source and install
7491

7592
In order to successfully build and install this interface, the following environment variables must be set:
7693

77-
1. `HDF5_HOME` = Location of the HDF5 C api installation (directory containing `/include` and `/lib` subdirectories).
94+
1. `BUILD_HOME` = Location of the HDF5 C api installation (directory containing `/include` and `/lib` subdirectories).
7895
2. `QHOME` = Q installation directory (directory containing `q.k`).
7996

97+
#### Linux/MacOS
98+
8099
* Create a directory from which the execute the CMAKE command and move into this directory
81100

82101
```bash
83-
mkdir build && cd build
102+
mkdir cmake && cd cmake
84103
```
85104

86105
* Execute the `cmake` instructions
@@ -89,23 +108,50 @@ mkdir build && cd build
89108
cmake ..
90109
```
91110

92-
* generate the `libhdf5.so` binary
111+
* generate the `libkdbhdf5.so` binary
93112

94113
```bash
95114
make
96115
```
97116

98-
* Install the `libhdf5.so` binary into `$QHOME/[ml]64` and `hdf5.q` into `$QHOME`
117+
* Install the `libkdbhdf5.so` binary into `$QHOME/[ml]64` and `hdf5.q` into `$QHOME`
99118

100119
```bash
101120
make install
102121
```
103-
122+
123+
#### Windows
124+
125+
From a Visual Studio command prompt:
126+
127+
* Create an out-of-source directory for the CMake and object files.
128+
129+
```bash
130+
mkdir cmake && cd cmake
131+
```
132+
133+
* Generate the VS solution
134+
135+
```bash
136+
cmake ..
137+
```
138+
139+
* Build the interface DLL and create the installation package into sub-directory hdf5
140+
141+
```bash
142+
MSBuild.exe INSTALL.vcxproj /p:Configuration=Release /p:Platform=x64
143+
```
144+
145+
* Install the package (copies the shared object to%QHOME%/w64 )
146+
147+
```bash
148+
cd mqtt && install.bat
149+
```
150+
104151
## Unsupported Functionality
105152

106153
This interface is in active developement and as such there are a number of use-cases that are currently not supported.
107154

108-
- Use of this interface on Windows 64-bit systems
109155
- Creation of compressed datasets
110156
- Access to unlimited datasets
111157
- Interaction with HDF5 images

0 commit comments

Comments
 (0)