Add src files
This commit is contained in:
28
eng/build-native.sh
Executable file
28
eng/build-native.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
BINDINGS_DIR="$ROOT_DIR/src/LibNftables.Bindings"
|
||||
WRAP_FILE="$BINDINGS_DIR/Generated/libnftables_wrap.c"
|
||||
OUT_DIR="$BINDINGS_DIR/runtimes/linux-x64/native"
|
||||
OUT_FILE="$OUT_DIR/libLibNftablesBindings.so"
|
||||
|
||||
if [[ ! -f "$WRAP_FILE" ]]; then
|
||||
echo "Missing SWIG wrapper: $WRAP_FILE" >&2
|
||||
echo "Run ./eng/regen-bindings.sh first." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$OUT_DIR"
|
||||
|
||||
CFLAGS="$(pkg-config --cflags libnftables 2>/dev/null || true)"
|
||||
LIBS="$(pkg-config --libs libnftables 2>/dev/null || echo '-lnftables')"
|
||||
|
||||
gcc -fPIC -shared -O2 \
|
||||
$CFLAGS \
|
||||
-I/usr/include \
|
||||
"$WRAP_FILE" \
|
||||
-o "$OUT_FILE" \
|
||||
$LIBS
|
||||
|
||||
echo "Built native wrapper: $OUT_FILE"
|
||||
22
eng/regen-bindings.sh
Executable file
22
eng/regen-bindings.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
BINDINGS_DIR="$ROOT_DIR/src/LibNftables.Bindings"
|
||||
SWIG_FILE="$BINDINGS_DIR/swig/libnftables.i"
|
||||
OUT_DIR="$BINDINGS_DIR/Generated"
|
||||
|
||||
mkdir -p "$OUT_DIR"
|
||||
rm -f "$OUT_DIR"/*.cs "$OUT_DIR"/*_wrap.c
|
||||
|
||||
swig \
|
||||
-csharp \
|
||||
-I/usr/include \
|
||||
-I/usr/local/include \
|
||||
-namespace LibNftables.Bindings.Native \
|
||||
-dllimport LibNftablesBindings \
|
||||
-outdir "$OUT_DIR" \
|
||||
-o "$OUT_DIR/libnftables_wrap.c" \
|
||||
"$SWIG_FILE"
|
||||
|
||||
echo "Generated SWIG bindings in $OUT_DIR"
|
||||
Reference in New Issue
Block a user