Hello all
I've been doing some work on building Go code with SCons (release
coming soon), with some inspiration from Ross Light's sconsgo work:
https://code.launchpad.net/sconsgo
I've added support for cgo and a few methods to make build scripts for
projects that follow the src/{pkg,cmd} convention as simple as:
env = Environment(tools=['default','golang'])
env.GoPackages('src/pkg')
env.GoCommands('src/cmd')
One issue I had to deal with is that one needs to obtain package names
and imports from .go files to calculate dependencies.
I started by parsing the output from gofmt -ast=true, but this is too
slow. Running gofmt with -ast=true takes about 6 seconds for our
project, where the entire build with make takes less than 2 seconds.
Ross's solution for this problem in sconsgo was to include a small
helper application (written in Go) to just print out package names and
imports. Using this helper instead of gofmt allows our SCons build to
run as fast as make.
Given that many build tools (SCons, waf, etc.) need these two bits of
information, perhaps support for this special case can be rolled into
gofmt? Alternatively, maybe a more flexible goast tool could be
created?
I think it would be worthwhile to have a tool like this included in
the Go distribution so that any build system can use it.
Thoughts on how to approach this greatly appreciated.
Regards
Albert