feat: hecitc C: add hectic-config
This commit is contained in:
@@ -18,9 +18,46 @@ stdenv.mkDerivation {
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/lib $out/include
|
||||
mkdir -p $out/lib $out/include $out/bin
|
||||
cp target/libhectic.a $out/lib/
|
||||
cp hectic.h $out/include/
|
||||
|
||||
# Create hectic-config script
|
||||
cat > $out/bin/hectic-config <<EOF
|
||||
#!/bin/sh
|
||||
|
||||
usage() {
|
||||
echo "Usage: hectic-config [--cflags] [--libs]"
|
||||
echo " --cflags Print the compiler flags"
|
||||
echo " --libs Print the linker flags"
|
||||
echo " --help Display this help message"
|
||||
exit \$1
|
||||
}
|
||||
|
||||
if [ \$# -eq 0 ]; then
|
||||
usage 1
|
||||
fi
|
||||
|
||||
while [ \$# -gt 0 ]; do
|
||||
case "\$1" in
|
||||
--cflags)
|
||||
echo "-I$out/include"
|
||||
;;
|
||||
--libs)
|
||||
echo "-L$out/lib -lhectic"
|
||||
;;
|
||||
--help)
|
||||
usage 0
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
EOF
|
||||
|
||||
chmod +x $out/bin/hectic-config
|
||||
'';
|
||||
|
||||
meta = {
|
||||
|
||||
@@ -7,7 +7,11 @@ PG_CONFIG = pg_config
|
||||
|
||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
|
||||
# Add hectic library path
|
||||
CFLAGS += -I -lhectic
|
||||
HECTIC_CONFIG = hectic-config
|
||||
|
||||
CFLAGS += $(shell $(HECTIC_CONFIG) --cflags)
|
||||
LDFLAGS += $(shell $(HECTIC_CONFIG) --libs)
|
||||
|
||||
SHLIB_LINK := $(LIBS)
|
||||
|
||||
include $(PGXS)
|
||||
@@ -86,8 +86,14 @@ case "$MODE" in
|
||||
build)
|
||||
mkdir -p target
|
||||
echo "# Building PostgreSQL extension"
|
||||
|
||||
# Get hectic library paths from nix
|
||||
HECTIC_PATH=$(nix build --print-out-paths -f ../../../. c-hectic)
|
||||
HECTIC_INCLUDE="$HECTIC_PATH/include"
|
||||
HECTIC_LIB="$HECTIC_PATH/lib"
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
gcc $CFLAGS $OPTFLAGS -I$PG_INCLUDE -shared -o target/hel.so hel.c
|
||||
gcc $CFLAGS $OPTFLAGS -I$PG_INCLUDE -I$HECTIC_INCLUDE -shared -o target/hel.so hel.c -L$HECTIC_LIB -lhectic
|
||||
|
||||
# Copy extension files to target directory
|
||||
cp hel.control target/
|
||||
|
||||
Reference in New Issue
Block a user