Hello again!
For now (maybe even "forever") I settled for something like the solution
presented below. I'm sending more than a simplest example, maybe someone
will find that a good starting point for his/her work with lua parser.
in Tuprules.lua:
===========================================================
-- get "file specific flags" from table (ASFLAGS, CFLAGS or CXXFLAGS)
for file named filename
function getSpecificFlags(table, filename)
specific_flags = {}
if table[filename] ~= nil then
specific_flags = table[filename]
end
return specific_flags
end
-- assemble file named input
function as(input)
specific_flags = getSpecificFlags(ASFLAGS, input)
output = {OUTPUT .. tup.getrelativedir(TOP) .. '/%B.o',
'$(TOP)/<objects>'}
tup.rule(input, "$(AS) $(ASFLAGS) $(specific_flags) -c %f -o %o",
output)
end
-- compile (C) file named input
function cc(input)
specific_flags = getSpecificFlags(CFLAGS, input)
output = {OUTPUT .. tup.getrelativedir(TOP) .. '/%B.o',
'$(TOP)/<objects>'}
tup.rule(input, "$(CC) $(CFLAGS) $(specific_flags) -c %f -o %o", output)
end
-- compile (C++) file named input
function cxx(input)
specific_flags = getSpecificFlags(CXXFLAGS, input)
output = {OUTPUT .. tup.getrelativedir(TOP) .. '/%B.o',
'$(TOP)/<objects>'}
tup.rule(input, "$(CXX) $(CXXFLAGS) $(specific_flags) -c %f -o %o",
output)
end
-- link all objects from $(TOP)/<objects> into file named output
function link(output)
extra_output = {OUTPUT .. PROJECT .. ".map"}
tup.rule({'$(TOP)/<objects>'}, "$(LD) $(LDFLAGS) %<objects> -o %o",
{output, extra_outputs = extra_output})
end
===========================================================
Usage in Tupfile.lua:
===========================================================
ASFLAGS["ARMv7-M-startup.S"] = "-D__USES_TWO_STACKS -D__USES_CXX"
for index, filename in ipairs(tup.glob('*.S')) do
as(filename)
end
for index, filename in ipairs(tup.glob('*.c')) do
cc(filename)
end
for index, filename in ipairs(tup.glob('*.cpp')) do
cxx(filename)
end
===========================================================
This lua parser is pretty nice, but there are still some rough edges...
Regards,
FCh
--
--
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.