diff --git a/Makefile b/Makefile index fd67fb7b9..0979a2603 100644 --- a/Makefile +++ b/Makefile @@ -38,11 +38,7 @@ clean: .PHONY: reformat reformat: - mill -i __.reformat - -.PHONY: checkformat -checkformat: - mill -i __.checkFormat + nix develop ".#t1.elaborator" -c bash -c 'eval "$$formatHook"' .PHONY: list-configs list-configs: diff --git a/nix/t1/mill-modules.nix b/nix/t1/mill-modules.nix index 85e81f885..26a720d83 100644 --- a/nix/t1/mill-modules.nix +++ b/nix/t1/mill-modules.nix @@ -80,6 +80,18 @@ let CIRCT_INSTALL_PATH = circt-full; JEXTRACT_INSTALL_PATH = jextract-21; JAVA_TOOL_OPTIONS = "--enable-preview"; + formatHook = '' + targets=( $(mill -i resolve _.reformat) ) + localTargets=() + for t in ''${targets[@]}; do + if ! mill -i show "''${t//reformat/sources}" | grep -q dependencies; then + localTargets+=($t) + fi + done + for t in ''${localTargets[@]}; do + mill -i "$t" + done + ''; }; outputs = [ "out" "omreader" "elaborator" "t1package" ];