nim-leveldb/build.sh

52 lines
1.4 KiB
Bash
Raw Normal View History

2024-05-09 08:18:06 +00:00
#!/bin/bash
root=$(dirname "$0")
output="${root}/src/leveldb/raw.nim"
2024-05-09 08:18:06 +00:00
# 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" > "${output}"
echo >> "${output}"
2024-05-09 09:01:21 +00:00
# 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" \
2024-05-09 12:11:08 +00:00
| grep -v "env_posix.cc" \
| grep -v "leveldbutil.cc"`; do
2024-05-09 12:05:01 +00:00
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" \
"${root}/sources/include/leveldb/c.h" >> "${output}"
2024-05-09 12:05:01 +00:00