nim-sqlite3-abi/update.sh

32 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2019-04-10 17:58:14 +00:00
#!/bin/bash
MAJOR="${1:-3}"
2023-02-21 07:34:28 +00:00
MINOR="${2:-40}"
PATCH="${3:-1}"
2019-04-10 17:58:14 +00:00
VER_INT="$(printf "%d%02d%02d00" "$MAJOR" "$MINOR" "$PATCH")"
# TODO check sha256sum
cd sqlite3_abi
2019-04-10 17:58:14 +00:00
ZIP="sqlite-amalgamation-$VER_INT.zip"
2023-02-21 07:34:28 +00:00
[ -f "$ZIP" ] || wget https://www.sqlite.org/2022/$ZIP
2019-04-10 17:58:14 +00:00
unzip -jo $ZIP "sqlite-amalgamation-$VER_INT/sqlite3.c" "sqlite-amalgamation-$VER_INT/sqlite3.h"
cd ..
[[ -v HAS_NIMTEROP ]] || nimble install -y nimterop@0.6.13
2019-04-10 17:58:14 +00:00
nim c -o:wrap --verbosity:0 --hints:off ./sqlite3_abi/wrap.nim
2020-02-17 14:38:49 +00:00
./wrap
2019-04-10 17:58:14 +00:00
sed -i \
2023-02-21 08:42:23 +00:00
-e "s|cdecl|sqlitedecl|g" \
2019-04-10 17:58:14 +00:00
-e "s|$PWD/||" \
2023-02-21 23:01:28 +00:00
-e 's|{.experimental: "codeReordering".}|{.experimental: "codeReordering".}\nwhen (NimMajor, NimMinor) < (1, 4):\n {.pragma: sqlitedecl, cdecl, gcsafe, raises: [Defect].}\nelse:\n {.pragma: sqlitedecl, gcsafe, cdecl, raises: [].}|' \
-e "s|sqlite3_column_text\\*(a1: ptr sqlite3_stmt; iCol: cint): ptr cuchar|sqlite3_column_text\\*(a1: ptr sqlite3_stmt; iCol: cint): cstring|" \
-e "s|sqlite3_value_text\\*(a1: ptr sqlite3_value): ptr cuchar|sqlite3_value_text\\*(a1: ptr sqlite3_value): cstring|" \
sqlite3_abi/sqlite3_gen.nim