From fa9688e71dbb1d9c8279f4284c0e983b367d8b9a Mon Sep 17 00:00:00 2001 From: cmccarthy1 <38653604+cmccarthy1@users.noreply.github.com> Date: Wed, 20 May 2020 19:18:24 +0100 Subject: [PATCH] Addition of windows build (#19) Co-authored-by: nmcdonnell-kx --- .travis.yml | 150 +++++++++++++++++++++++++------------------ CMakeLists.txt | 44 ++++++++----- README.md | 92 +++++++++++++++++++------- examples/h5_attr.q | 2 +- examples/h5_comp.q | 2 +- examples/h5_dset.q | 2 +- examples/h5_file.q | 2 +- examples/h5_group.q | 2 +- examples/h5_link.q | 2 +- examples/h5_tables.q | 2 +- examples/h5_utils.q | 2 +- install.bat | 33 ++++++++++ install.sh | 21 +++--- hdf5.q => q/hdf5.q | 2 +- test.q | 15 +++++ tests/test.t | 2 +- travis_setup.sh | 18 ++++-- 17 files changed, 269 insertions(+), 124 deletions(-) create mode 100644 install.bat rename hdf5.q => q/hdf5.q (99%) create mode 100644 test.q diff --git a/.travis.yml b/.travis.yml index 5de17b6..c735d3e 100755 --- a/.travis.yml +++ b/.travis.yml @@ -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 = linux) + skip_cleanup: 'true' notifications: slack: - secure: "fDsGcgmkYyndvlN2NQlfqPrk0rfKVbDlp2Wg5pr/PZYCRY7rjXEwdby9T/tOpulQ6HXpdnqFN1zJ+5ih3XCwtLa4mPYRGWK3GvLNFvINTQDsYrCpgfQKxC6snBiGrUA0DoSAhS1nlB2igGoZSUSGi+sROsLiDn5aIqi3+Wz3JcFytISncWovO2bhedRjrFZXt4zmrDRpJ2BCShQdg2kppPGIDUHS0/xDElGtaHizLijeJjX/49xtABn7cLrv3wbVvejHU6yu5OdxOqtc98NYLV1lVPxiUIrjmvs/tlV4C6peGc1H9GioExThoWxW/KrMEL7biRxtTZzgqr+2W6+NWkzL74pMhqROOGvULH9DkfQxkjNNN6aLhN98oYswOgzg/UxM/F+Qolf948EWgcbg4USlAotd779YOfYPymYEeJlZTrvuYSazUdjUh6FkJtDYeiu7ZHkc75c4Fm8RNpxC6Kc4fO1Aq9ga0A8VoEzwIEscsMDvNC0hJjeFvglN0wie+jT23nNXnucTdgqxH9aCdub+ARcDEIXMS99WiYApHjbNK2WcTJYVDIKy1g1dO49oQMNLaHofaoO14OHw3OcWBlnHKhU2OWPuB0v0vqTeW8YAhGUewEmc5uwg6hYeVmE4ThDr4tiNDDyeCA6uTTN87oCguvlwrLF56vIEg0Sh4ok=" - + 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=" + + diff --git a/CMakeLists.txt b/CMakeLists.txt index 11e601a..0edf4ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # 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 @@ -8,24 +8,37 @@ 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" @@ -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() @@ -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/ -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) diff --git a/README.md b/README.md index c6fbabf..9993405 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ 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). @@ -46,41 +46,60 @@ The following outlines instructions for installing the HDF5 group's C api for su **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 @@ -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 diff --git a/examples/h5_attr.q b/examples/h5_attr.q index 5d86bee..aadfdce 100644 --- a/examples/h5_attr.q +++ b/examples/h5_attr.q @@ -6,7 +6,7 @@ -1"Running h5_attr.q\n"; // import the hdf5 library -\l ../hdf5.q +\l ../q/hdf5.q // Move into the hdf5 namespace \d .hdf5 diff --git a/examples/h5_comp.q b/examples/h5_comp.q index 1ee9e57..2b255bd 100644 --- a/examples/h5_comp.q +++ b/examples/h5_comp.q @@ -4,7 +4,7 @@ -1"Running h5_comp.q\n"; // import the hdf5 library -\l ../hdf5.q +\l ../q/hdf5.q // Move into the hdf5 namespace \d .hdf5 diff --git a/examples/h5_dset.q b/examples/h5_dset.q index 4b99578..d06baf5 100644 --- a/examples/h5_dset.q +++ b/examples/h5_dset.q @@ -4,7 +4,7 @@ -1"Running h5_dset.q\n"; // import the hdf5 library -\l ../hdf5.q +\l ../q/hdf5.q // Move into the hdf5 namespace \d .hdf5 diff --git a/examples/h5_file.q b/examples/h5_file.q index eccd0e2..f45c5c8 100644 --- a/examples/h5_file.q +++ b/examples/h5_file.q @@ -3,7 +3,7 @@ -1"\nRunning h5_file.q\n"; // import the hdf5 library -\l ../hdf5.q +\l ../q/hdf5.q // Move into the hdf5 namespace \d .hdf5 diff --git a/examples/h5_group.q b/examples/h5_group.q index b6fccbb..9510da0 100644 --- a/examples/h5_group.q +++ b/examples/h5_group.q @@ -6,7 +6,7 @@ -1"Running h5_group.q\n"; // import the hdf5 library -\l ../hdf5.q +\l ../q/hdf5.q // Move into the hdf5 namespace \d .hdf5 diff --git a/examples/h5_link.q b/examples/h5_link.q index 1e03380..0df8b49 100644 --- a/examples/h5_link.q +++ b/examples/h5_link.q @@ -8,7 +8,7 @@ -1"Running h5_link.q\n"; // import the hdf5 library -\l ../hdf5.q +\l ../q/hdf5.q // Move into the hdf5 namespace \d .hdf5 diff --git a/examples/h5_tables.q b/examples/h5_tables.q index 68e91ef..ca24b19 100644 --- a/examples/h5_tables.q +++ b/examples/h5_tables.q @@ -5,7 +5,7 @@ -1"Running h5_tables.q\n"; // import the hdf5 library -\l ../hdf5.q +\l ../q/hdf5.q // Move into the hdf5 namespace \d .hdf5 diff --git a/examples/h5_utils.q b/examples/h5_utils.q index 2a2f653..c54afbc 100644 --- a/examples/h5_utils.q +++ b/examples/h5_utils.q @@ -3,7 +3,7 @@ -1"Running h5_utils.q\n"; // import the hdf5 library -\l ../hdf5.q +\l ../q/hdf5.q // Move into the hdf5 namespace \d .hdf5 diff --git a/install.bat b/install.bat new file mode 100644 index 0000000..3b8bf0e --- /dev/null +++ b/install.bat @@ -0,0 +1,33 @@ +@echo off + +IF "%QHOME%"=="" ( + ECHO ERROR: Enviroment variable QHOME is NOT defined + EXIT /B +) + +IF NOT EXIST %QHOME%\w64 ( + ECHO ERROR: Installation destination %QHOME%\w64 does not exist + EXIT /B +) + + +IF EXIST q ( + ECHO Copying q script to %QHOME% + COPY q\* %QHOME% + IF %ERRORLEVEL% NEQ 0 ( + ECHO ERROR: Copy failed + EXIT /B %ERRORLEVEL% + ) +) + +IF EXIST lib ( + ECHO Copying DLL to %QHOME%\w64 + COPY lib\* %QHOME%\w64\ + IF %ERRORLEVEL% NEQ 0 ( + ECHO ERROR: Copy failed + EXIT /B %ERRORLEVEL% + ) +) + +ECHO Installation complete + diff --git a/install.sh b/install.sh index f2453ca..e95c0df 100755 --- a/install.sh +++ b/install.sh @@ -58,22 +58,23 @@ if [ ! -w "$Q_SHARED_LIB_DIR" ]; then echo "ERROR: Directory '$Q_SHARED_LIB_DIR' does not exist" exit 1 fi -if [ ! -d lib ]; then - echo "ERROR: Directory 'lib' does not exist. Please run from release package" - exit 1 -fi -echo "Copying q script to $Q_SCRIPT_DIR ..." -cp hdf5.q $Q_SCRIPT_DIR -if [ $? -ne 0 ]; then +if [ -d q ]; then + echo "Copying q script to $Q_SCRIPT_DIR ..." + cp q/* $Q_SCRIPT_DIR + if [ $? -ne 0 ]; then echo "ERROR: copy failed" exit 1 + fi fi -echo "Copying shared lib to $Q_SHARED_LIB_DIR ..." -cp lib/* $Q_SHARED_LIB_DIR -if [ $? -ne 0 ]; then + +if [ -d lib ]; then + echo "Copying shared lib to $Q_SHARED_LIB_DIR ..." + cp lib/* $Q_SHARED_LIB_DIR + if [ $? -ne 0 ]; then echo "ERROR: copy failed" exit 1 + fi fi echo "Install complete" diff --git a/hdf5.q b/q/hdf5.q similarity index 99% rename from hdf5.q rename to q/hdf5.q index e4dee8d..2c50a14 100644 --- a/hdf5.q +++ b/q/hdf5.q @@ -1,5 +1,5 @@ \d .hdf5 -LIBPATH:`:libhdf5 2: +LIBPATH:`:libkdbhdf5 2: funcs:( (`hdf5init;1); // .hdf5.init[]_ diff --git a/test.q b/test.q new file mode 100644 index 0000000..128c0d0 --- /dev/null +++ b/test.q @@ -0,0 +1,15 @@ +\d .t +n:ne:nf:ns:0 +pt:{-2 $[first[x]~`..err;err;fail][x;y]} +i:{` sv" ",/:` vs x} +ge:{if[not P;n+:1;ns+:1;:(::)];v:.Q.trp[x;y;{(`..err;x,"\n",.Q.sbt 1#y)}];n+:1;if[not(1b~v)|(::)~v;pt[v](y;file)]} +P:1;N:0;MM:0#` +e:ge value +err:{ne+:1;"ERROR:\n test:\n",i[y 0]," message:\n",i[x 1]," file:\n",i y 1} +fail:{nf+:1;"FAIL:\n test:\n",i[y 0]," result:\n",i[.Q.s x]," file:\n",i y 1} +u:raze{$[0>type k:key x;k;` sv'x,'k]}each hsym`$$[count .z.x;.z.x;enlist"tests"] +{N+:1;P::1;file::x;system"l ",x}each 1_'string u where u like"*.t"; +msg:{", "sv{":"sv string(x;y)}'[key x;value x]}`failed`errored`skipped`total!nf,ne,ns,n; +if[(ne+nf);-2 msg;exit 1] +\\ + diff --git a/tests/test.t b/tests/test.t index 96ecf5a..08f643e 100644 --- a/tests/test.t +++ b/tests/test.t @@ -1,4 +1,4 @@ -\l hdf5.q +\l q/hdf5.q fname:"test_file.h5" attr_dset:"attr_dset"; diff --git a/travis_setup.sh b/travis_setup.sh index 6631be2..73d083d 100644 --- a/travis_setup.sh +++ b/travis_setup.sh @@ -5,11 +5,21 @@ if [ "$TRAVIS_OS_NAME" == "osx" ]; then # use homebrew version brew install hdf5 echo "brew install finished" else # install from source - cd .. - wget "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.4/src/hdf5-1.10.4.tar.gz" + wget --no-check-certificate "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.4/src/hdf5-1.10.4.tar.gz" tar -xzf "hdf5-1.10.4.tar.gz" cd "hdf5-1.10.4" - ./configure --prefix=/usr/local - sudo make install 2>&1 | tail -n200 + export BUILD_HOME=$TRAVIS_BUILD_DIR/cbuild + mkdir $BUILD_HOME + if [ "$TRAVIS_OS_NAME" == "linux" ]; then + ./configure --prefix=$BUILD_HOME + sudo make install 2>&1 | tail -n200 + else + # Windows build + mkdir cmake && cd cmake + cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=$BUILD_HOME .. + cmake --build . --config Release + cmake --build . --config Release --target install + cd .. + fi cd .. fi