Symbol checks (#2)

* sets up checkers

* updates raw.nim

* Removes prints

* Removes automatic symbol check

* update

* Attempt to run cmake on every build

* Restores build.sh

* Updates readme

* Removes unnecessary include dir

* updates
This commit is contained in:
Ben Bierens 2024-05-22 18:41:07 +02:00 committed by GitHub
parent f0d18f6d35
commit 5f0a4ea871
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 90 additions and 93 deletions

View File

@ -6,6 +6,8 @@ Original nim LevelDB wrapper: [HERE](https://github.com/zielmicha/leveldb.nim)
Replacing of system library dependency with self-contained C/CPP interoperability by (Codex.Storage)[https://codex.storage]
## Usage
Create a database:
```Nim
import leveldbstatic
@ -49,3 +51,25 @@ Iterate over subset of database content:
db.close()
```
## Compiling with optimizations
CMake is used during compilation to determine which of the following optimization options are enabled. You can set the following nim compiler flags to 0 or 1 to override them:
- fdatasync from <unistd.h> `--passC:-DHAVE_FDATASYNC=1`
- F_FULLSYNC from <fcntl.h> `--passC:-DHAVE_FULLFSYNC=1`
- O_CLOEXEC from <fcntl.h> `--passC:-DHAVE_O_CLOEXEC=1`
- crc32c from <crc32c/crc32c.h> `--passC:-DHAVE_CRC32C=1`
- snappy from <snappy.h> `--passC:-DHAVE_SNAPPY=1`
- zstd from <zstd.h> `--passC:-DHAVE_ZSTD=1`
## Updating
When you want to update this library to a new version of LevelDB, follow these steps:
- Update LevelDB submodule to new version.
- Run 'build.sh'.
- Run 'nimble build' and 'nimble test'.
- Make sure everything's working.
- Increment version of this library in 'leveldbstatic.nimble'.
- Commit the changes.
- Tag the commit with the new version number.
- Push.

View File

@ -47,10 +47,8 @@ toast \
--includeDirs="${sourceDir}/helpers/memenv" \
--includeDirs="${sourceDir}/port" \
--includeDirs="${sourceDir}/include" \
--includeDirs="${buildDir}/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}"

View File

@ -1,38 +0,0 @@
// Copyright 2017 The LevelDB Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.
#ifndef STORAGE_LEVELDB_PORT_PORT_CONFIG_H_
#define STORAGE_LEVELDB_PORT_PORT_CONFIG_H_
// Define to 1 if you have a definition for fdatasync() in <unistd.h>.
#if !defined(HAVE_FDATASYNC)
#define HAVE_FDATASYNC 1
#endif // !defined(HAVE_FDATASYNC)
// Define to 1 if you have a definition for F_FULLFSYNC in <fcntl.h>.
#if !defined(HAVE_FULLFSYNC)
#define HAVE_FULLFSYNC 0
#endif // !defined(HAVE_FULLFSYNC)
// Define to 1 if you have a definition for O_CLOEXEC in <fcntl.h>.
#if !defined(HAVE_O_CLOEXEC)
#define HAVE_O_CLOEXEC 1
#endif // !defined(HAVE_O_CLOEXEC)
// Define to 1 if you have Google CRC32C.
#if !defined(HAVE_CRC32C)
#define HAVE_CRC32C 0
#endif // !defined(HAVE_CRC32C)
// Define to 1 if you have Google Snappy.
#if !defined(HAVE_SNAPPY)
#define HAVE_SNAPPY 0
#endif // !defined(HAVE_SNAPPY)
// Define to 1 if you have Zstd.
#if !defined(HAVE_Zstd)
#define HAVE_ZSTD 0
#endif // !defined(HAVE_ZSTD)
#endif // STORAGE_LEVELDB_PORT_PORT_CONFIG_H_

View File

@ -1,8 +1,37 @@
import os
const root = currentSourcePath.parentDir.parentDir
const envWindows = root/"vendor"/"util"/"env_windows.cc"
const envPosix = root/"vendor"/"util"/"env_posix.cc"
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")
static:
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")
when defined(windows):
{.compile: envWindows.}
@ -13,13 +42,3 @@ when defined(windows):
when defined(posix):
{.compile: envPosix.}
{.passc: "-DLEVELDB_PLATFORM_POSIX".}
{.passc: "-DHAVE_FDATASYNC=0".}
{.passc: "-DHAVE_FULLFSYNC=0".}
{.passc: "-DHAVE_O_CLOEXEC=0".}
{.passc: "-DHAVE_CRC32C=0".}
{.passc: "-DHAVE_SNAPPY=0".}
{.passc: "-DHAVE_ZSTD=0".}
{.passc: "-DHAVE_Zstd=0".}

View File

@ -1,8 +1,37 @@
import os
const root = currentSourcePath.parentDir.parentDir
const envWindows = root/"vendor"/"util"/"env_windows.cc"
const envPosix = root/"vendor"/"util"/"env_posix.cc"
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")
static:
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")
when defined(windows):
{.compile: envWindows.}
@ -14,19 +43,9 @@ when defined(posix):
{.compile: envPosix.}
{.passc: "-DLEVELDB_PLATFORM_POSIX".}
{.passc: "-DHAVE_FDATASYNC=0".}
{.passc: "-DHAVE_FULLFSYNC=0".}
{.passc: "-DHAVE_O_CLOEXEC=0".}
{.passc: "-DHAVE_CRC32C=0".}
{.passc: "-DHAVE_SNAPPY=0".}
{.passc: "-DHAVE_ZSTD=0".}
{.passc: "-DHAVE_Zstd=0".}
# Generated @ 2024-05-13T12:00:58+02:00
# Generated @ 2024-05-22T10:00:37+02:00
# Command line:
# /home/ben/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --compile=./vendor/db/log_writer.cc --compile=./vendor/db/db_impl.cc --compile=./vendor/db/db_iter.cc --compile=./vendor/db/dumpfile.cc --compile=./vendor/db/c.cc --compile=./vendor/db/builder.cc --compile=./vendor/db/filename.cc --compile=./vendor/db/write_batch.cc --compile=./vendor/db/table_cache.cc --compile=./vendor/db/version_edit.cc --compile=./vendor/db/dbformat.cc --compile=./vendor/db/log_reader.cc --compile=./vendor/db/memtable.cc --compile=./vendor/db/version_set.cc --compile=./vendor/db/repair.cc --compile=./vendor/table/block.cc --compile=./vendor/table/two_level_iterator.cc --compile=./vendor/table/table_builder.cc --compile=./vendor/table/iterator.cc --compile=./vendor/table/block_builder.cc --compile=./vendor/table/merger.cc --compile=./vendor/table/format.cc --compile=./vendor/table/filter_block.cc --compile=./vendor/table/table.cc --compile=./vendor/util/hash.cc --compile=./vendor/util/arena.cc --compile=./vendor/util/options.cc --compile=./vendor/util/histogram.cc --compile=./vendor/util/crc32c.cc --compile=./vendor/util/env.cc --compile=./vendor/util/filter_policy.cc --compile=./vendor/util/bloom.cc --compile=./vendor/util/logging.cc --compile=./vendor/util/coding.cc --compile=./vendor/util/status.cc --compile=./vendor/util/cache.cc --compile=./vendor/util/comparator.cc --compile=./vendor/helpers/memenv/memenv.cc --pnim --preprocess --noHeader --includeDirs=./vendor --includeDirs=./vendor/helpers --includeDirs=./vendor/helpers/memenv --includeDirs=./vendor/port --includeDirs=./vendor/include --includeDirs=./build/include ./vendor/include/leveldb/c.h
# /home/ben/.nimble/pkgs/nimterop-0.6.13/nimterop/toast --compile=./vendor/db/log_writer.cc --compile=./vendor/db/db_impl.cc --compile=./vendor/db/db_iter.cc --compile=./vendor/db/dumpfile.cc --compile=./vendor/db/c.cc --compile=./vendor/db/builder.cc --compile=./vendor/db/filename.cc --compile=./vendor/db/write_batch.cc --compile=./vendor/db/table_cache.cc --compile=./vendor/db/version_edit.cc --compile=./vendor/db/dbformat.cc --compile=./vendor/db/log_reader.cc --compile=./vendor/db/memtable.cc --compile=./vendor/db/version_set.cc --compile=./vendor/db/repair.cc --compile=./vendor/table/block.cc --compile=./vendor/table/two_level_iterator.cc --compile=./vendor/table/table_builder.cc --compile=./vendor/table/iterator.cc --compile=./vendor/table/block_builder.cc --compile=./vendor/table/merger.cc --compile=./vendor/table/format.cc --compile=./vendor/table/filter_block.cc --compile=./vendor/table/table.cc --compile=./vendor/util/hash.cc --compile=./vendor/util/arena.cc --compile=./vendor/util/options.cc --compile=./vendor/util/histogram.cc --compile=./vendor/util/crc32c.cc --compile=./vendor/util/env.cc --compile=./vendor/util/filter_policy.cc --compile=./vendor/util/bloom.cc --compile=./vendor/util/logging.cc --compile=./vendor/util/coding.cc --compile=./vendor/util/status.cc --compile=./vendor/util/cache.cc --compile=./vendor/util/comparator.cc --compile=./vendor/helpers/memenv/memenv.cc --pnim --preprocess --noHeader --includeDirs=./vendor --includeDirs=./vendor/helpers --includeDirs=./vendor/helpers/memenv --includeDirs=./vendor/port --includeDirs=./vendor/include ./vendor/include/leveldb/c.h
{.push hint[ConvFromXtoItselfNotNeeded]: off.}
import macros
@ -79,7 +98,6 @@ macro defineEnum(typ: untyped): untyped =
{.passc: "-I" & root & "/vendor/helpers/memenv".}
{.passc: "-I" & root & "/vendor/port".}
{.passc: "-I" & root & "/vendor/include".}
{.passc: "-I" & root & "/build/include".}
{.compile: root & "/vendor/db/log_writer.cc".}
{.compile: root & "/vendor/db/db_impl.cc".}
{.compile: root & "/vendor/db/db_iter.cc".}

View File

@ -1,8 +0,0 @@
#include <unistd.h>
int main(int argc, char** argv)
{
fdatasync(-1);
return 0;
}

View File

@ -1,8 +0,0 @@
#include <fcntl.h>
int main(int argc, char** argv)
{
int i = F_FULLSYNC;
return 0;
}

View File

@ -1,8 +0,0 @@
#include <fcntl.h>
int main(int argc, char** argv)
{
int i = O_CLOEXEC;
return 0;
}