diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a0ae08..5988459 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -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 @@ -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: > diff --git a/.gitmodules b/.gitmodules index 8231cca..d736843 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/README.md b/README.md index 368d6c8..8aec7c7 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/scripts/build_dlls_windows.bat b/scripts/build_dlls_windows.bat new file mode 100755 index 0000000..4cf5f0d --- /dev/null +++ b/scripts/build_dlls_windows.bat @@ -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 diff --git a/scripts/build_dlls_windows.sh b/scripts/build_dlls_windows.sh new file mode 100755 index 0000000..f6c8293 --- /dev/null +++ b/scripts/build_dlls_windows.sh @@ -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 diff --git a/triplets/x64-windows-rocksdb.cmake b/triplets/x64-windows-rocksdb.cmake new file mode 100644 index 0000000..5ec3033 --- /dev/null +++ b/triplets/x64-windows-rocksdb.cmake @@ -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() diff --git a/triplets/x86-windows-rocksdb.cmake b/triplets/x86-windows-rocksdb.cmake new file mode 100644 index 0000000..701a059 --- /dev/null +++ b/triplets/x86-windows-rocksdb.cmake @@ -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() diff --git a/vendor/rocksdb b/vendor/rocksdb index a66daec..bcf88d4 160000 --- a/vendor/rocksdb +++ b/vendor/rocksdb @@ -1 +1 @@ -Subproject commit a66daec5410683c0f66e7759b425631ffbfd8677 +Subproject commit bcf88d48ce8aa8b536aee4dd305533b3b83cf435 diff --git a/vendor/vcpkg b/vendor/vcpkg new file mode 160000 index 0000000..01f6021 --- /dev/null +++ b/vendor/vcpkg @@ -0,0 +1 @@ +Subproject commit 01f602195983451bc83e72f4214af2cbc495aa94