Skip to content

Commit

Permalink
Add windows CI and build script
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjala committed Apr 15, 2024
1 parent 853eab7 commit fc8789f
Show file tree
Hide file tree
Showing 6 changed files with 369 additions and 25 deletions.
106 changes: 100 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ jobs:
working-directory: ${{ github.workspace }}

- name: Start HSDS
if: ${{ matrix.endpoint != 'http://127.0.0.1:5101'}}
run: |
cd ${{github.workspace}}/hsds
mkdir ${{github.workspace}}/hsdsdata &&
Expand All @@ -135,7 +134,6 @@ jobs:
working-directory: ${{github.workspace}}/hsds

- name: Test HSDS
if: ${{matrix.endpoint != 'http://127.0.0.1:5101'}}
run: |
python tests/integ/setup_test.py
working-directory: ${{github.workspace}}/hsds
Expand Down Expand Up @@ -181,7 +179,7 @@ jobs:
-DBUILD_SHARED_LIBS=ON -DHDF5_ENABLE_SZIP_SUPPORT=OFF \
-DHDF5_TEST_API=ON \
-DHDF5_ENABLE_Z_LIB_SUPPORT=OFF \
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DHDF5_ENABLE_THREADSAFE=OFF \
-DCMAKE_BUILD_TYPE=Release -DHDF5_ENABLE_THREADSAFE=OFF \
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/hdf5install \
..
make
Expand All @@ -194,7 +192,7 @@ jobs:
mkdir ./build
cd ./build
CFLAGS="-D_POSIX_C_SOURCE=200809L" cmake -G "Unix Makefiles" -DHDF5_ROOT=${{github.workspace}}/hdf5install \
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/vol-rest/install \
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/vol-rest/install -DCMAKE_BUILD_TYPE=Release \
..
shell: bash
working-directory: ${{github.workspace}}/vol-rest
Expand Down Expand Up @@ -242,7 +240,6 @@ jobs:
working-directory: ${{ github.workspace }}

- name: Start HSDS
if: ${{ matrix.endpoint != 'http://127.0.0.1:5101'}}
run: |
cd ${{github.workspace}}/hsds
mkdir ${{github.workspace}}/hsdsdata &&
Expand All @@ -256,7 +253,6 @@ jobs:
working-directory: ${{github.workspace}}/hsds

- name: Test HSDS
if: ${{matrix.endpoint != 'http://127.0.0.1:5101'}}
run: |
python tests/integ/setup_test.py
working-directory: ${{github.workspace}}/hsds
Expand All @@ -276,3 +272,101 @@ jobs:
# run: |
# valgrind --leak-check=full -s ctest -R "vol-rest" -VV
# working-directory: ${{github.workspace}}/hdf5/build/

build_and_test_windows:
strategy:
fail-fast: false
matrix:
os: [windows-latest]
python-version: ["3.10"]
hdf5-branch: ["hdf5_1_14", "develop"]

runs-on: ${{matrix.os}}
steps:
- name: Get HDF5
uses: actions/checkout@v4
with:
repository: HDFGroup/hdf5
ref: ${{matrix.hdf5-branch}}
path: ${{github.workspace}}/hdf5

- name: Get REST VOL
uses: actions/checkout@v3
with:
path: ${{github.workspace}}/vol-rest

- name: Get curl from source
uses: actions/checkout@v4
with:
repository: curl/curl
path: ${{github.workspace}}/curl

- name: Install curl
working-directory: ${{github.workspace}}/curl
run: |
mkdir build
mkdir install
cd build
cmake -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/curl/install `
-DCMAKE_BUILD_TYPE=Release -DBUILD_STATIC_LIBS=ON `
-DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS="/DCURL_STATICLIB" `
-DCURL_STATIC_CRT=ON -DBUILD_STATIC_CURL=ON ..
cmake --build . --config Release
cmake --install . --config Release
- name: Get yajl from source
uses: actions/checkout@v4
with:
repository: lloyd/yajl
path: ${{github.workspace}}/yajl

- name: Install yajl
working-directory: ${{github.workspace}}/yajl
run: |
mkdir build
mkdir install
cd build
cmake -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/yajl/install `
-DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release
cmake --install . --config Release
- name: CMake Configure + Build HDF5
run: |
mkdir build
cd build
cmake `
-DHDF5_BUILD_HL_LIB=ON `
-DBUILD_SHARED_LIBS=ON -DHDF5_ENABLE_SZIP_SUPPORT=OFF `
-DHDF5_TEST_API=ON `
-DHDF5_ENABLE_Z_LIB_SUPPORT=OFF `
-DCMAKE_BUILD_TYPE=Release -DHDF5_ENABLE_THREADSAFE=OFF `
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/hdf5install `
..
cmake --build . -j --config Release
cmake --install . --config Release
working-directory: ${{github.workspace}}/hdf5

- name: CMake Configure + Build REST VOL
working-directory: ${{github.workspace}}/vol-rest
run: |
mkdir build
cd build
cmake -DHDF5_ROOT=${{github.workspace}}/hdf5install `
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/vol-rest/install `
-DCURL_ROOT=${{github.workspace}}/curl/install/ -DCMAKE_C_FLAGS="/DCURL_STATICLIB" `
-DCURL_USE_STATIC_LIBRARIES=ON `
-DYAJL_ROOT=${{github.workspace}}/yajl/install/ `
-DCMAKE_BUILD_TYPE=Release ..
cmake --build . -j --config Release
cmake --install . --config Release
- name: Set HDF5 Plugin path
run: |
echo "HDF5_PLUGIN_PATH=${{github.workspace}}/vol-rest/build/bin/" >> $GITHUB_ENV
echo "HDF5_VOL_CONNECTOR=REST" >> $GITHUB_ENV
- name: Test REST VOL
working-directory: ${{github.workspace}}/vol-rest/build/bin/Release
run: |
test_rest_vol-shared.exe
33 changes: 25 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ set (HDF5_VOL_REST_LIBSH_TARGET "${HDF5_VOL_REST_LIB_CORENAME}-shared")
set (HDF5_VOL_REST_TEST_LIB_TARGET "${HDF5_VOL_REST_TEST_LIB_CORENAME}-static")
set (HDF5_VOL_REST_TEST_LIBSH_TARGET "${HDF5_VOL_REST_TEST_LIB_CORENAME}-shared")


#-----------------------------------------------------------------------------
# Define some CMake variables for use later in the project
#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -118,19 +117,29 @@ if (HDF5_ENABLE_THREADSAFE AND NOT Threads_FOUND)
find_package(Threads)
endif ()

set (CURL_TARGET_LIBTYPE shared)


find_package (CURL 7.61 REQUIRED)
if (CURL_FOUND)
# FindCURL module is not always found on windows; set paths manually
if (WIN32)
set (CURL_INCLUDE_DIRS "${CURL_ROOT}\\include")
set (LINK_LIBS ${LINK_LIBS} Ws2_32.lib Wldap32.lib)

if (CURL_USE_STATIC_LIBRARIES)
set (CURL_LIBRARIES "${CURL_ROOT}\\lib\\libcurl.lib")
else ()
set (CURL_LIBRARIES "${CURL_ROOT}\\bin\\libcurl.dll")
endif()
endif()

include_directories(${CURL_INCLUDE_DIRS})
set (LINK_LIBS ${LINK_LIBS} CURL::libcurl)
set_target_properties(CURL::libcurl PROPERTIES
IMPORTED_LOCATION ${CURL_ROOT}/lib/libcurl.lib)
set (LINK_LIBS ${LINK_LIBS} ${CURL_LIBRARIES})
else ()
message (FATAL_ERROR "cURL not found; please check CURL_INCLUDE_DIR")
message (FATAL_ERROR "cURL not found; please check CURL_ROOT")
endif ()

if (WIN32)
set (LINK_LIBS ${LINK_LIBS} Ws2_32.lib)
endif ()
# Include custom module for finding YAJL
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${HDF5_VOL_REST_RESOURCES_MOD_DIR}")

Expand Down Expand Up @@ -369,6 +378,10 @@ if (NOT BUILD_SHARED_LIBS)
endif ()
if (BUILD_SHARED_LIBS)
set (HDF5_VOL_REST_LIBRARIES_TO_EXPORT ${HDF5_VOL_REST_LIBRARIES_TO_EXPORT} ${HDF5_VOL_REST_LIBSH_TARGET} CACHE INTERNAL "Store which libraries should be exported" FORCE)
# Value is not automatically inherited from cache on Windows
if (WIN32)
set (HDF5_VOL_REST_LIBRARIES_TO_EXPORT ${HDF5_VOL_REST_LIBRARIES_TO_EXPORT} ${HDF5_VOL_REST_LIBSH_TARGET})
endif()
endif ()

option (BUILD_STATIC_LIBS "Build Static Libraries" OFF)
Expand All @@ -377,6 +390,10 @@ if (BUILD_STATIC_LIBS)
set (HDF5_VOL_REST_ENABLE_STATIC_LIB YES)
set (LINK_STATIC_LIBS ${LINK_LIBS})
set (HDF5_VOL_REST_LIBRARIES_TO_EXPORT ${HDF5_VOL_REST_LIBRARIES_TO_EXPORT} ${HDF5_VOL_REST_LIB_TARGET} CACHE INTERNAL "Store which libraries should be exported" FORCE)
# Value is not automatically inherited from cache on Windows
if (WIN32)
set (HDF5_VOL_REST_LIBRARIES_TO_EXPORT ${HDF5_VOL_REST_LIBRARIES_TO_EXPORT} ${HDF5_VOL_REST_LIB_TARGET})
endif()
endif ()

set (CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand Down
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ and can directly be obtained from:

`git clone https://github.com/HDFGroup/vol-rest`

For building with the 1.12 or later version of the HDF5 library, use the hdf5_1_12_update branch of this repository.

A source distribution of the HDF5 library has been included in the REST VOL connector
source in the `/src/hdf5` directory.

Expand Down Expand Up @@ -141,9 +139,6 @@ The following configuration options are available to all of the build scripts:
mostly useful in helping to diagnose any possible memory leaks or other
memory errors within the connector.

-g Enables symbolic debugging of the REST VOL code. (Only available for
`build_vol_autotools.sh`)

-P DIR Specifies where the REST VOL connector should be installed. The default
installation prefix is `rest_vol_build` inside the REST VOL connector source
root directory.
Expand All @@ -158,7 +153,15 @@ The following configuration options are available to all of the build scripts:
-Y DIR Specifies the top-level directory where YAJL is installed. Used if YAJL is
not installed to a system path or used to override

Additionally, the CMake build scripts have the following configuration options:
The following configuration options are specific to `build_vol_autotools.sh`:

-g Enables symbolic debugging of the REST VOL code.

The following configuration options are specific to the CMake build scripts:

-u Specifies that a static cURL library should be used as a dependency.

-t Specifies that a static YAJL library should be used as a dependency.

-B DIR Specifies the directory that CMake should use as the build tree location.
The default build tree location is `rest_vol_cmake_build_files` inside the
Expand Down Expand Up @@ -291,7 +294,8 @@ components mentioned previously cannot be found within the system path.
* `HDF5_VOL_REST_ENABLE_MEM_TRACKING` - Enables/Disables memory tracking within the REST VOL connector. This option is mostly useful in helping to diagnose any possible memory leaks or other memory errors within the connector. The default value is `OFF`.
* `HDF5_VOL_REST_THREAD_SAFE` - Enables/Disables linking to HDF5 statically compiled with thread safe option. The default value is `OFF`.
* `YAJL_USE_STATIC_LIBRARIES` - Indicate if the static YAJL libraries should be used for linking. The default value is `OFF`.

* `CURL_USE_STATIC_LIBRARIES` - Indicate if the static CURL libraries should be used for linking. The default value is `OFF`.

Note, when setting BUILD_SHARED_LIBS=ON and YAJL_USE_STATIC_LIBRARIES=ON, the static YAJL libraries have be build with the position independent code (PIC) option enabled. In the static YAJL build,
this PIC option has been turned off by default.

Expand All @@ -301,7 +305,7 @@ It is also possible to build the REST VOL as part of the build process for the H

### II.B.v. Build Results

If the build is successful, the following files will be written into the installation directory:
If the build is successful, the following files will be written into the installation directory on a Linux or OSX machine:

```
bin/
Expand All @@ -327,6 +331,8 @@ share/
hdf5_vol_rest-targets-<build mode>.cmake
```

On a Windows system, the installation directory will have a few differences. If shared libraries are built, the resulting `hdf5_vol_rest.dll` will be found in the `bin` directory. If tests are enabled, `test_rest_vol(-shared).exe` will also be in the `bin` directory. If static libraries are built, `lib` will contain `libhdf5_vol_rest.lib`.

If the REST VOL connector was built using one of the included build scripts, all of the usual files
from an HDF5 source build should appear in the respective `bin`, `include`, `lib` and `share`
directories in the install directory. Notable among these is `bin/h5cc`, a special-purpose compiler wrapper script that streamlines the process of building HDF5 applications.
Expand Down
Loading

0 comments on commit fc8789f

Please sign in to comment.