Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails without Go source tree #5

Open
dradtke opened this issue Dec 15, 2012 · 4 comments
Open

Build fails without Go source tree #5

dradtke opened this issue Dec 15, 2012 · 4 comments

Comments

@dradtke
Copy link

dradtke commented Dec 15, 2012

Building gogobject failed for me because the internal go tool dist failed with this error (I'm using openSUSE, not Ubuntu, but it's the same error). The dist tool appears to expect you to be working from the Go source tree, but I installed it through my package manager, which effectively renders it useless.

In order to get the build to work, I changed this section of code in waftools/go.py

vars = {}
try:
    out = self.cmd_and_log([self.env.GO, 'tool', 'dist', 'env'])
    for line in out.splitlines():
            eq = line.index('=')
            vars[line[:eq]] = line[eq+2:-1]
except (WafError, ValueError):
    pass

into

vars = os.environ

This forces waf to check the system variables directly, rather than the dist tool. The downside to this is that any missing variables (like GOHOSTARCH and GOCHAR) need to be set and exported before building. For reference, here are the values I used to get it working (64-bit openSUSE):

GOROOT     = /usr/lib64/go
GOBIN      = /usr/bin
GOARCH     = amd64
GOOS       = linux
GOHOSTARCH = amd64
GOHOSTOS   = linux
GOTOOLDIR  = /usr/lib64/go/pkg/tool/linux_amd64/
GOCHAR     = 6
GOPATH     = /usr/lib64/go/contrib

Every variable needs to have a value, because otherwise line 74 in waftools/go.py throws this error:

AttributeError: 'ConfigurationContext' object has no attribute 'bld'

After that, I was able to get it to build.

If there's a way to use the go tools to get values for each of these variables without requiring the Go source code, that would be a preferable fix, but I'm not familiar enough with them to know if there's an easy way to do that.

Hope this helps.

@nsf
Copy link
Owner

nsf commented Dec 16, 2012

There is a possible fix, but I'm not sure, try changing:

out = self.cmd_and_log([self.env.GO, 'tool', 'dist', 'env'])

to:

out = self.cmd_and_log([self.env.GO, 'env'])

@nsf
Copy link
Owner

nsf commented Dec 16, 2012

Also you were pointing at line 74 in waftools/go.py, doesn't make sense to me, I see no 'bld' even around it:
https://github.com/nsf/gogobject/blob/master/waftools/go.py#L74

@dradtke
Copy link
Author

dradtke commented Dec 17, 2012

Sorry, line 173.

I'm at work right now and can't test your fix, but I'll be sure to give it a shot and let you know soon.

@nsf
Copy link
Owner

nsf commented Dec 18, 2012

Indeed a bug on line 173. I've applied a fix and now the code uses go env instead of go tool dist env. Try it. It should work now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants