[go-nuts] Compile files in subdirectories

1,162 views
Skip to first unread message

Archos

unread,
May 17, 2010, 4:48:58 PM5/17/10
to golang-nuts
Is possible compile source files in subdirectories from the Makefile?

I've a structure like the next one but it only compiles the source
files of the actual directory (error.go, util.go).

===
GOFILES=\
error.go\
util.go\
\
key/aes.go\
key/base.go\
key/dsaprivate.go\
===

It would very helpful that source files could be in subdirectories
overall when you have more than 20 source files.

Archos

unread,
May 17, 2010, 7:17:35 PM5/17/10
to golang-nuts
The only problem now is that `gotest` doesn't searches through
subdirectories.

Archos wrote:
> Is possible compile source files in subdirectories from the Makefile?
>
> I've a structure like the next one but it only compiles the source
> files of the actual directory (error.go, util.go).
>
> ===
> GOFILES=\
> error.go\
> util.go\
> \
> key/aes.go\
> key/base.go\
> key/dsaprivate.go\
> ===
The problem was that I had a line commented out (using #), and it
looks that `make` skips all the next lines from there.

Russ Cox

unread,
May 21, 2010, 2:12:16 AM5/21/10
to Archos, golang-nuts
I would have expected the above to work,
but the convention in Go is to put everything
in one directory. If you have so many files
that you need subdirectories, you might consider
making each subdirectory its own package and
use implicit imports to refer to the code in subdirectories.

Following the one directory = one package convention
will make any automated build tool that comes along
work with your code.

Russ

Archos

unread,
May 21, 2010, 4:37:26 AM5/21/10
to golang-nuts
OK. The use of subdirectories was to have all well organized but
knowing that then I've moved them to the same directory:

From:
key/aes.go\
key/base.go\
key/dsaprivate.go\

to:
key-aes.go\
key-base.go\
key-dsaprivate.go\

Using a character as separator lets me to get the same goal.

abiosoft

unread,
May 21, 2010, 6:50:04 AM5/21/10
to golang-nuts
i you really need to build all at once,
u can try gobuild at
http://code.google.com/p/gobuild

Russel Winder

unread,
May 21, 2010, 7:05:18 AM5/21/10
to abiosoft, golang-nuts
On Fri, 2010-05-21 at 03:50 -0700, abiosoft wrote:
> i you really need to build all at once,
> u can try gobuild at
> http://code.google.com/p/gobuild

From the website:

"gobuild is an automatic build tool that aims to replace Makefiles for
simple projects written in the Go programming language. It creates a
dependency graph of all local imports and compiles them in the right
order using the gc Go compiler."

Which seems like a very limited ambition for a build framework.

Given that there are already a number of build frameworks out there
(SCons and Waf to name but two) that are not language specific but could
easily be used for Go, wouldn't it be better to write plugins for them
to handle Go?

--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel...@ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: rus...@russel.org.uk
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder

signature.asc
Reply all
Reply to author
Forward
0 new messages