nim-leveldb/build.sh

49 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 12:05:01 +00:00
# Prelude:
cat "${root}/prelude.nim" > "${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
2024-05-09 12:05:01 +00:00
for file in `find "${root}/sources" -type f -name "*.${ext}" \
| grep -v "_test" \
| grep -v "env_windows.cc" \
| grep -v "env_posix.cc"`; do
compile="${compile} --compile=${file}"
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" \
2024-05-09 12:05:01 +00:00
--includeDirs="${root}/build/include/port" \
2024-05-09 09:26:26 +00:00
"${root}/sources/include/leveldb/c.h" >> "${root}/leveldb.nim"
2024-05-09 12:05:01 +00:00