2024-05-09 13:37:37 +00:00
|
|
|
import os
|
|
|
|
|
2024-05-22 16:41:07 +00:00
|
|
|
const
|
|
|
|
root = currentSourcePath.parentDir.parentDir
|
|
|
|
envWindows = root/"vendor"/"util"/"env_windows.cc"
|
|
|
|
envPosix = root/"vendor"/"util"/"env_posix.cc"
|
|
|
|
|
|
|
|
LevelDbCMakeFlags {.strdefine.} =
|
|
|
|
when defined(macosx):
|
|
|
|
"-DCMAKE_BUILD_TYPE=Release"
|
|
|
|
elif defined(windows):
|
|
|
|
"-G\"MSYS Makefiles\" -DCMAKE_BUILD_TYPE=Release"
|
|
|
|
else:
|
|
|
|
"-DCMAKE_BUILD_TYPE=Release"
|
|
|
|
|
|
|
|
LevelDbDir {.strdefine.} = $(root/"vendor")
|
|
|
|
buildDir = $(root/"build")
|
|
|
|
|
2024-08-15 08:33:33 +00:00
|
|
|
proc buildLevelDb() =
|
|
|
|
if fileExists(buildDir/"Makefile"):
|
|
|
|
echo "LevelDB already build. Delete '" & buildDir & "' to force rebuild."
|
|
|
|
return
|
|
|
|
|
2024-05-22 16:41:07 +00:00
|
|
|
echo "Initializing submodule..."
|
|
|
|
discard gorge "git submodule deinit -f \"" & root & "\""
|
|
|
|
discard gorge "git submodule update --init --recursive --checkout \"" & root & "\""
|
|
|
|
|
|
|
|
echo "\nClean dir: \"" & buildDir & "\""
|
|
|
|
discard gorge "rm -rf " & buildDir
|
|
|
|
discard gorge "mkdir -p " & buildDir
|
|
|
|
|
|
|
|
let cmd = "cmake -S \"" & LevelDbDir & "\" -B \"" & buildDir & "\" " & LevelDbCmakeFlags
|
|
|
|
echo "\nBuilding LevelDB: " & cmd
|
|
|
|
let (output, exitCode) = gorgeEx cmd
|
|
|
|
if exitCode != 0:
|
|
|
|
discard gorge "rm -rf " & buildDir
|
|
|
|
echo output
|
|
|
|
raise (ref Defect)(msg: "Failed to build LevelDB")
|
2024-05-09 13:37:37 +00:00
|
|
|
|
2024-08-15 08:33:33 +00:00
|
|
|
static:
|
|
|
|
buildLevelDb()
|
|
|
|
|
2024-05-09 12:05:01 +00:00
|
|
|
when defined(windows):
|
2024-05-09 13:37:37 +00:00
|
|
|
{.compile: envWindows.}
|
2024-05-13 09:38:49 +00:00
|
|
|
{.passc: "-DLEVELDB_PLATFORM_WINDOWS".}
|
|
|
|
{.passc: "-D_UNICODE".}
|
|
|
|
{.passc: "-DUNICODE".}
|
2024-05-09 12:05:01 +00:00
|
|
|
|
|
|
|
when defined(posix):
|
2024-05-09 13:37:37 +00:00
|
|
|
{.compile: envPosix.}
|
2024-05-13 09:38:49 +00:00
|
|
|
{.passc: "-DLEVELDB_PLATFORM_POSIX".}
|