Uncrustify, packaged for the zig build system
- Zig 96.4%
- Python 3.6%
|
Chinmay Dalal
334f306f25
All checks were successful
Continuous Integration / Build, run, test (push) Successful in 7m19s
|
||
|---|---|---|
| .forgejo/workflows | ci: specify zig version for setup-zig | |
| .gitignore | update to v0.83.0 | |
| build.zig | add run step | |
| build.zig.zon | switch to sourcehut ci | |
| gen_token_names.py | wip | |
| LICENSE | add license | |
| README.md | update readme urls after transfer to allyourcodebase | |
Uncrustify
This is Uncrustify, packaged for the Zig build system.
How to use it
Standalone binary
git clone https://codeberg.org/allyourcodebase/uncrustify
cd uncrustify
zig build -Doptimize=ReleaseFast
- the CLI tool can be found in the newly created
./zig-outdirectory - the
runbuild step may be used to directly run Uncrustify. - the
installstep with the--prefix(e.g./usr/,/usr/local/, or~/.local) option can be used to do a complete installation with docs and example configurations.
Formatting step for a C/C++ project:
First, update your build.zig.zon:
zig fetch --save git+https://codeberg.org/allyourcodebase/uncrustify.git
You can then use it in your build.zig like:
constformatc=b.step("formatc","Run uncrustify on C source");constuncrustify=b.dependency("uncrustify",.{.target=target,.optimize=.ReleaseFast,// you want ReleaseFast for uncrustify regardless of the optimize mode of your own project});constuncrustify_exe=uncrustify.artifact("uncrustify");constsources=&[_][]constu8{"src/foo.c","src/bar.c"};constupdate=b.addUpdateSourceFiles();for(sources)|file|{construn=b.addRunArtifact(uncrustify_exe);run.addArgs(&.{"-c","src/uncrustify.cfg","-f"});run.addFileArg(b.path(file));run.addArg("-o");constoutput_name=trystd.mem.replaceOwned(u8,b.allocator,file,"/","-");constoutput=run.addOutputFileArg(output_name);update.addCopyFileToSource(output,file);}formatc.dependOn(&update.step);The above code replaces the source file with the formatted versions, and modulo UpdateSourceFiles not updating the hash after running, will only run on edited files.