Thanks Rendaw for taking the time to reply.

Here's the code for my functions if it helps:

local function target(name)
  return '<' .. name .. '>'
end

local function cc_obj(src)
  out = '%B.o'
  return tup.rule(src, '^ CXX %f^ $(CXX) -c %f -o %o $(CXXFLAGS) -I$(TOP)', 
out)
end

function cc_lib(args)
  outs = {
    'lib' .. args.name .. '.a',
    target(args.name)
  }
  inputs = {}
  for i,v in ipairs(args.srcs) do inputs += cc_obj(v) end
  return tup.rule(inputs, '^ AR %o^ $(AR) crs %o %f', outs)
end

function cc_bin(args)
  outs = {
    args.name,
    target(args.name)
  }
  inputs = {}
  for i,v in ipairs(args.srcs) do inputs += cc_obj(v) end
  for i,v in ipairs(args.libs) do inputs += v end
  return tup.rule(inputs, '^ LINK %B^ $(CXX) %f -o %o', outs)
end

A question to your original suggestion (include deps in the return object): 
how can I access lua objects from other Tupfile.lua's? If for example I 
have the following structure:

src
 - lib
 - bin

Can a Tupfile.lua under src/bin access lua objects in a Tupfile.lua under 
src/lib? If so how?

Thanks for the pointers to the merging two libs, those do not do exactly 
what I want since I don't have two libraries but rather a set of objects to 
link in a library with unresolved references that can be satisfied by 
another library. That said, thin archives might work if for every library I 
make a normal archive with a "private" name and then actual library is a 
thin archive of this private lib + all deps. My build foo is a bit weak 
though, I need to try that to verify that it works. Of course getting deps 
from the lua object is preferable since I won't have to create 2 files per 
library but instead pass the transitive closure of library deps to the link 
step of the executable.

On Tuesday, December 9, 2014 3:57:31 PM UTC+1, Rendaw wrote:
>
>  
> On 12/09/2014 06:10 PM, Alkis Evlogimenos ('Αλκης Ευλογημένος) wrote:
>  
> I am building a dsl on top of tup(lua) for my project. What I want to end 
> up with is something like this: 
>
>  bar = cc_lib {
>   name = 'bar',
>   srcs = {'bar.cc'}
>   -- no deps
> } -- creates rules to compile bar.cc and create libbar.a
>
>  foo = cc_lib {
>   name = 'foo',
>   srcs = {'foo1.cc', 'foo2.cc'},
>   deps = {bar}
> } -- creates rules to compile foo1.cc and foo2.cc and create libfoo.a
>
>  cc_bin {
>   name = 'runme',
>   srcs = {'runme.cc'},
>   deps = {foo}
> } -- creates rules to compile runme.cc and link it with libfoo.a and 
> *libbar.a*
>
>  I didn't find a way to query for the dependency of libfoo.a to libbar.a 
> so that I can pull both in the link rule for runme. I believe tup does not 
> have this dependency in the db either because library archives do not have 
> dependencies. What are my options to track dependencies between libs so 
> that I can specify the transitive closure of deps to the link rule for a 
> binary?
>  -- 
> -- 
> tup-users mailing list
> email: [email protected] <javascript:>
> unsubscribe: [email protected] <javascript:>
> 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] <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
>
> I'm not familiar with cc_lib and cc_bin, but perhaps you could modify 
> cc_lib so that the return value includes dependency information?  And then 
> modify cc_bin to use the dependency information.
>
> Alternatively, can't you just include the .a in libfoo.a?  That way, by 
> linking libfoo.a, you'll automatically get all the symbols in libbar.a as 
> well.  This has a few ways to do it: 
> http://stackoverflow.com/questions/3821916/how-to-merge-two-ar-static-libraries-into-one
>
> 

-- 
-- 
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.

Reply via email to