Closed chen-factual closed 8 years ago
@chen-factual, I think this might not be working as intended. Here is an example.
in a/Drakefile:
%include dir/Drakefile
In a/dir/Drakefile2:
%include Drakefile3
In a/Drakefile3
a <-
touch $OUTPUT
This workflow works. Notice that a/dir/Drakefile2's include is relative to the a/Drakefile context.
Now if I try to %context this
workflow in a file b/Drakefile:
%context ../a/Drakefile
I get
java.io.FileNotFoundException: b/./Drakefile3 (No such file or directory)
In other words Drakefile2 seems to be run from the b/Drakefile context, not from the a/Drakefile context as desired.
Hey @potash, thanks for filing this.
The problem here is your a/Drakefile: it should %context dir/Drakefile2
instead of %include dir/Drakefile2
. Here's why:
%include
, Drakefile2
looks for Drakefile3
relative to the a
directory, i.e. it thinks Drakefile3
is located in a
instead of a/dir
.
Drakefile2
would work in this case if you did %include dir/Drakefile3
.%context
, Drakefile2
looks for Drakefile3
relative to it's own context, which is a/dir
, hence it finds a/dir/Drakefile3
in the %include Drakefile3
directive.So to summarize, here's what I have:
a/Drakefile
:
%context dir/Drakefile2
a/dir/Drakefile2
:
%include Drakefile3
a/dir/Drakefile3
:
a <-
touch $OUTPUT
b/Drakefile
:
%context ../a/Drakefile
Hope that helps, please let me know if you run into more problems.
@chen-factual thanks for the quick reply. Actually in my example Drakefile3
really does live in a/
not a/dir
. running drake in a/
works fine. It only fails when I run drake from b/
.
I think the problem is that after the %context ../a/Drakefile
BASE is set to a/
but after the %include dir/Drakefile2
BASE gets reset back to b/
. That seems wrong?
Ah I see, the context is applied to a/Drakefile
, but it doesn't propagate further down.
Yeah this should be a bug. I'll file a ticket and tag you on it, thanks for the report.
Nested includes within files included via
%context
use relative paths. #204E.g.
foo.d
nested/bar.d
Now
bar.d
looks in thenested/
folder forbaz.d
instead of the top level folder.