Skip to content

Commit

Permalink
Refactor / cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
bhartnett committed Mar 19, 2024
1 parent 44a4a33 commit c66b341
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
12 changes: 6 additions & 6 deletions config.nims
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ when fileExists("nimble.paths"):
include "nimble.paths"
# end Nimble config

when defined(static_linking):
import std/os
when defined(rocksdb_static_linking):
import std/[os, strutils]

const libsDir = currentSourcePath.parentDir() & "/vendor/rocksdb"
switch("dynlibOverrideAll")
const libsDir = currentSourcePath.parentDir().replace('\\', '/') & "/build/lib"
switch("gcc.linkerexe", "g++") # use the C++ linker profile because it's a C++ library
switch("dynlibOverride", "librocksdb.a")
switch("dynlibOverride", "libz.a")
switch("l", libsDir & "/librocksdb.a")
switch("l", libsDir & "/libz.a")
switch("gcc.linkerexe", "g++") # use the C++ linker profile because it's a C++ library

4 changes: 2 additions & 2 deletions rocksdb.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mode = ScriptMode.Verbose

### Dependencies
requires "nim >= 1.6",
"stew",
"results",
"tempfile",
"unittest2"

Expand All @@ -17,4 +17,4 @@ task test, "Run tests":

task test_static, "Run tests after static linking dependencies":
exec "scripts/build_static_deps.sh"
exec "nim c -d:static_linking -r --threads:on tests/test_all.nim"
exec "nim c -d:rocksdb_static_linking -r --threads:on tests/test_all.nim"
2 changes: 1 addition & 1 deletion rocksdb/lib/librocksdb.nim
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ type

## DB operations

when defined(static_linking):
when defined(rocksdb_static_linking):
{.pragma: importrocks, importc, cdecl.}
when defined(windows):
{.passL: "-lshlwapi -lrpcrt4".}
Expand Down
9 changes: 5 additions & 4 deletions scripts/build_static_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
set -e

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

REPO_DIR="${PWD}"
ROCKSDB_LIB_DIR=$REPO_DIR/vendor/rocksdb
BUILD_DEST=$REPO_DIR/build/lib


git submodule update --init
DEBUG_LEVEL=0 make -C "${ROCKSDB_LIB_DIR}" libz.a
DEBUG_LEVEL=0 make -C "${ROCKSDB_LIB_DIR}" static_lib
# TODO: add this in later
#exec "strip --strip-unneeded vendor/rocksdb/libz.a vendor/rocksdb/librocksdb.a"
DEBUG_LEVEL=0 make -C "${ROCKSDB_LIB_DIR}" libz.a static_lib --no-print-directory &>/dev/null

mkdir -p "${BUILD_DEST}"
cp "${ROCKSDB_LIB_DIR}/libz.a" "${ROCKSDB_LIB_DIR}/librocksdb.a" "${BUILD_DEST}/"

strip --strip-unneeded "${BUILD_DEST}/libz.a" "${BUILD_DEST}/librocksdb.a"

0 comments on commit c66b341

Please sign in to comment.