From 37af6e5b9b8df83a278731147c1371fbcefeb79c Mon Sep 17 00:00:00 2001 From: benbierens Date: Mon, 20 May 2024 15:03:00 +0200 Subject: [PATCH] Attempt to run cmake on every build --- build.sh | 55 --------------------------------------- build/.keep | 0 leveldbstatic/prelude.nim | 15 ----------- leveldbstatic/raw.nim | 29 +++++++++++++++++++++ 4 files changed, 29 insertions(+), 70 deletions(-) delete mode 100755 build.sh delete mode 100644 build/.keep delete mode 100644 leveldbstatic/prelude.nim diff --git a/build.sh b/build.sh deleted file mode 100755 index dd683df..0000000 --- a/build.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -root=$(dirname "$0") - -sourceDir="${root}/vendor" -buildDir="${root}/build" -output="${root}/leveldbstatic/raw.nim" - -# install nimterop, if not already installed -if ! [ -x "$(command -v toast)" ]; then - nimble install -y nimterop@0.6.13 -fi - -git submodule deinit -f "${root}" -git submodule update --init --recursive --checkout "${root}" - -cmake -S "${sourceDir}" -B "${buildDir}" - -# Remove testing, benchmarking, third-party libraries. -rm -Rf "${sourceDir}/third_party" -rm -Rf "${sourceDir}/benchmarks" -rm "${sourceDir}/util/testutil.cc" - -# Prelude: -cat "${root}/leveldbstatic/prelude.nim" > "${output}" -echo >> "${output}" - -# assemble files to be compiled: -extensions="c cc cpp" -for ext in ${extensions}; do - for file in `find "${sourceDir}" -type f -name "*.${ext}" \ - | grep -v "_test" \ - | grep -v "env_windows.cc" \ - | grep -v "env_posix.cc" \ - | grep -v "leveldbutil.cc"`; do - compile="${compile} --compile=${file}" - done -done - -# generate nim wrapper with nimterop -toast \ - $compile \ - --pnim \ - --preprocess \ - --noHeader \ - --includeDirs="${sourceDir}" \ - --includeDirs="${sourceDir}/helpers" \ - --includeDirs="${sourceDir}/helpers/memenv" \ - --includeDirs="${sourceDir}/port" \ - --includeDirs="${sourceDir}/include" \ - --includeDirs="${root}/leveldbstatic/include" \ - "${sourceDir}/include/leveldb/c.h" >> "${output}" - -sed -i 's/\bpassC\b/passc/g' "${output}" -sed -i 's/{\.compile\:\ \"\./{\.compile\:\ root\ \&\ \"/g' "${output}" -sed -i 's/{\.passc\:\ \"-I\./{\.passc\:\ \"-I\"\ \&\ root\ \&\ \"/g' "${output}" diff --git a/build/.keep b/build/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/leveldbstatic/prelude.nim b/leveldbstatic/prelude.nim deleted file mode 100644 index b000f9c..0000000 --- a/leveldbstatic/prelude.nim +++ /dev/null @@ -1,15 +0,0 @@ -import os - -const root = currentSourcePath.parentDir.parentDir -const envWindows = root/"vendor"/"util"/"env_windows.cc" -const envPosix = root/"vendor"/"util"/"env_posix.cc" - -when defined(windows): - {.compile: envWindows.} - {.passc: "-DLEVELDB_PLATFORM_WINDOWS".} - {.passc: "-D_UNICODE".} - {.passc: "-DUNICODE".} - -when defined(posix): - {.compile: envPosix.} - {.passc: "-DLEVELDB_PLATFORM_POSIX".} diff --git a/leveldbstatic/raw.nim b/leveldbstatic/raw.nim index ee5216b..e18c6f1 100644 --- a/leveldbstatic/raw.nim +++ b/leveldbstatic/raw.nim @@ -4,6 +4,35 @@ const root = currentSourcePath.parentDir.parentDir const envWindows = root/"vendor"/"util"/"env_windows.cc" const envPosix = root/"vendor"/"util"/"env_posix.cc" +const + 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") + +static: + echo "Initialize submodule" + + discard gorge "git submodule deinit -f \"" & root & "\"" + discard gorge "git submodule update --init --recursive --checkout \"" & root & "\"" + + echo "Clean 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 + echo output + if exitCode != 0: + discard gorge "rm -rf " & buildDir + raise (ref Defect)(msg: "Failed to build LevelDB") + when defined(windows): {.compile: envWindows.} {.passc: "-DLEVELDB_PLATFORM_WINDOWS".}