fixed the go wrapper code further
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-11-01 01:42:47 +09:00
parent 3b9b02de83
commit 85a2152be4
5 changed files with 61 additions and 21 deletions

View File

@ -42,15 +42,18 @@ hclgo_DEPENDENCIES = hclgo.bin
## let the linker to move hclgo.bin to the actual target
hclgo_LINK = mv -f hclgo.bin hclgo$(EXEEXT) || echo "FAILED TO LINK"
hclgo.bin:
hclgo.bin: lib/libhcl.la
cp -pf $(srcdir)/go.mod $(builddir)/go.mod >/dev/null 2>&1 || true
chmod u+w $(builddir)/go.mod ## with `make distcheck`, the echo's redirection to the file fails without this permission change
sed -r -i -e "/^[[:space:]]*replace[[:space:]]+cfg[[:space:]]*=>/d" $(builddir)/go.mod
echo -e "\nreplace cfg => $(abs_builddir)/go/cfg" >> $(builddir)/go.mod
[ -f $(srcdir)/go.sum ] && cp -pf $(srcdir)/go.sum $(builddir)/go.sum >/dev/null 2>&1 || true
## ---------------------------------------------------------------
CC=$(CC) \
CGO_CFLAGS="-I$(abs_srcdir)/lib -I$(abs_builddir)/lib $(CFLAGS)" \
CGO_LDFLAGS="-L$(abs_builddir)/lib -L$(abs_builddir)/lib/.libs -lhcl -ldl -lquadmath" \
go build -C $(srcdir) -x -o $(abs_builddir)/hclgo.bin -modfile $(abs_builddir)/go.mod
## ---------------------------------------------------------------
go clean -C $(srcdir) -x -modfile $(abs_builddir)/go.mod
rm -rf $(builddir)/go.mod $(builddir)/go.sum