clang-format

121 views
Skip to first unread message

Anthony Jones

unread,
Jan 7, 2014, 9:31:59 PM1/7/14
to
I have been doing some testing with clang-format and formatting only the
lines that have been modified.

Version 3.5 is good enough for Mozilla style although the defaults for
style=Mozilla need to be corrected. It doesn't handle weird cases like
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN and _END blocks.

To try it out, all you need to do is add the "Add a clang-format-diff
helper to mach;" patch from bug 952379 to the head of your patch queue.
It will download clang-format and clang-format-diff for you. I have
built the binary on Ubuntu 64 so let me know if it's broken on other 64
bit Linuxes.

The workflow looks like this:
$ hg qrefresh
$ mach clang-format
<shows changes>

This reformats only the lines that are different from tip^. If you're
happy with the changes then you do:
$ hg qrefresh
$ hg bzexport ...

Otherwise you do:
$ hg revert --all

I've also added a file called .clang-format-ignore which lists
directories to exclude from the "mach clang-format" command. This
currently lsits js/ and mfbt/.

Anthony

Anthony Jones

unread,
Jan 8, 2014, 3:55:19 PM1/8/14
to
clang-format-3.5 is now available for Windows using the updated patch in
bug 952379.

Anthony

Anthony Jones

unread,
Jan 22, 2014, 8:52:49 PM1/22/14
to
Excuse the continued conversation with myself.....

Bug 952379 has landed on m-c so you can now use the work flow below:

$ hg qrefresh
$ mach clang-format

This reformats only the lines that are different from tip^. It doesn't
show anything on the console. Review the changes with your favourite
diff tool. You can see a beautiful screenshot here:

http://people.mozilla.org/~ajones/clang-format/meld-screen-shot.png

Information on how to set up meld is available here:

http://mercurial.selenic.com/wiki/ExtdiffExtension
http://coffeepluscode.wordpress.com/2012/10/11/using-meld-with-mercurial/

Once you're happy with the changes then you do:
$ hg qrefresh
$ hg bzexport ...

Otherwise you do:
$ hg revert --all

Please put any issues you find into 961541.

Anthony

Bobby Holley

unread,
Jan 22, 2014, 9:18:58 PM1/22/14
to Anthony Jones, dev-pl...@lists.mozilla.org
On OSX10.9, I get:

Unsupported platform Darwin/x86_64. Supported platforms are Windows/* and
Linux/x86_64

Is there a reason for this?
> _______________________________________________
> dev-platform mailing list
> dev-pl...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform
>

Gregory Szorc

unread,
Jan 22, 2014, 9:26:48 PM1/22/14
to Bobby Holley, Anthony Jones, dev-pl...@lists.mozilla.org
As a temporary workaround until upstream gets patched, we're downloading and running hosted binaries from ajone's people account (with consent of course). He hasn't built the binary for OS X yet.

On Jan 22, 2014, at 18:19, Bobby Holley <bobby...@gmail.com> wrote:

> On OSX10.9, I get:
>
> Unsupported platform Darwin/x86_64. Supported platforms are Windows/* and
> Linux/x86_64
>
> Is there a reason for this?
>
>
> On Wed, Jan 22, 2014 at 5:52 PM, Anthony Jones <ajo...@mozilla.com> wrote:
>

Anthony Jones

unread,
Jan 22, 2014, 11:48:54 PM1/22/14
to
On 23/01/14 15:26, Gregory Szorc wrote:
> As a temporary workaround until upstream gets patched, we're
> downloading and running hosted binaries from ajone's people account
> (with consent of course). He hasn't built the binary for OS X yet.

I've created bug 962954 to track this issue.

Anthony
Reply all
Reply to author
Forward
0 new messages