nim-leveldb/build.sh

50 lines
1.3 KiB
Bash
Raw Normal View History

2024-05-09 08:18:06 +00:00
#!/bin/bash
root=$(dirname "$0")
# install nimterop, if not already installed
if ! [ -x "$(command -v toast)" ]; then
nimble install -y nimterop@0.6.13
fi
2024-05-09 09:58:18 +00:00
git submodule deinit -f "${root}"
git submodule update --init --recursive --checkout "${root}"
2024-05-09 09:01:21 +00:00
cmake -S "${root}/sources" -B "${root}/build"
2024-05-09 09:58:18 +00:00
# Remove testing, benchmarking, third-party libraries.
rm -Rf "${root}/sources/third_party"
rm -Rf "${root}/sources/benchmarks"
rm "${root}/sources/util/testutil.cc"
2024-05-09 09:01:21 +00:00
# prelude: not needed?
2024-05-09 09:42:52 +00:00
rm "${root}/leveldb.nim"
2024-05-09 09:01:21 +00:00
echo >> "${root}/leveldb.nim"
# assemble files to be compiled:
extensions="c cc cpp"
for ext in ${extensions}; do
for file in `find "${root}/sources" -type f -name "*.${ext}"`; do
2024-05-09 09:42:52 +00:00
if [[ $file == *"_test"* ]]; then
echo "Skip test file: ${file}"
else
2024-05-09 09:58:18 +00:00
echo "Include file: ${file}"
2024-05-09 09:42:52 +00:00
compile="${compile} --compile=${file}"
fi
2024-05-09 09:01:21 +00:00
done
done
2024-05-09 08:18:06 +00:00
# generate nim wrapper with nimterop
2024-05-09 09:26:26 +00:00
toast \
$compile \
--pnim \
--preprocess \
--noHeader \
2024-05-09 09:42:52 +00:00
--includeDirs="${root}/sources" \
--includeDirs="${root}/sources/helpers" \
--includeDirs="${root}/sources/helpers/memenv" \
--includeDirs="${root}/sources/port" \
--includeDirs="${root}/sources/include" \
2024-05-09 09:26:26 +00:00
--includeDirs="${root}/build/include" \
"${root}/sources/include/leveldb/c.h" >> "${root}/leveldb.nim"
2024-05-09 09:58:18 +00:00