Skip to content

Commit

Permalink
Add vcpkg and remove hardcoded dependencies (#254)
Browse files Browse the repository at this point in the history
**Summary**

This PR adds vcpkg configurations for dependency management and removes
hardcoded dependencies from the codebase. It also adds vcpkg to our
GitHub
Actions workflow and uses it to automatically install our dependencies.

**Notes**
- By integrating a package manager, we significantly simplify dependency
management, improve our productivity, and promote consistency across
environments.
- In this configuration, there's no need to add vcpkg as a submodule to
the project. Instead, individual users should install vcpkg in their
home directory and set up the necessary environment variables (following
this
[guide](https://learn.microsoft.com/en-us/vcpkg/get_started/get-started?pivots=shell-bash).)
- When we're ready to add
[minio](https://vcpkg.io/en/package/minio-cpp), all we need to do is
update `vcpkg.json` in the root folder.
- I will update the README file with installation instructions and
remove the hardcoded `json.hpp` library from the tests folder in
separate PRs.

**Test Plan**
- All existing tests have passed.

---------

Co-authored-by: Alan Liddell <[email protected]>
  • Loading branch information
shlomnissan and aliddell authored Jun 18, 2024
1 parent 9368165 commit 156b99e
Show file tree
Hide file tree
Showing 25 changed files with 111 additions and 25,246 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/test_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ jobs:
fail-fast: false
matrix:
platform: [ "windows-latest", "ubuntu-latest", "macos-latest" ]
include:
- platform: "windows-latest"
vcpkg_triplet: "x64-windows-static"
- platform: "ubuntu-latest"
vcpkg_triplet: "x64-linux"
- platform: "macos-latest"
vcpkg_triplet: "arm64-osx"
permissions:
actions: write

Expand All @@ -43,8 +50,19 @@ jobs:
sudo bash cmake.sh --skip-license --exclude-subdir --prefix=/usr/local
shell: bash

- name: Install vcpkg
run: |
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg && ./bootstrap-vcpkg.sh
echo "VCPKG_ROOT=${{github.workspace}}/vcpkg" >> $GITHUB_ENV
echo "${{github.workspace}}/vcpkg" >> $GITHUB_PATH
./vcpkg integrate install
shell: bash

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
run: |
cmake --preset=default -DVCPKG_TARGET_TRIPLET=${{matrix.vcpkg_triplet}}
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ project(acquire-driver-zarr)
cmake_policy(SET CMP0079 NEW) # allows use with targets in other directories
enable_testing()

find_package(nlohmann_json CONFIG REQUIRED)
find_package(blosc CONFIG REQUIRED)

include(cmake/aq_require.cmake)
include(cmake/git-versioning.cmake)
include(cmake/ide.cmake)
Expand Down
12 changes: 12 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 3,
"configurePresets": [
{
"name": "default",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
}
]
}
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,45 @@

This is an Acquire Driver that supports chunked streaming to [zarr][].

## Installing Dependencies

This driver uses the following libraries:
- blosc v1.21.5
- nlohmann-json v3.11.3

We prefer using [vcpkg](https://vcpkg.io/en/) for dependency management, as it integrates well with CMake. Below are instructions for installing vcpkg locally and configuring it to fetch and compile the necessary dependencies (the steps are taken from [this vcpkg guide](https://learn.microsoft.com/en-us/vcpkg/get_started/get-started?pivots=shell-bash)).

**1. Clone the repository**

The repository contains scripts to acquire the vcpkg executable and a registry of curated open-source libraries maintained by the vcpkg community. To do this, run:
```
git clone https://github.com/microsoft/vcpkg.git
```
**2. Clone the repository**

Run the bootstrap script
```
cd vcpkg && ./bootstrap-vcpkg.sh
```

**3. Configure environment variables**

Add the following export commands to your shell's profile script (e.g., `~/.bashrc` or `~/.zshrc`).
```
export VCPKG_ROOT=/path/to/vcpkg
export PATH=$VCPKG_ROOT:$PATH
```

**4. Configure CMake**

This repository's root directory contains a `CMakePresets.json` file with a single "default" preset for CMake, which sets the `CMAKE_TOOLCHAIN_FILE` variable. This file simplifies the process of specifying the toolchain when running CMake. Before building your project, execute the following command:

```
cmake --preset=default
```

If you've built the driver before, consider deleting your build directory first. If you encounter any problems, refer to the [source vcpkg guide](https://learn.microsoft.com/en-us/vcpkg/get_started/get-started?pivots=shell-bash) or open an issue for help.

## Devices

### Storage
Expand Down
2 changes: 0 additions & 2 deletions src/3rdParty/CMakeLists.txt

This file was deleted.

23 changes: 0 additions & 23 deletions src/3rdParty/cblosc/CMakeLists.txt

This file was deleted.

45 changes: 0 additions & 45 deletions src/3rdParty/cblosc/inc/blosc-export.h

This file was deleted.

Loading

0 comments on commit 156b99e

Please sign in to comment.