Skip to content

Commit

Permalink
Addition of windows build (#19)
Browse files Browse the repository at this point in the history
Co-authored-by: nmcdonnell-kx <[email protected]>
  • Loading branch information
cmccarthy1 and nmcdonnell-kx authored May 20, 2020
1 parent fc5fb70 commit fa9688e
Show file tree
Hide file tree
Showing 17 changed files with 269 additions and 124 deletions.
150 changes: 88 additions & 62 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,79 +1,105 @@
matrix:
include:
- dist: xenial
os: linux
- dist: trusty
os: linux
- dist: bionic
os: linux
- os: osx
- os: windows
language: c
os:
- linux
- osx
git:
depth: 1
compiler: gcc

env:
global:
- HDF5_RELEASE_URL = "https://support.hdfgroup.org/ftp/HDF5/releases"
- HDF5_HOME="/usr"
before_install:
- export FILE_ROOT="hdf5"
- export TESTS="True"
- export BUILD="True"

before_install:
- chmod +x travis_setup.sh
- ./travis_setup.sh
# Run instructions to install the C/C++ requirements (BUILD_HOME) set in place of PAHO_HOME/HDF5_HOME etc.
# Files in this case are unzipped into cbuild within travis_setup.sh
- if [[ $BUILD == "True" ]]; then
chmod +x travis_setup.sh;
./travis_setup.sh;
export BUILD_HOME=$TRAVIS_BUILD_DIR/cbuild
export LIB="cmake/$FILE_ROOT/lib";
mkdir cmake
else
export LIB="";
fi

install:
# We do this conditionally because it saves us some downloading if the
# version is the same.
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh -O miniconda.sh;
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then
QLIBDIR=l64; OD=$L64;
elif [[ $TRAVIS_OS_NAME == "osx" ]]; then
QLIBDIR=m64; OD=$M64;
elif [[ $TRAVIS_OS_NAME == "windows" ]]; then
QLIBDIR=w64; OD=$W64;
else
wget https://repo.continuum.io/miniconda/Miniconda3-4.5.4-MacOSX-x86_64.sh -O miniconda.sh;
echo "unknown OS ('$TRAVIS_OS_NAME')" >&2; exit 1;
fi
- bash miniconda.sh -b -p $HOME/miniconda
- ls /usr/local/lib
- export PATH="$HOME/miniconda/bin:$PATH"
- echo $LD_LIBRARY_PATH
- export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
# Useful for debugging any issues with conda
- conda info -a
- if [ $TRAVIS_OS_NAME = linux ]; then
QLIBDIR=l64;
elif [ $TRAVIS_OS_NAME = osx ]; then
QLIBDIR=m64;
else
echo "unknown OS ('$TRAVIS_OS_NAME')" >&2; exit 1;
fi; export QLIBDIR
- conda install -c kx embedpy # grab kdb+ with conda
- cp -r $(conda info --base)/q q && export QHOME=$(pwd)/q && export PATH=$QHOME/$QLIBDIR:$PATH
# grab latest embedpy
- if [[ "x$QLIC_KC" != "x" ]]; then
echo -n $QLIC_KC |base64 --decode > q/kc.lic;

- export LD_LIBRARY_PATH=$BUILD_HOME/lib:$LD_LIBRARY_PATH
- export DYLD_LIBRARY_PATH=$BUILD_HOME/lib:$DYLD_LIBRARY_PATH
- export PATH=$BUILD_HOME/lib:$PATH
- export PATH=$BUILD_HOME/bin:$PATH
- export PATH=$BUILD_HOME/include:$PATH
- export QLIBDIR
- mkdir qhome
- export QHOME=$(pwd)/qhome
- export PATH=$QHOME/$QLIBDIR:$PATH

# Set up q for testing and execute tests on multiple
- if [[ $TESTS == "True" && "x$OD" != "x" && "x$QLIC_KC" != "x" ]]; then
curl -o qhome/q.zip -L $OD;
unzip -d qhome qhome/q.zip;
rm qhome/q.zip;
echo -n $QLIC_KC |base64 --decode > qhome/kc.lic;
else
echo No kdb+, no tests;
fi
- mkdir build
- cd build
- cmake .. -DCMAKE_BUILD_TYPE=Release && make && make install
- cd ..

script:
- echo "Preparing version $TRAVIS_BRANCH-$TRAVIS_COMMIT"
- cd build
- tar -zcvf hdf5_$TRAVIS_OS_NAME-$TRAVIS_BRANCH.tgz hdf5
- cd ..
- echo "Packaged as hdf5_$TRAVIS_OS_NAME-$TRAVIS_BRANCH.zip"
- if [[ "x$QLIC_KC" != "x" ]]; then
curl -fsSL -o test.q https://github.com/KxSystems/embedpy/raw/master/test.q;
q test.q tests/ -q;
- if [[ $TRAVIS_OS_NAME == "windows" ]]; then
export FILE_TAIL="zip";
else
export FILE_TAIL="tgz";
fi
- export FILE_NAME=$FILE_ROOT-$TRAVIS_OS_NAME-$TRAVIS_BRANCH.$FILE_TAIL

else
echo No kdb+, no tests;
fi
# Make binaries for the library as appropriate
- if [[ $BUILD == "True" && $TRAVIS_OS_NAME == "windows" ]]; then
cd cmake && cmake -G "Visual Studio 15 2017 Win64" .. ;
cmake --build . --config Release;
cmake --build . --config Release --target install;
cd ..;
elif [[ $BUILD == "True" && ( $TRAVIS_OS_NAME == "linux" || $TRAVIS_OS_NAME == "osx" ) ]]; then
cd cmake && cmake .. -DCMAKE_BUILD_TYPE=Release && make install && cd .. ;
fi

script:
- if [[ $TESTS == "True" && "x$OD" != "x" && "x$QLIC_KC" != "x" ]]; then
q test.q tests/ -q;
fi
- if [[ $TRAVIS_OS_NAME == "windows" && $BUILD == "True" ]]; then
7z a -tzip -r $FILE_NAME ./cmake/$FILE_ROOT/*;
elif [[ $BUILD == "True" && ( $TRAVIS_OS_NAME == "linux" || $TRAVIS_OS_NAME == "osx" ) ]]; then
tar -zcvf $FILE_NAME -C cmake/$FILE_ROOT .;
elif [[ $TRAVIS_OS_NAME == "windows" ]]; then
7z a -tzip $FILE_NAME README.md install.bat LICENSE q examples;
elif [[ $TRAVIS_OS_NAME == "linux" || $TRAVIS_OS_NAME == "osx" ]]; then
tar -zcvf $FILE_NAME README.md install.sh LICENSE q examples;
fi

deploy:
provider: releases
api_key: "$GH_APIKEY"
file_glob: true
file: build/hdf5_$TRAVIS_OS_NAME-$TRAVIS_BRANCH.tgz
skip_cleanup: true
api_key: "$GITHUB_APIKEY"
file: "$FILE_NAME"
on:
tags: true
condition: $TRAVIS_OS_NAME = windows || $TRAVIS_OS_NAME = osx || ($TRAVIS_DIST = trusty && $TRAVIS_OS_NAME =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05i3CIvWUTodp1eQDFGsvixQMnD9PrzD+SbY5v6oDg/R0+pEHhPhRJ6v23OAmFyU90kn3VQQIFDMKufKSJE4jItoUBXhmavSHHU/sysH1n8YXCU0kuOFtWIK+t5RIFrhYuDvVcz8O4xF95oCdKXjX/jWTO+qGc+YU9WKieCwS8PXwqBJJA4V5D4KkzmJAX5Y2SqODYF/KOD59AedX9u7nlnTD3EHK5iGnnIVhAKyJq0kwLp3ikP7uZupddMg/6J8s0zg3r61GvxXaoPDTAzTn7MDEX7HQonX+IiUvfRQFIuT3VmQvv+pEeoDOw="


44 changes: 29 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,44 @@
# Environment variable for HDF5_HOME is required
if(NOT DEFINED ENV{HDF5_HOME})
message(FATAL_ERROR "HDF5_HOME must be set to the location of your installed hdf5-group repository")
if(NOT DEFINED ENV{BUILD_HOME})
message(FATAL_ERROR "BUILD_HOME must be set to the location of your installed hdf5-group repository")
endif()

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

cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.0)
project(hdf5 C)

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

set(MY_LIBRARY_NAME hdf5)
set(MY_LIBRARY_NAME kdbhdf5)
file(GLOB C_FILES src/*.c)
set_source_files_properties(${C_FILES} PROPERTIES LANGUAGE C)

include_directories($ENV{HDF5_HOME}/include)
message(STATUS "Generator : ${CMAKE_GENERATOR}")
message(STATUS "Build Tool : ${CMAKE_BUILD_TOOL}")
message(STATUS "HDF5 API : $ENV{BUILD_HOME}")

include_directories($ENV{BUILD_HOME}/include)

find_library(HDF5_LIBRARY
NAMES hdf5 libhdf5
HINTS "$ENV{HDF5_HOME}/lib/"
HINTS "$ENV{BUILD_HOME}/lib/"
)

if (MSVC)
file(DOWNLOAD "https://github.com/KxSystems/kdb/raw/master/w64/q.lib" "${CMAKE_BINARY_DIR}/q.lib" )
set(LINK_LIBS "${CMAKE_BINARY_DIR}/q.lib")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3 /D H5_BUILT_AS_DYNAMIC_LIB /D WIN32_LEAN_AND_MEAN /D _CRT_SECURE_NO_WARNINGS")
else()
set(LINK_LIBS "")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-strict-aliasing")
endif()

add_library (${MY_LIBRARY_NAME} SHARED ${C_FILES})
target_link_libraries(${MY_LIBRARY_NAME} ${HDF5_LIBRARY})
target_link_libraries(${MY_LIBRARY_NAME} ${HDF5_LIBRARY} ${LINK_LIBS})

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

message(STATUS "Installing package to : ${PROJECT_BINARY_DIR}/hdf5")

# Minimum build/install move binary and q-script to $QHOME & $QHOME/<QARCH>
install(TARGETS ${MY_LIBRARY_NAME} DESTINATION "$ENV{QHOME}/${OSFLAG}${BITNESS}/" CONFIGURATIONS MinSizeRel Release)
install(FILES hdf5.q DESTINATION "$ENV{QHOME}" CONFIGURATIONS MinSizeRel Release)
file(TO_CMAKE_PATH "$ENV{QHOME}" QHOME_PATH)
install(TARGETS ${MY_LIBRARY_NAME} DESTINATION "${QHOME_PATH}/${OSFLAG}${BITNESS}/" CONFIGURATIONS MinSizeRel Release)
install(DIRECTORY "q/" DESTINATION "${QHOME_PATH}" CONFIGURATIONS MinSizeRel Release FILES_MATCHING PATTERN "*.q")

# Required objects for release packaging
install(FILES LICENSE DESTINATION ${PROJECT_BINARY_DIR}/hdf5 CONFIGURATIONS Release)
install(FILES README.md DESTINATION ${PROJECT_BINARY_DIR}/hdf5 CONFIGURATIONS Release)
install(FILES README.md LICENSE ${INSTALL_SCRIPT} DESTINATION ${PROJECT_BINARY_DIR}/hdf5 CONFIGURATIONS Release)
install(DIRECTORY examples DESTINATION ${PROJECT_BINARY_DIR}/hdf5 CONFIGURATIONS Release)
install(FILES install.sh DESTINATION ${PROJECT_BINARY_DIR}/hdf5 CONFIGURATIONS Release)
install(FILES hdf5.q DESTINATION ${PROJECT_BINARY_DIR}/hdf5 CONFIGURATIONS Release)
install(DIRECTORY q DESTINATION ${PROJECT_BINARY_DIR}/hdf5 CONFIGURATIONS Release)
install(TARGETS ${MY_LIBRARY_NAME} DESTINATION ${PROJECT_BINARY_DIR}/hdf5/lib CONFIGURATIONS Release)
92 changes: 69 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,49 +38,68 @@ If you have any HDF5 related questions, you can raise them on the [HDF Forum](ht

### Third-Party Library Installation

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

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

**MacOS**
- Run `brew install hdf5`

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

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
2. Set an environment variable `$BUILD_HOME`/`%BUILD_HOME%` pointing to the location of the installed HDF group C api
3. Make the HDF group C api for HDF5 available to kdb

1. Ensure you have downloaded/installed the HDF5 C api following the instructions [here](#third-party-library-installation)
2. Download a release from [here](https://github.com/KxSystems/hdf5/releases) for your system architecture.
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.
For Linux and MacOS, add the location of the 'lib' directory to `LD_LIBRARY_PATH`/`DYLD_LIBRARY_PATH` as appropriate

```
## Linux
export LD_LIBRARY_PATH=/usr/local/hdf5-c-api/lib/:$LD_LIBRARY_PATH
```
## Linux
export LD_LIBRARY_PATH=$BUILD_HOME/lib/:$LD_LIBRARY_PATH
## MacOS
export DYLD_LIBRARY_PATH=/Users/bob/hdf5-c-api/lib/:$DYLD_LIBRARY_PATH
```
## MacOS
export DYLD_LIBRARY_PATH=$BUILD_HOME/lib/:$DYLD_LIBRARY_PATH
```

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
For Windows, create links to the paho dll's in the %QHOME%\w64 directory. e.g.

```
chmod +x install.sh
```
cd %QHOME%\w64
MKLINK libhdf5.dll %BUILD_HOME%\lib\libhdf5.dll
MKLINK hdf5.dll %BUILD_HOME%\lib\hdf5.dll
```

### Installing a release

It is recommended that a user install this interface through a release. This is completed in a number of steps

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)
2. Download a release from [here](https://github.com/KxSystems/hdf5/releases)
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

```
## Linux/MacOS
chmod +x install.sh && ./install.sh
## Windows
install.bat
```

./install.sh
```

### Building interface from source and install

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

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

#### Linux/MacOS

* Create a directory from which the execute the CMAKE command and move into this directory

```bash
mkdir build && cd build
mkdir cmake && cd cmake
```

* Execute the `cmake` instructions
Expand All @@ -89,23 +108,50 @@ mkdir build && cd build
cmake ..
```

* generate the `libhdf5.so` binary
* generate the `libkdbhdf5.so` binary

```bash
make
```

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

```bash
make install
```


#### Windows

From a Visual Studio command prompt:

* Create an out-of-source directory for the CMake and object files.

```bash
mkdir cmake && cd cmake
```

* Generate the VS solution

```bash
cmake ..
```

* Build the interface DLL and create the installation package into sub-directory hdf5

```bash
MSBuild.exe INSTALL.vcxproj /p:Configuration=Release /p:Platform=x64
```

* Install the package (copies the shared object to%QHOME%/w64 )

```bash
cd mqtt && install.bat
```

## Unsupported Functionality

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

- Use of this interface on Windows 64-bit systems
- Creation of compressed datasets
- Access to unlimited datasets
- Interaction with HDF5 images
Expand Down
Loading

0 comments on commit fa9688e

Please sign in to comment.