On Wed, Aug 5, 2015 at 3:10 PM, Bourgond Aries <[email protected]> wrote:
> >You can do something like this with the Lua parser:
>
> >Tupdefault.lua (at the top of your project):
> >tup.foreach_rule('*.c', 'gcc -c %f -o %o -I$(NETHACK_ROOT)/include',
> {'%B.o', '$(NETHACK_ROOT)/<objs>'})
>
> Interestingly enough, the code your provided put the object files in the
> source directories.
> To rememedy this I had to write the following in Tupdefault.lua:
> tup.foreach_rule('*.cpp', 'g++ -std=c++11 -g -Wall -Wextra -Wfatal-errors
> -c %f -o %o -I$(NETHACK_ROOT)/', {''$(NETHACK_ROOT)/temp/%B.o'})
>
> A question regarding this, btw, is the DSL deprecated in favor of Lua? I
> was namely generating DSL code using bash, then this came along.
> The Lua API seems a lot more versatile. Also, is "NETHACK_ROOT" the root
> folder convention that ought to be used?
>
Nope, it hasn't been deprecated. The lua parser just has some features that
make it better suited to this particular use-case, just as automatically
including the Tuprules.lua files and allowing a default tupfile to be
parsed if the directory doesn't contain one.
I like to use PROJECTNAME_ROOT as the variable pointing to the top-level
directory. Obviously you would only use NETHACK_ROOT if you were compiling
nethack... I probably should have mentioned that's what I was testing with
:)
>
> >I'd like to see this trivial Makefile.
> SOURCES=$(find -name *.cpp)
> g++ -std=c++11 -g $(SOURCES) -o binaries/test.elf $(INCLUDE)
>
I don't think this is really equivalent to what tup is doing. There is no
dependency tracking whatsoever, and even if you add gcc -MMD it would still
be wrong when you add include directories. Additionally, if you remove a
.cpp file from your tree, make will leave the corresponding .o file hanging
around. Tup correctly removes the .o file.
-Mike
--
--
tup-users mailing list
email: [email protected]
unsubscribe: [email protected]
options: http://groups.google.com/group/tup-users?hl=en
---
You received this message because you are subscribed to the Google Groups
"tup-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.