ziglang / zig-mode

Zig mode for Emacs
GNU General Public License v3.0
157 stars 54 forks source link

Included the option to call `zig build run` from the project root. #74

Open alexjgriffith opened 1 year ago

alexjgriffith commented 1 year ago

For interactive projects its nice to do a quick build run from any file your working on.

The new zig-project-build-run interactive function identifies the root of the project and calls the appropriate executable with the arguments build run.

By default it is bound to C-c C-p.

This PR adds two additional customs

zig-project-build-file is the name of the file you wish to use as your build file. It defaults to build.zig

zig-project-root-search-up is the number of directories you wish to search up for the zig-project-build-file. This is used to ensure the function terminates.

If the project root cannot be found, zig-project-build-run indicates so in Messages.

joachimschmidt557 commented 1 year ago

zig build automatically searches for a build.zig file in the current directory or in all parent directories.

joachim@pier ~ % ~/src/zig/build/stage3/bin/zig build       
info: Initialize a 'build.zig' template file with `zig init-lib` or `zig init-exe`,
or see `zig --help` for more options.
error: No 'build.zig' file found, in the current directory or any parent directories.
joachim@pier ~ % 

In my opinion, we shouldn't support other build file names than build.zig as this is also the default enforced by the zig compiler.

jiacai2050 commented 1 year ago

I agree with @joachimschmidt557, this addition seems unnecessary.