Commit df7db445 authored by Kirill Smelkov's avatar Kirill Smelkov

golang: Hook-in pkg-config for Cgo support

The most convenient way to discover CFLAGS/LDFLAGS when building Cgo bits is
via pkg-config:

    https://golang.org/cmd/cgo/

For this to work let's add pkg-config to be available there in gowork out of
the box, and provide users with a way to specify which C packages they want to
be there on gowork's $PKG_CONFIG_PATH, e.g. this way:

    [gowork]
    cpkgpath =
        ${sqlite3:location}/lib/pkgconfig
        ${zlib:location}/lib/pkgconfig

In buildout sources cpkgpath is specified as multiline - not one line with ":"
delimiters - with the idea that it should be easy to amend gowork.cpkgpath with "+="
in different places.
parent 8d623f5f
......@@ -3,6 +3,7 @@
extends =
../findutils/buildout.cfg
../git/buildout.cfg
../pkgconfig/buildout.cfg
parts = gowork
......@@ -64,7 +65,15 @@ environment-extra =
# github.com/pkg/profile \
# golang.org/x/perf/cmd/benchstat
#
# it is possible to specify Go build flags used for compilation e.g. this way:
# For Cgo support pkg-config is made pre-available by gowork, and users
# should list paths where to search for pkg-config files, e.g. this way:
#
# [gowork]
# cpkgpath =
# ${sqlite3:location}/lib/pkgconfig
# ${zlib:location}/lib/pkgconfig
#
# It is also possible to specify Go build flags used for compilation e.g. this way:
#
# [gowork]
# buildflags = -race
......@@ -80,6 +89,9 @@ golang = ${golang19:location}
# no special build flags by default
buildflags =
# empty pkg-config path by default
cpkgpath =
# everything is done by dependent parts
recipe = plone.recipe.command
command = :
......@@ -93,7 +105,7 @@ recipe = slapos.recipe.template
url = ${:_profile_base_location_}/goenv.sh.in
output = ${gowork:directory}/env.sh
depends = ${gowork.mkdir:recipe}
md5sum = a9a265135931b3da53f4392870748264
md5sum = 7a067a3974c446c3eaa0e82818ba1adb
[gowork.mkdir]
# NOTE do not use slapos.cookbook:mkdirectory here - if anything in software (not instance)
......
......@@ -3,13 +3,16 @@
# ---- 8< ---- (buildout substitution here)
# PATH so that go & friends work out of the box
export PATH=${gowork:golang}/bin:${git:location}/bin:${buildout:bin-directory}:$PATH
export PATH=${gowork:golang}/bin:${git:location}/bin:${pkgconfig:location}/bin:${buildout:bin-directory}:$PATH
X=${gowork:directory}
export PKG_CONFIG_PATH=$(echo -n "${gowork:cpkgpath}" |tr '\n' ':'):$PKG_CONFIG_PATH
# ---- 8< ----
export GOPATH=$X:$GOPATH
export PATH=$X/bin:$PATH
export PS1="(`basename $X`) $PS1"
# strip trailing : from $GOPATH
# strip trailing : from $GOPATH, $PKG_CONFIG_PATH
GOPATH=$${GOPATH%:}
PKG_CONFIG_PATH=$${PKG_CONFIG_PATH%:}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment