2
0
Fork
You've already forked uncrustify
0
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
update readme urls after transfer to allyourcodebase
2026年06月06日 16:31:30 -04:00
.forgejo/workflows ci: specify zig version for setup-zig 2026年06月06日 16:29:48 -04:00
.gitignore update to v0.83.0 2026年05月17日 02:44:05 -04:00
build.zig add run step 2026年05月17日 14:08:13 -04:00
build.zig.zon switch to sourcehut ci 2026年05月17日 03:52:08 -04:00
gen_token_names.py wip 2026年03月29日 20:05:38 -04:00
LICENSE add license 2026年03月29日 20:56:42 -04:00
README.md update readme urls after transfer to allyourcodebase 2026年06月06日 16:31:30 -04:00

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-out directory
  • the run build step may be used to directly run Uncrustify.
  • the install step 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.