Re: Build action
Bram Moolenaar <[email protected]>
| Newsgroups | gmane.comp.tools.aap.devel |
|---|---|
| Message-ID | <[email protected]> |
Lars Ivar Igesund wrote:
> The default BUILD_ACTION creates similar problems like
> the ones created by COMPILE_ACTION. It is not necessarily
> the object files themselves that cause trouble since they
> might be compatible with others (gcc is used for linking on
> linux), but the D compiler/linker needs to link in the D runtime
> which means that I need to change the BUILD_ACTION in
> some way.
>
> Should it be solved by :route and an :action dbuild with an
> accompanying D_BUILD_ACTION, or are there other,
> better solutions? Maybe a check in :action build
> for which compiler was used?
Besides the solution that Adriaan mentioned, you can also directly
specify the linker to be used:
:program myprog {var_LD = dlink} : foo.d bar.d
The idea behind is that you tell Aap that "myprog" is to be linked with
your specific linker "dlink".
Obviously this has the disadvantage that it's not automatic. That would
require defining a BUILD_ACTION. If you only compile "D" sources then
it's easy: set BUILD_ACTION to "d_build" and define your d_build action.
If you have a large project with a mix of languages the BUILD_ACTION
would need to check the attributes of the object files to find out how
they are to be linked. The default.aap recipe currently does this for
C++ (using the "cppsource" attribute). This is a bit complicated
though...
Hmm, perhaps we should add a "buildaction" attribute to the object
files. Summary:
In the "d" tool recipe:
:action compile object d
:attr {buildaction = d_build} $target
:sys dcc -o $target $source
:action d_build default
:sys dlink -o $target $source
Now we need to check for the {buildaction} attribute and invoke the
"d_build" action in the default recipe:
:action build default
done = 0
@for item in var2dictlist(source):
@if item.get("buildaction"):
:do `item["buildaction"]` {target = $target} $source
done = 1
@break
@if not done:
... the normal C linker ...
(The real code would have to check for conflicting "buildaction"
attributes.)
The idea is that you generat object files with a remark "if you are
going to build a program with this object file, then you need to use
this build action".
This solution would also take care of using $CXX for linking objects
from C++ sources.
How does this sound? Anything that would not work this way?
--
Computers are not intelligent. They only think they are.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
\\\ Project leader for A-A-P -- http://www.A-A-P.org ///
\\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf