On 2021-3-30 06:35 , Christopher Jones wrote:
Hi All,

Working on fixing a build issue and hitting a limit in my current understanding of Tcl… I am trying to set some new env vars in the build.env

         set ldflags ${configure.ldflags}
         build.env-append   GO_EXTLINK_ENABLED=1
         build.env-append   GO_LDFLAGS='-extldflags\=$ldflags’

however, when the port in question using ${build.env} I get

DEBUG: system -W /opt/local/var/macports/build/_Users_chris_Projects_MacPorts_ports_devel_codesearch/codesearch/work/gopath/src/github.com/google/codesearch: <http://github.com/google/codesearch:> GOPATH=/opt/local/var/macports/build/_Users_chris_Projects_MacPorts_ports_devel_codesearch/codesearch/work/gopath GOARCH=amd64 GOOS=darwin CC=/usr/bin/clang CXX=/usr/bin/clang++ GOPROXY=off GO111MODULE=off C_INCLUDE_PATH=/opt/local/include/LegacySupport OBJC_INCLUDE_PATH=/opt/local/include/LegacySupport CPLUS_INCLUDE_PATH=/opt/local/include/LegacySupport OBJCPLUS_INCLUDE_PATH=/opt/local/include/LegacySupport GO_EXTLINK_ENABLED=1 {GO_LDFLAGS='-extldflags=-L/opt/local/lib -Wl,-headerpad_max_install_names -lMacportsLegacySupport'} /opt/local/bin/go build cmd/cgrep/cgrep.go sh: {GO_LDFLAGS=-extldflags=-L/opt/local/lib -Wl,-headerpad_max_install_names -lMacportsLegacySupport}:

That isn't a result of setting build.env. You must have added this to build.args or similar.

See how the second env var I define above is shown inside {} braces, which of course sh cannot parse.

I have tried numerous forms of how to set

build.env-append   GO_LDFLAGS='-extldflags\=$ldflags’

but they all have the same issue.

I suspect this is just my lack of really undertanding quoting in tcl, so I am hoping someone can tell me what I am doing wrong ?

Do you want literal single quotes in the value of the environment variable? If so:

build.env-append   GO_LDFLAGS='-extldflags=${configure.ldflags}’

if not:

build.env-append   GO_LDFLAGS=-extldflags=${configure.ldflags}

The value of the *.env options never gets passed to a shell; the environment variables are set directly by our code. The parsing is very simple, perhaps deceptively so if you expect it to work like a shell. Each list element is expected to contain a single assignment, with everything before the first '=' used as the variable name, and everything after it used as the value to set it to.

A corollary is that something like this won't (in general) work:

build.args-append ${build.env}

because build.args has to deal with shell quoting. There's also a second bug in that line because it appends the entirety of build.env, which is a list, as a single element. The {*} operator is essential when doing something like this:

build.args foo bar
destroot.args-append {*}${build.args}

- Josh

Reply via email to