See CODING_STYLE: Xen uses spaces, not tabs.

* OCaml code:

Using `ocp-indent` for now to just make minimal modifications in
tabs vs spaces and get the right indentation.
We can introduce `ocamlformat` later.

* C stubs:

just replace tabs with spaces now, using `indent` or `clang-format`
would change code too much for 4.17.

This avoids perpetuating a formatting style that is inconsistent with
the rest of Xen, and that makes preparing and submitting patches more
difficult (OCaml indentation tools usually only support spaces, not tabs).

No functional change.

Signed-off-by: Edwin Török <edvin.to...@citrix.com>

--
Reason for inclusion:
- avoid perpetuating a different coding style (I thought tabs were
  mandated by Xen, and was about to fix up my editor config to match
  when I realized Xen already mandates the use of spaces)
- should make submitting patches for OCaml easier (OCaml indentation
  tools know only about spaces, so I either can't use them, or have to
  manually adjust indentation every time I submit a patch)
- it can be verified that the only change here is the Makefile change
  for the new rule, 'git log -p -1 -w' should be otherwise empty

Changes since v3:
- this didn't make it into 4.17.0, we'll reconsider for 4.17.1, for now
  apply just to master which is open again
- separate introducing the rule from actual reformatting

Cc: Christian Lindig <christian.lin...@citrix.com>
---
 tools/ocaml/Makefile | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/ocaml/Makefile b/tools/ocaml/Makefile
index a7c04b6546..274ba15d75 100644
--- a/tools/ocaml/Makefile
+++ b/tools/ocaml/Makefile
@@ -34,3 +34,8 @@ build-tools-oxenstored:
        $(MAKE) -s -C libs/xb
        $(MAKE) -s -C libs/xc
        $(MAKE) -C xenstored
+
+.PHONY: format
+format:
+       git ls-files '*.ml' '*.mli' | xargs -n1 ocp-indent -i
+       git ls-files '*.c' '*.h' | xargs -n1 sed -ie 's/\t/    /g'
-- 
2.34.1


Reply via email to