On Mon, Oct 3, 2016 at 6:03 AM, stewart mackenzie <[email protected]>
wrote:

>
> Now I need to know why I cannot just do this:   using Tuple = import
> "${tuple}/src/contract.capnp";
> which will evaluate to using Tuple = import "/nix/store/
> xsibhsqk8n9m7cr0dvy050lq054p0pnd-tuple/src/contract.capnp";
>
> Do I have to use the -I argument to pass into the capnp command?
>
>
Yes. You need to add a "-l/" flag to tell the schema compiler to add "/" to
the list of directories it will search when given an absolute path. By
default, only /usr/include and /usr/local/include are searched.


Is there a good reason for not allowing absolute paths when importing in
> the contract?
>

The filesystem root "/" is not searched by default because usually capnp
import statements are written in a style that does not require the
filesystem root to be searched. For example, import statements like the
following are common:

    using Cxx = import "/capnp/c++.capnp";
    using Util = import "/sandstorm/util.capnp";

The idea is that, in the context of these import statements, "/" refers to
the *project* root, rather than the filesystem root. Then the project can
exist anywhere on the filesystem and still be compilable without requiring
string interpolations like your `import "${tuple}/src/contract.capnp";`.


- David

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/capnproto.

Reply via email to