[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v4 03/11] CODING_STYLE(tools/ocaml): add 'make format' and remove tabs


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Edwin Török <edvin.torok@xxxxxxxxxx>
  • Date: Fri, 16 Dec 2022 18:25:12 +0000
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Edwin Török <edvin.torok@xxxxxxxxxx>, David Scott <dave@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Christian Lindig <christian.lindig@xxxxxxxxxx>
  • Delivery-date: Fri, 16 Dec 2022 18:25:58 +0000
  • Ironport-data: A9a23:L181mqLfMTS7DoSlFE+R35UlxSXFcZb7ZxGr2PjKsXjdYENS12ZRz zcbWj2Pb/aDM2D0c91yOY+y8E0C7ZPcn4RiTgZlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHv+kUrWs1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpJrfPdwP9TlK6q4mlB5AVgPaojUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c5pIEMe6 K0ALAwXRRHend+6z5G2TdtF05FLwMnDZOvzu1llxDDdS/0nXYrCU+PB4towMDUY354UW6yEP oxANGQpPE+ojx5nYz/7DLozkPmpgD/jdCdfq3qepLYt4niVxwt0uFToGIuMIIzaHpUK9qqej kec7k3rAxtDDdOwl2Ci3G+Pu/bkxAquDer+E5Xnr6U30TV/3Fc7GBAQEFe2v/S9okq/QM5Eb VwZ/DI0qqo//1DtScPyNzW0qWCJlgQRUN1RF6s98g7l4rXQyxaUAC4DVDEpVTA9nJZoH3pwj AbPxo63Q2w02FGIdZ6D3qm1j2OvaDAREXUpZHIecAcKwNTkkqhm23ojUe1fOKKyi9T0HxT5z DaLsDUyit0vsCIb60mo1QuZ2mzx//AlWiZwv1yKBTz9smuVcab/P+SVBU7nAeGsxWpzZn2Ip zA6lseX94ji5rndxXXWEI3h8FxEjstp0QEwY3Y1R/HNFBz3oRZPmLy8BxkgTHqFyu5eJVfUj Lb74Gu9HqN7MnqwdrNQaImsEcksxqWIPY27CamNNIsXM8gpKFHvEMRSiam4hjCFraTRuftnZ cfznTiEUx729piLPBLpHrxAgNfHNwg1xH/JRICT8vhU+eP2WZJhcp9caAHmRrlgvMu5TPD9r 4432z2il08OD4UTo0D/reYuELz9BSRjVM2r95EJKb7rz8gPMDhJNsI9CIgJI+RN95m5XM+Rl p1hcie0EGbCuEA=
  • Ironport-hdrordr: A9a23:cE5k8amlqTf1MuUs0MvLeLX20dDpDfLL3DAbv31ZSRFFG/Fwwf re+sjztCWatN91YhsdcL+7VJVoLUmsjqKdpLNhRYtKPzOJhILLFvAE0WK4+UyDJ8SWzIc06U 4jSdkcNDSXNykesS+Q2njALz9P+rS62ZHtrfrai09wQR1nS4wI1XYCNi+rVmVqQQFdH5owE9 657spD4x6tY24eYMj+JnRtZYn+juyOvI/iaQQdBxYhrC2HjTbt1aXzFAKR1AofVTQK4bpKyw j4ewKQ3NTGjxjq8HTh61M=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.torok@xxxxxxxxxx>

--
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.lindig@xxxxxxxxxx>
---
 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




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.