zigler
zigler copied to clipboard
Resolve paths from project root
First off, congrats on the 0.10 release! Huge update and some extremely cool and novel stuff here.
I ran against a somewhat sharp edge trying to work with an included lib. It seems that, currently, paths to e.g. included libs or c_src are all resolved relative to the current file, which means co-locating in lib/my_project/.... In my case, that means needing to put a git submodule in lib, which means all contents are included in packages by default, etc.
What do you think about resolving paths relative to the project root by default, and relative to the current module if the path uses ./?
# resolves to PROJECT_ROOT/includes
use Zig, include_dir: "includes"
# resolves to __DIR__/includes
use Zig, include_dir: "./includes"
I think I like this, let's call it provisional since I don't know if the zig build will play nice with it (sometimes it wants things in the project root) but I think it will be ok.
I want to chip with a pattern I recently encountered: using hex dependency management to pull a C library off the GitHub:
{:libmagic, git: "https://github.com/file/file", tag: "FILE#{filelib_tag()}", app: false, compile: false}
and being able to add deps/file in the include path would come in handy.