Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build windows DLLs from vendor directory #45

Merged
merged 19 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 4 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@ jobs:
target:
- os: linux
cpu: amd64
# - os: linux
# cpu: i386
- os: macos
cpu: amd64
- os: windows
cpu: amd64
#- os: windows
#cpu: i386
branch: [version-1-6, version-2-0, devel]
include:
- target:
Expand Down Expand Up @@ -113,17 +109,8 @@ jobs:
git
mingw-w64-x86_64-toolchain

- name: Restore Nim DLLs dependencies (Windows) from cache
if: runner.os == 'Windows'
id: windows-dlls-cache
uses: actions/cache@v4
with:
path: external/dlls-${{ matrix.target.cpu }}
key: 'dlls-${{ matrix.target.cpu }}'

- name: Install DLL dependencies (Windows)
if: >
steps.windows-dlls-cache.outputs.cache-hit != 'true' &&
runner.os == 'Windows'
run: |
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
Expand All @@ -132,13 +119,11 @@ jobs:
ROCKSDBSUB=x86
fi
DLLPATH="external/dlls-${{ matrix.target.cpu }}"
mkdir external
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
7z x -y external/windeps.zip -o"${DLLPATH}"
mkdir -p ${DLLPATH}

# ROCKSDB
curl -L "https://github.com/status-im/nimbus-deps/releases/download/rocksdb-9.1.0/nimbus-deps.zip" -o external/nimbus-deps.zip
7z x -y external/nimbus-deps.zip
cp -a "./${ROCKSDBSUB}/librocksdb.dll" "${DLLPATH}/librocksdb.dll"
./scripts/build_dlls_windows.sh
cp ./build/librocksdb.dll "${DLLPATH}/librocksdb.dll"

- name: Path to cached dependencies (Windows)
if: >
Expand Down
5 changes: 5 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
url = https://github.com/facebook/rocksdb
ignore = dirty
branch = master
[submodule "vendor/vcpkg"]
path = vendor/vcpkg
url = https://github.com/microsoft/vcpkg
ignore = dirty
branch = master
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ nim c -d:rocksdb_static_linking --threads:on your_program.nim

See the config.nims file which contains the static linking configuration which is switched on with the `rocksdb_static_linking` flag. Note that static linking is currently not supported on windows.

### Building Windows DLLs

Prerequisites:
- Windows 7 or newer
- Git
- Visual Studio 2015 Update 3 or greater with the English language pack

To build RocksDB for Windows, run the following:

```
.\scripts\build_dlls_windows.bat
```

After the build completes the built RocksDB DLLs will be located in the `build` directory.


### Contribution

Any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any
Expand Down
14 changes: 14 additions & 0 deletions scripts/build_dlls_windows.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@echo off

SET SCRIPT_DIR=%~dp0

cd %SCRIPT_DIR%\..

git submodule update --init

CALL .\vendor\vcpkg\bootstrap-vcpkg.bat -disableMetrics

.\vendor\vcpkg\vcpkg install rocksdb[lz4,zstd]:x64-windows-rocksdb --recurse --overlay-triplets=.\triplets

mkdir .\build
copy .\vendor\vcpkg\installed\x64-windows-rocksdb\bin\rocksdb-shared.dll .\build\librocksdb.dll
25 changes: 25 additions & 0 deletions scripts/build_dlls_windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

# Nim-RocksDB
# Copyright 2018-2024 Status Research & Development GmbH
# Licensed under either of
#
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
#
# at your option. This file may not be copied, modified, or distributed except according to those terms.

set -e

cd "$(dirname "${BASH_SOURCE[0]}")"/..

REPO_DIR="${PWD}"

git submodule update --init

${REPO_DIR}/vendor/vcpkg/bootstrap-vcpkg.sh -disableMetrics

${REPO_DIR}/vendor/vcpkg/vcpkg install rocksdb[lz4,zstd]:x64-windows-rocksdb --recurse --overlay-triplets=${REPO_DIR}/triplets

mkdir -p ${REPO_DIR}/build
cp ${REPO_DIR}/vendor/vcpkg/installed/x64-windows-rocksdb/bin/rocksdb-shared.dll ./build/librocksdb.dll
10 changes: 10 additions & 0 deletions triplets/x64-windows-rocksdb.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_BUILD_TYPE release)

if(${PORT} MATCHES "snappy|zlib|lz4|zstd")
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
else()
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE dynamic)
endif()
10 changes: 10 additions & 0 deletions triplets/x86-windows-rocksdb.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_BUILD_TYPE release)

if(${PORT} MATCHES "snappy|zlib|lz4|zstd")
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
else()
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE dynamic)
endif()
2 changes: 1 addition & 1 deletion vendor/rocksdb
Submodule rocksdb updated 778 files
1 change: 1 addition & 0 deletions vendor/vcpkg
Submodule vcpkg added at 01f602