2024-05-09 08:18:06 +00:00
|
|
|
#!/bin/bash
|
|
|
|
root=$(dirname "$0")
|
|
|
|
|
2024-05-09 12:58:31 +00:00
|
|
|
sourceDir="${root}/src/vendor"
|
|
|
|
buildDir="${root}/build"
|
2024-05-09 12:42:38 +00:00
|
|
|
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 12:58:31 +00:00
|
|
|
cmake -S "${sourceDir}" -B "${buildDir}"
|
2024-05-09 09:01:21 +00:00
|
|
|
|
2024-05-09 09:58:18 +00:00
|
|
|
# Remove testing, benchmarking, third-party libraries.
|
2024-05-09 12:58:31 +00:00
|
|
|
rm -Rf "${sourceDir}/third_party"
|
|
|
|
rm -Rf "${sourceDir}/benchmarks"
|
|
|
|
rm "${sourceDir}/util/testutil.cc"
|
2024-05-09 09:58:18 +00:00
|
|
|
|
2024-05-09 12:05:01 +00:00
|
|
|
# Prelude:
|
2024-05-09 12:42:38 +00:00
|
|
|
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:58:31 +00:00
|
|
|
for file in `find "${sourceDir}" -type f -name "*.${ext}" \
|
2024-05-09 12:05:01 +00:00
|
|
|
| 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 12:58:31 +00:00
|
|
|
--includeDirs="${sourceDir}" \
|
|
|
|
--includeDirs="${sourceDir}/helpers" \
|
|
|
|
--includeDirs="${sourceDir}/helpers/memenv" \
|
|
|
|
--includeDirs="${sourceDir}/port" \
|
|
|
|
--includeDirs="${sourceDir}/include" \
|
|
|
|
--includeDirs="${buildDir}/include" \
|
|
|
|
"${sourceDir}/include/leveldb/c.h" >> "${output}"
|
|
|
|
|
|
|
|
# --includeDirs="${buildDir}/include/port" \
|
|
|
|
|
2024-05-09 12:05:01 +00:00
|
|
|
|