Prototype buildsystem "Drake"
Jacob Carlborg
doob at me.com
Thu Jul 14 02:43:32 PDT 2011
On 2011-07-13 23:41, Nick Sabalausky wrote:
> "Jacob Carlborg"<doob at me.com> wrote in message
>> Most of the functions called in the build script should be instance
>> methods, this will allow to use threading, possible invoke multiple
>> targets/tasks simultaneously and running several build scripts
>> simultaneously.
>>
>
> My understanding is that with thread-local being the default, they *don't*
> need to be instance methods to be thread-safe.
>
> Also, dependency-checking and task-invocation (once they're implemented)
> won't occur at all until *after* the drakefile() function completes. The
> target!...(...) function merely defines the targets, adding them to an
> internal list - nothing more. So I'm not sure that's not really a
> thread-appropriate matter.
>
> Not really sure what you mean about running several build scripts
> simultaneously. The buildscript gets compiled into an exe, so the
> buildscripts all run in separate processes anyway.
Now I remember how I was thinking, I was thinking in Ruby :)
This will most likely not work in D but let me explain anyway. Say that
you have a build script with two targets, two executables:
target("foo.d", (Target t) {
t.buildflags ~= "-L-ldwt";
});
target("main.d" (Target t) {
t.buildflags ~= "-release"
});
In Ruby this would work the same:
target "foo.d" do |t|
t.buildflags << "-L-ldwt"
end
target "main.d" do |t|
t.buildflags << "-release"
end
In Ruby you could improve this syntax a little, like this:
target "foo.d" do
buildflags << "-L-ldwt"
end
target "main.d" do
buildflags << "-release"
end
In Ruby you can take advantage of the instance_eval method, allowing to
evaluate a block/delegate in the context of an instance. In the above
example "buildflags" would be a an instance method in the class that the
block is evaluated in. Then you don't need to pass the a Target instance
to the block.
In D, with this syntax:
target("foo.d", {
buildflags ~= "-L-ldwt";
});
target("main.d" {
buildflags ~= "-release"
});
"buildflags" would probably be a global function or an instance method.
If this should work "buildflags" needs to keep some data structure with
buildflags for each target. This seems quite complicated, making sure
the correct build flags are used with the correct target.
More information about the Digitalmars-d
mailing list