Commit 8c8f8dd3 authored by Jérome Perrin's avatar Jérome Perrin

component/golang: support environment variables during build

With this new environment option to gowork section, it is possible
to specify environment variables that will be set during the build,
more specifically when env.sh is sourced.

The implementation is a bit complex, so that the syntax is not strict
and whitespace are tolerated in the definition, ie. all these should be
understood:

    [gowork]
    environment =
      A=a
      B =b
      C= c
      D=d=d
parent 8183d953
......@@ -103,6 +103,13 @@ environment-extra =
# [gowork]
# buildflags = -race
#
# - If some environment variables are needed during the build, they can be
# added with environment option, e.g. this way:
#
# [gowork]
# environment =
# CGO_ENABLED = 1
# FOO = bar
#
# Users can also add `install` field to [gowork] to request Go programs to be
# automatically installed, for example:
......@@ -143,6 +150,9 @@ cpkgpath =
# by default don't `go install` anything
install =
# empty key=value environment by default
environment =
# everything is done by dependent parts
recipe = plone.recipe.command
command = :
......
......@@ -15,4 +15,4 @@
[gowork-env.sh]
filename = goenv.sh.in
md5sum = 6efdf5d63381c240c7d206d7939a63f7
md5sum = f6d0fc24e3f08f27bc2bd85003ca5ec2
......@@ -2,6 +2,17 @@
# Usage: env.sh [/path/to/env.sh]
# ---- 8< ---- (buildout substitution here)
# extend environment
while read x ; do
k=$(echo $x | cut -d '=' -f 1 | sed -e 's/[[:space:]]*$//' )
v=$(echo $x | cut -d '=' -f 2- | sed -e 's/^[[:space:]]*//' )
if [ -n "$k" ]
then export $k="$v"
fi
done <<-EOF
${gowork:environment}
EOF
# PATH so that go & friends work out of the box
export PATH=${gowork:golang}/bin:${git:location}/bin:${pkgconfig:location}/bin:${buildout:bin-directory}:${gcc:prefix}/bin:$PATH
X=${gowork:directory}
......
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