>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?
>I'd like to see this trivial Makefile.
SOURCES=$(find -name *.cpp)
g++ -std=c++11 -g $(SOURCES) -o binaries/test.elf $(INCLUDE)
I didn't generate .o files here, but that'd be a call to a bash script
looping over them, generating the .o file,
and ensuring a unique name (by sorting the list of paths first, then
`sed`ing the / to be _).
for i in ${LIST}; do
echo $i | sed 's|/|_|g' # GCC invocation follows naturally...
done
Is there any way of doing this (E.g. prepending paths to the o-files and
replacing / by underscores)?
On Wednesday, August 5, 2015 at 8:10:59 PM UTC+2, [email protected] wrote:
>
> On Wed, Aug 5, 2015 at 12:38 PM, Bourgond Aries <[email protected]
> <javascript:>> wrote:
>
>> I have a project with a lot of directories.
>> I want to just build every .c file and dump the .o files in $(TOP)/temp/.
>>
>> Then I'd like to link them into an executable.
>>
>
> 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>'})
>
> Tuprules.lua (at the top of your project):
> NETHACK_ROOT = tup.getcwd()
>
> Tupfile.lua (wherever you want to link everything):
> tup.rule('$(NETHACK_ROOT)/<objs>', 'gcc -o %o %<objs>', 'nethack')
>
> So three files in total, each one line.
>
>
>>
>> This is trivial with make.
>>
>
> I'd like to see this trivial Makefile.
>
>
>> How is this done in tup?
>> The single-tupfile-per-directory and similar limitations are not
>> practical and they clutter.
>> What am I supposed to do? Propagate the .o files up to the parent
>> directory? What
>> if the files have the same name?
>>
>
> If the files have the same name, won't you run into trouble putting
> everything in $(TOP)/temp regardless?
>
> -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.