Skip to content

Commit

Permalink
bas
Browse files Browse the repository at this point in the history
  • Loading branch information
phadej committed Aug 29, 2024
1 parent fa25c11 commit 8d3abe6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ jobs:
uses: actions/cache/save@v4
if: always()
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }}
path: ${{ steps.setup-haskell.outputs.cabal-store }}
12 changes: 7 additions & 5 deletions hs-bindgen-libclang/configure
Original file line number Diff line number Diff line change
Expand Up @@ -3218,6 +3218,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# Extract the first word of "llvm-config", so it can be a program name with args.
set dummy llvm-config; ac_word=$2
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
Expand Down Expand Up @@ -3283,21 +3284,20 @@ LLVM_VERSION="$("$LLVM_CONFIG" --version)"
if test $? == 0; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LLVM_VERSION" >&5
printf "%s\n" "$LLVM_VERSION" >&6; }
# TODO: Use https://www.gnu.org/software/autoconf-archive/ax_compare_version.html
# to compare version
else
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: error" >&5
printf "%s\n" "error" >&6; }
as_fn_error $? "could not run llvm-config" "$LINENO" 5
fi
fi
HS_BINDGEN_EXTRA_LIBS="clang"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking LLVM library directory" >&5
printf %s "checking LLVM library directory... " >&6; }
if test -z "$LLVM_CONFIG"; then
HS_BINDGEN_LIBDIR="libfoo";
HS_BINDGEN_LIBDIR="$LLVM_PATH/lib"
else
HS_BINDGEN_LIBDIR="$("$LLVM_CONFIG" --libdir)";
fi
Expand All @@ -3307,13 +3307,14 @@ printf "%s\n" "$HS_BINDGEN_LIBDIR" >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking LLVM include directory" >&5
printf %s "checking LLVM include directory... " >&6; }
if test -z "$LLVM_CONFIG"; then
HS_BINDGEN_INCLUDEDIR=bar;
HS_BINDGEN_INCLUDEDIR="$LLVM_PATH/include"
else
HS_BINDGEN_INCLUDEDIR="$("$LLVM_CONFIG" --includedir)"
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $HS_BINDGEN_INCLUDEDIR" >&5
printf "%s\n" "$HS_BINDGEN_INCLUDEDIR" >&6; }
LIBS="$LIBS -l$HS_BINDGEN_EXTRA_LIBS"
LDFLAGS="$LDFLAGS -L$HS_BINDGEN_LIBDIR"
CPPFLAGS="$CPPFLAGS -I$HS_BINDGEN_INCLUDEDIR"
Expand Down Expand Up @@ -3406,6 +3407,7 @@ fi
ac_config_files="$ac_config_files hs-bindgen-libclang.buildinfo"
Expand Down
20 changes: 16 additions & 4 deletions hs-bindgen-libclang/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ AC_CONFIG_MACRO_DIRS([m4])

AC_PROG_CC

dnl The discovery logic is following
dnl * look for llvm-config (LLVM_CONFIG if set, in PATH otherwise)
dnl * if not found
dnl - if LLVM_PATH is set, use it (skip version check)
dnl - otherwise fail.

AC_ARG_VAR(LLVM_CONFIG, [Location of llvm-config])
AC_ARG_VAR(LLVM_PATH, [Location of LLVM installation])

Expand All @@ -25,39 +31,45 @@ else
LLVM_VERSION="$("$LLVM_CONFIG" --version)"
if test $? == 0; then
AC_MSG_RESULT([$LLVM_VERSION])
# TODO: Use https://www.gnu.org/software/autoconf-archive/ax_compare_version.html
# to compare version
dnl TODO: Use https://www.gnu.org/software/autoconf-archive/ax_compare_version.html to compare version
else
AC_MSG_RESULT([error])
AC_MSG_ERROR([could not run llvm-config])
fi
fi

dnl LIBS/LIBDIR/INCLUDEDIR

HS_BINDGEN_EXTRA_LIBS="clang"

AC_MSG_CHECKING([LLVM library directory])
if test -z "$LLVM_CONFIG"; then
HS_BINDGEN_LIBDIR="libfoo";
HS_BINDGEN_LIBDIR="$LLVM_PATH/lib"
else
HS_BINDGEN_LIBDIR="$("$LLVM_CONFIG" --libdir)";
fi
AC_MSG_RESULT($HS_BINDGEN_LIBDIR)

AC_MSG_CHECKING([LLVM include directory])
if test -z "$LLVM_CONFIG"; then
HS_BINDGEN_INCLUDEDIR=bar;
HS_BINDGEN_INCLUDEDIR="$LLVM_PATH/include"
else
HS_BINDGEN_INCLUDEDIR="$("$LLVM_CONFIG" --includedir)"
fi
AC_MSG_RESULT($HS_BINDGEN_INCLUDEDIR)

dnl Runtime checks

dnl Set some C related environment variables for further tests
LIBS="$LIBS -l$HS_BINDGEN_EXTRA_LIBS"
LDFLAGS="$LDFLAGS -L$HS_BINDGEN_LIBDIR"
CPPFLAGS="$CPPFLAGS -I$HS_BINDGEN_INCLUDEDIR"

AC_CHECK_HEADER([clang-c/Index.h],[],[AC_MSG_ERROR([Cannot find libclang headers])])
AC_CHECK_LIB([clang], [clang_createIndex],[],[AC_MSG_ERROR([Cannot link against libclang])])

dnl Substitution

AC_SUBST([HS_BINDGEN_EXTRA_LIBS])
AC_SUBST([HS_BINDGEN_LIBDIR])
AC_SUBST([HS_BINDGEN_INCLUDEDIR])
Expand Down

0 comments on commit 8d3abe6

Please sign in to comment.