Skip to content

Use only .ocamlformat* to enable or disable ocamlformat #1135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Please make a pull request to change this file.
# Each directory that enables ocamlformat sets its own options, so here we just
# disable it by default.
disable=true
55 changes: 3 additions & 52 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,66 +77,17 @@ promote:

.PHONY: fmt
fmt:
ocamlformat -i \
$$(find middle_end/flambda2 \
\( -name "*.ml" -or -name "*.mli" \) \
-and \! \( -name "flambda_parser.*" -or -name "flambda_lex.*" \))
ocamlformat -i \
$$(find backend/cfg \
\( -name "*.ml" -or -name "*.mli" \))
ocamlformat -i middle_end/mangling.ml
ocamlformat -i middle_end/mangling.mli
ocamlformat -i \
$$(find backend/asm_targets \
\( -name "*.ml" -or -name "*.mli" \))
ocamlformat -i \
$$(find backend/debug \
\( -name "*.ml" -or -name "*.mli" \))
ocamlformat -i backend/cmm_helpers.ml{,i}
ocamlformat -i backend/cmm_builtins.ml{,i}
ocamlformat -i backend/checkmach.ml{,i}
ocamlformat -i tools/merge_archives.ml
ocamlformat -i \
$$(find backend/debug/dwarf \
\( -name "*.ml" -or -name "*.mli" \))
ocamlformat -i \
$$(find utils \
\( -name "*.ml" -or -name "*.mli" \))
ocamlformat -i \
$$(find ocaml/utils \
\( -name "*.ml" -or -name "*.mli" \))
ocamlformat -i $$(find . \( -name "*.ml" -or -name "*.mli" \))

.PHONY: check-fmt
check-fmt:
@if [ "$$(git status --porcelain middle_end/flambda2)" != "" ] || \
[ "$$(git status --porcelain backend/cfg)" != "" ] || \
[ "$$(git status --porcelain middle_end/mangling.ml)" != "" ] || \
[ "$$(git status --porcelain middle_end/mangling.mli)" != "" ] || \
[ "$$(git status --porcelain backend/asm_targets)" != "" ] || \
[ "$$(git status --porcelain backend/debug)" != "" ] || \
[ "$$(git status --porcelain backend/cmm_helpers.ml{,i})" != "" ] || \
[ "$$(git status --porcelain backend/cmm_builtins.ml{,i})" != "" ] || \
[ "$$(git status --porcelain backend/checkmach.ml{,i})" != "" ] || \
[ "$$(git status --porcelain tools/merge_archives.ml)" != "" ] || \
[ "$$(git status --porcelain ocaml/utils)" != "" ] || \
[ "$$(git status --porcelain utils)" != "" ]; then \
@if [ "$$(git status --porcelain)" != "" ]; then \
echo; \
echo "Tree must be clean before running 'make check-fmt'"; \
exit 1; \
fi
$(MAKE) fmt
@if [ "$$(git diff middle_end/flambda2)" != "" ] || \
[ "$$(git diff backend/cfg)" != "" ] || \
[ "$$(git diff middle_end/mangling.ml)" != "" ] || \
[ "$$(git diff middle_end/mangling.mli)" != "" ] || \
[ "$$(git diff backend/asm_targets)" != "" ] || \
[ "$$(git diff backend/debug)" != "" ] || \
[ "$$(git diff backend/cmm_helpers.ml{,i})" != "" ] || \
[ "$$(git diff backend/cmm_builtins.ml{,i})" != "" ] || \
[ "$$(git diff backend/checkmach.ml{,i})" != "" ] || \
[ "$$(git diff tools/merge_archives.ml)" != "" ] || \
[ "$$(git diff ocaml/utils)" != "" ] || \
[ "$$(git diff utils)" != "" ]; then \
@if [ "$$(git diff)" != "" ]; then \
echo; \
echo "The following code was not formatted correctly:"; \
echo "(the + side of the diff is how it should be formatted)"; \
Expand Down
2 changes: 0 additions & 2 deletions backend/.ocamlformat-enable
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ cmm_helpers.ml
cmm_helpers.mli
cmm_builtins.ml
cmm_builtins.mli
internal_assembler/*.ml
internal_assembler/*.mli
checkmach.ml
checkmach.mli
cfg/**/*.ml
Expand Down
2 changes: 0 additions & 2 deletions middle_end/.ocamlformat-enable
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
mangling.ml
mangling.mli
flambda2/**/*.ml
flambda2/**/*.mli
1 change: 1 addition & 0 deletions middle_end/flambda2/.ocamlformat
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Please make a pull request to change this file.
# Keep this file in sync with other .ocamlformat files in this repo.
disable=false
assignment-operator=begin-line
cases-exp-indent=2
doc-comments=before
Expand Down
2 changes: 2 additions & 0 deletions middle_end/flambda2/parser/.ocamlformat-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
flambda_lex.*
flambda_parser.*
1 change: 0 additions & 1 deletion ocaml/lambda/.ocamlformat-enable

This file was deleted.

1 change: 1 addition & 0 deletions ocaml/manual/src/html_processing/.ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
disable=true
1 change: 1 addition & 0 deletions tools/.ocamlformat-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flambda_backend_objinfo.ml