Hierarchical builds (Was: Re: Linking a program with a directory??)

Bram Moolenaar <[email protected]> Sat, 24 Jul 2004 13:59:16 +0200
Newsgroups gmane.comp.tools.aap.user
Message-ID <[email protected]>
Magnus Therning wrote:

> I have now modified my aap files like this:
> 
>   main.aap:
>  
>    :child foo/main.aap
>    :child bar/main.aap
>  
>   foo/main.aap:
>  
>    :dll foo : foo.c
>  
>   bar/main.aap:
>  
>    all: bar
> 
>    INCLUDE = -I../foo
> 
>    :program { add_LIBS = ../foo/$(DLLPRE)foo$(DLLSUF) } bar
>        : main.c
> 
> This doesn't work, because aap doesn't connect
> '../foo/$(DLLPRE)foo$(DLLSUF)' with ':dll foo : foo.c' dependency-wise.
> Is this something that is being worked on?

Yes, it should be possible to mention the library as one of the sources:

	:program bar : main.c ../foo/$(DLLPRE)foo$DLLSUF

Perhaps it already works.  Let's try...   No, it doesn't work.

If you change default.aap then it works for my compiler.  But I'm not
sure if this is acceptable in general.  Can a linker normally directly
link with a shared library?  If not, then we need to add a mechanism to
turn the name of the dll into the correct linker argument.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
diff -u -r1.62 default.aap
--- default.aap 7 Jul 2004 08:58:05 -0000       1.62
+++ default.aap 24 Jul 2004 11:55:09 -0000
@@ -66,6 +66,9 @@
        DLLOBJSUF = .o
        CXXFLAGS = $CXXFLAGS -LANG:std
 
+# used in add_build_one()
+LTOBJSUF = .lo
+
 
 # Check if $CC ($CXX) is GCC, remember this in $HASGCC ($HASGCCXX)
 # Use a dependency to avoid checking it more than once.
@@ -409,7 +412,7 @@
             :sys $ld $LDFLAGS `cflags_normal()` -o $target $source $?LIBS
         """,
         outtypes = ["default"],
-        intypes = ["object", "libobject", "ltobject", "default"])
+        intypes = ["object", "libobject", "ltobject", "dll", "default"])
     def default_build_defer_name(source = ""):
         if _no.get("BUILD_ACTION"):
             return var2string(_no.BUILD_ACTION)
@@ -437,7 +440,7 @@
             :sys $ld $LDFLAGS `cflags_normal()` -o $target $source $?LIBS
         """,
         outtypes = ["default"],
-        intypes = ["object", "libobject", "ltobject", "default"])
+        intypes = ["object", "libobject", "ltobject", "dll", "default"])
     def default_cxx_build_defer_name(source = ""):
         if _no.get("CXX_BUILD_ACTION"):
             return var2string(_no.CXX_BUILD_ACTION)

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

> I'd even like to see that the following would create such a dependency
> connection:
> 
>    :program { add_LDFLAGS = -L../foo } { add_LIBS = -lfoo } bar
>        : main.c
> 
> In my perception this would bring aap to place where recursive aap files
> can't be considered harmful in the same way makefiles are[1].

This would require formalizing the method how libraries are specified.
I think the example I gave above is already good.  Just have to make it
work...

Another way is to explicitly add the dependency:

	bar$EXESUF : ../foo/$(DLLPRE)foo$DLLSUF

-- 
Proof techniques #2: Proof by Oddity.
	SAMPLE: To prove that horses have an infinite number of legs.
(1) Horses have an even number of legs.
(2) They have two legs in back and fore legs in front.
(3) This makes a total of six legs, which certainly is an odd number of
    legs for a horse.
(4) But the only number that is both odd and even is infinity.
(5) Therefore, horses must have an infinite number of legs.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click