Merge lp:~charlesk/cmake-extras/formatcode into lp:cmake-extras

Proposed by Charles Kerr
Status: Merged
Approved by: Michi Henning
Approved revision: 53
Merged at revision: 41
Proposed branch: lp:~charlesk/cmake-extras/formatcode
Merge into: lp:cmake-extras
Diff against target: 574 lines (+521/-7)
8 files modified
CMakeLists.txt (+2/-7)
src/FormatCode.cmake (+238/-0)
src/formatcode/formatcode.in (+61/-0)
src/formatcode/formatcode_common.cmake (+79/-0)
src/formatcode/formatcode_format.cmake.in (+31/-0)
src/formatcode/formatcode_test.cmake.in (+31/-0)
src/formatcode/unity-api.astyle (+30/-0)
src/formatcode/unity-api.clang-format (+49/-0)
To merge this branch: bzr merge lp:~charlesk/cmake-extras/formatcode
Reviewer Review Type Date Requested Status
Michi Henning (community) Approve
Pete Woods Approve
Review via email: mp+290879@code.launchpad.net

Commit message

Add optional `formatcode' test and rule for comparing code to, and reformatting code to, a style guide standard.

Description of the change

Add optional `formatcode' test and rule. For the specified sources, the test checks to see if they match some style guide and 'make formatcode' reformats them.

Standalone projects will specify their own style options, but projects following a 'house style' -- such as the unity-api format -- can use common files installed in cmake/Modules/formatcode/.

This MP includes common files for the unity-api team, taken from michi's astyle and clang-foramt files

To post a comment you must log in.
Revision history for this message
Pete Woods (pete-woods) wrote :

Sorry for the long delay. I pushed a branch (lp:~pete-woods/cmake-extras/formatcode-changes) that includes the changes I'd recommend, which are:
1) Include the parse arguments module in the main Format cmake file.
2) Use sed, rather than dos2unix, as this is installed by default on Ubuntu.

FYI, I used the following small project for testing with:
http://people.canonical.com/~pete/formatcode-test.tar.gz

review: Needs Fixing
Revision history for this message
Pete Woods (pete-woods) wrote :

Thanks for the fixes! :)

review: Approve
Revision history for this message
Michi Henning (michihenning) wrote :

Superb, thank you!

Minor niggles:

+ if(atyle AND astyle_config)

should be

+ if(astyle AND astyle_config)

+# --pad-oper

We can enable this now, the padding for rvalue references was fixed in astyle 2.05.

One thing I'd like to be able to do is to sit in vi and occasionally run the current file through the formatter by typing

1G!Gformatcode

Any chance we could add a way to do this (assuming that I add the relevant dir to my path, of course)?

review: Needs Fixing
Revision history for this message
Michi Henning (michihenning) wrote :

Also, we probably should add

SortIncludes: false

to the clang config. Otherwise, it sorts all #includes into alphabetical order, which conflicts with our style guide. (This must have been added with 3.6 or later; it didn't use to do this.)

Revision history for this message
Michi Henning (michihenning) wrote :

And I just stumbled across this one in the astyle doc:

--lineend=linux

I haven't tried whether this works as you'd think it does. But, if it does, we could ditch the line-ending re-writing with sed altogether.

lp:~charlesk/cmake-extras/formatcode updated
45. By Charles Kerr

tyop fix: s/atyle/astyle/

46. By Charles Kerr

in unity-api's astyle config, enable --pad-oper since it's been fixed in astyle 2.05

47. By Charles Kerr

in unity-api's clang-format, add 'SortIncludes: false'

Revision history for this message
Charles Kerr (charlesk) wrote :

> + if(astyle AND astyle_config)

Good catch! Fixed r45

> +# --pad-oper

Enabled r46

> SortIncludes: false

Added r47

> --lineend=linux

Looks like this should do what we want. I'll test this out tomorrow and, depending how it goes, either update the patch or add a followup comment here.

> 1G!Gformatcode

I would use this too. I don't have that in this MR but it might make a nice Friday project.

lp:~charlesk/cmake-extras/formatcode updated
48. By Charles Kerr

use astyle's linux linefeed option instead of reformatting with sed

49. By Charles Kerr

initial formatcode filter file. doesn't do anything yet.

50. By Charles Kerr

try adapting the formatcode filter from unity-scopes-api

51. By Charles Kerr

fix formatting errors

52. By Charles Kerr

when installing our modules, preserve the source files' permissions. needed for the formatcode.in script.

53. By Charles Kerr

updat the 'make formatcode' rule and formatcode test to use the new filter

Revision history for this message
Charles Kerr (charlesk) wrote :

I had a couple of hours' layover today with no internet access, so I decided to go ahead and do this...

michi, as of r53 there's a ~/build/formatcode filter script based on the unity-scopes-api/trunk/tools/formatcode.in.

Revision history for this message
Michi Henning (michihenning) wrote :

Bloody awesome, thank you so much!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2015-06-19 09:04:54 +0000
3+++ CMakeLists.txt 2016-04-23 15:31:47 +0000
4@@ -1,13 +1,8 @@
5 project(cmake-extras)
6 cmake_minimum_required(VERSION 2.8.9)
7
8-file(
9- GLOB_RECURSE SRC_FILES
10- "src/*.cmake"
11- "src/*.in"
12-)
13-
14 install(
15- FILES ${SRC_FILES}
16+ DIRECTORY "src/"
17 DESTINATION "${CMAKE_ROOT}/Modules/"
18+ USE_SOURCE_PERMISSIONS
19 )
20
21=== added file 'src/FormatCode.cmake'
22--- src/FormatCode.cmake 1970-01-01 00:00:00 +0000
23+++ src/FormatCode.cmake 2016-04-23 15:31:47 +0000
24@@ -0,0 +1,238 @@
25+# .rst:
26+# FormatCode
27+# ----------
28+#
29+# Helpers to reformat source or test that it follows a style guide.
30+# Supports astyle and clang-format.
31+#
32+# The ``ADD_FORMATCODE_TARGET'' function adds a rule
33+# to reformat the specified sources into the desired style::
34+#
35+# add_formatcode_target(
36+# sources
37+# [STYLE_NAME <name>]
38+# [ASTYLE_CONFIG <path>]
39+# [CFORMAT_CONFIG <path>]
40+# )
41+#
42+# If the ``STYLE_NAME`` argument is used, formatcode first looks for shared
43+# style files installed in the FormatCode module's formatcode/ directory.
44+#
45+# Otherwise it looks in ${CMAKE_SOURCE_DIR} and ${CMAKE_SOURCE_DIR}/data/
46+# for the ``ASTYLE_CONFIG`` and ``CFORMAT_CONFIG`` files.
47+#
48+# The ``ADD_FORMATCODE_TEST'' function takes the same arguments as
49+# ``ADD_FORMATCODE_TARGET'' and adds a test to see if the specified
50+# sources follow the desired style::
51+#
52+# add_formatcode_test(
53+# sources
54+# [STYLE_NAME <name>]
55+# [ASTYLE_CONFIG <path>]
56+# [CFORMAT_CONFIG <path>]
57+# )
58+#
59+# Example use:
60+#
61+# In CMakeLists.txt:
62+#
63+# file(GLOB_RECURSE MY_SOURCES src/*.cpp src/*.cxx src/*.cc src/*.h)
64+# include(FormatCode)
65+# add_formatcode_target(${MY_SOURCES} STYLE_NAME unity-api)
66+#
67+# In tests/CMakeLists.txt:
68+#
69+# add_formatcode_test(${MY_SOURCES} STYLE_NAME unity-api)
70+#
71+
72+#=============================================================================
73+# Copyright 2016 Canonical Ltd
74+#
75+# This file may be licensed under the terms of the
76+# GNU Lesser General Public License Version 3 (the ``LGPL''),
77+# or (at your option) any later version.
78+#
79+# Software distributed under the License is distributed
80+# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
81+# express or implied. See the LGPL for the specific language
82+# governing rights and limitations.
83+#
84+# You should have received a copy of the LGPL along with this
85+# program. If not, go to http://www.gnu.org/licenses/lgpl.html
86+# or write to the Free Software Foundation, Inc.,
87+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
88+#=============================================================================
89+
90+include(CMakeParseArguments)
91+
92+set(FC_CMAKE_MODULE_DIR ${CMAKE_CURRENT_LIST_DIR}/formatcode)
93+
94+function(_fc_find_style_files FC_STYLE_NAME FC_ASTYLE_CONFIG FC_CFORMAT_CONFIG)
95+
96+ message(STATUS "checking for astyle or clang-format")
97+
98+ set(style_search_path
99+ ${CMAKE_SOURCE_DIR}
100+ ${CMAKE_SOURCE_DIR}/data
101+ ${FC_CMAKE_MODULE_DIR}
102+ )
103+
104+ if(FC_STYLE_NAME)
105+ set(filename ${FC_STYLE_NAME}.astyle)
106+ find_file(astyle_tmp ${filename} PATHS ${style_search_path})
107+ set(filename ${FC_STYLE_NAME}.clang-format)
108+ find_file(cformat_tmp ${filename} PATHS ${style_search_path})
109+ endif()
110+
111+ if(FC_ASTYLE_CONFIG AND NOT astyle_tmp)
112+ if(EXISTS ${FC_ASTYLE_CONFIG})
113+ set(astyle_tmp ${FC_ASTYLE_CONFIG})
114+ else()
115+ find_file(astyle_tmp
116+ NAMES ${FC_ASTYLE_CONFIG} astyle-config
117+ PATHS ${style_search_path}
118+ )
119+ endif()
120+ endif()
121+
122+ if(FC_CFORMAT_CONFIG AND NOT cformat_tmp)
123+ if(EXISTS ${FC_CFORMAT_CONFIG})
124+ set(cformat_tmp ${FC_CFORMAT_CONFIG})
125+ else()
126+ find_file(cformat_tmp
127+ NAMES ${FC_CFORMAT_CONFIG} cformat-config
128+ PATHS ${style_search_path}
129+ )
130+ endif()
131+ endif()
132+
133+ # set retvals
134+
135+ if(astyle_tmp)
136+ message(STATUS " found ${astyle_tmp}")
137+ set(FC_ASTYLE_CONFIG ${astyle_tmp} PARENT_SCOPE)
138+ else()
139+ unset(FC_ASTYLE_CONFIG PARENT_SCOPE)
140+ endif()
141+
142+ if(cformat_tmp)
143+ message(STATUS " found ${cformat_tmp}")
144+ set(FC_CFORMAT_CONFIG ${cformat_tmp} PARENT_SCOPE)
145+ else()
146+ unset(FC_CFORMAT_CONFIG PARENT_SCOPE)
147+ endif()
148+
149+endfunction()
150+
151+function(_fc_find_apps FC_ASTYLE_CONFIG FC_CFORMAT_CONFIG)
152+
153+ if(EXISTS ${FC_ASTYLE_CONFIG})
154+ # find astyle...
155+ find_program(ASTYLE NAMES astyle)
156+ if(NOT ASTYLE)
157+ message(WARNING "found astyle config file, but not astyle")
158+ endif()
159+ endif()
160+
161+ if(EXISTS ${FC_CFORMAT_CONFIG})
162+ # find clang-format executable...
163+ find_program(CFORMAT NAMES clang-format clang-format-3.8 clang-format-3.7 clang-format-3.6 clang-format-3.5)
164+ if(NOT CFORMAT)
165+ message(WARNING "found clang-format style file, but not clang-format")
166+ endif()
167+ endif()
168+
169+ # set retvals
170+
171+ if(ASTYLE)
172+ message(STATUS " found ${ASTYLE}")
173+ set(FC_ASTYLE ${ASTYLE} PARENT_SCOPE)
174+ else()
175+ unset(FC_ASTYLE PARENT_SCOPE)
176+ endif()
177+
178+ if(CFORMAT)
179+ message(STATUS " found ${CFORMAT}")
180+ set(FC_CFORMAT ${CFORMAT} PARENT_SCOPE)
181+ else()
182+ unset(FC_CFORMAT PARENT_SCOPE)
183+ endif()
184+
185+endfunction()
186+
187+# cmake doesn't have a mktemp func, so roll a simple one
188+function(_fc_mktemp in out)
189+ set(_counter 1)
190+ while(EXISTS ${in}.${_counter})
191+ math(EXPR _counter "${_counter} + 1")
192+ endwhile()
193+ set(${out} "${in}.${_counter}" PARENT_SCOPE)
194+endfunction()
195+
196+# clang-format has a goofy wart, it doesn't let you pass in an arbitrary
197+# style file. But, you CAN pass style options on the command line with
198+# --style="{foo: bar, mum: baz}" ... so let's read the style file in
199+# and bang it into a --style string
200+function(_fc_get_cformat_style cformat_style_string filename)
201+ file(READ ${filename} contents)
202+ STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}")
203+ STRING(REGEX REPLACE "\n" ";" contents "${contents}")
204+ set(style)
205+ foreach(LINE IN LISTS contents)
206+ string(STRIP "${LINE}" LINE)
207+ if (LINE MATCHES ".*:.*")
208+ set(style "${style}${LINE}, ")
209+ endif()
210+ endforeach(LINE)
211+ STRING(LENGTH "${style}" len)
212+ if(${len} GREATER 2) # trim the trailing ", "
213+ MATH(EXPR len "${len}-2")
214+ STRING(SUBSTRING "${style}" 0 ${len} style)
215+ endif()
216+ # set retval
217+ set(${cformat_style_string} "{${style}}" PARENT_SCOPE)
218+endfunction()
219+
220+
221+# add_custom_target() and add_test() can take a cmake file argument but not a
222+# function name argument, so we generate cmake files to call
223+# formatcode_format_files() or formatcode_test_files() with the right FC_* args
224+function(_fc_configure_new_cmake_file filename template_name)
225+
226+ # parse the args
227+ set(options)
228+ set(oneValueArgs STYLE_NAME ASTYLE_CONFIG CFORMAT_CONFIG)
229+ set(multiValueArgs)
230+ cmake_parse_arguments(FC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
231+ set(FC_SOURCES "${FC_UNPARSED_ARGUMENTS}")
232+
233+ # use the args to find the right formatters and config files
234+ _fc_find_style_files("${FC_STYLE_NAME}" "${FC_ASTYLE_CONFIG}" "${FC_CFORMAT_CONFIG}")
235+ _fc_find_apps("${FC_ASTYLE_CONFIG}" "${FC_CFORMAT_CONFIG}")
236+
237+ # build the filter
238+ set(FC_COMMAND ${CMAKE_BINARY_DIR}/formatcode)
239+ _fc_get_cformat_style(FC_CFORMAT_STYLE "${FC_CFORMAT_CONFIG}")
240+ configure_file(${FC_CMAKE_MODULE_DIR}/formatcode.in ${FC_COMMAND} @ONLY)
241+
242+ # build the config file
243+ _fc_mktemp(${CMAKE_BINARY_DIR}/${template_name} TMPFILE)
244+ set(TMPFILE ${TMPFILE}.cmake)
245+ configure_file(${FC_CMAKE_MODULE_DIR}/${template_name}.cmake.in ${TMPFILE} @ONLY)
246+
247+ # set the retval, the filename of the generated file
248+ set(${filename} ${TMPFILE} PARENT_SCOPE)
249+endfunction()
250+
251+# add a 'make formatcode' target to reformat the source files
252+function(add_formatcode_target)
253+ _fc_configure_new_cmake_file(cmake_file "formatcode_format" ${ARGN})
254+ add_custom_target(formatcode COMMAND ${CMAKE_COMMAND} -P ${cmake_file} DEPENDS ${FC_SOURCES})
255+endfunction()
256+
257+# add a 'formatcode' test to confirm the source files follow the style guide
258+function(add_formatcode_test)
259+ _fc_configure_new_cmake_file(cmake_file "formatcode_test" ${ARGN})
260+ add_test(NAME formatcode COMMAND ${CMAKE_COMMAND} -P ${cmake_file})
261+endfunction()
262+
263
264=== added directory 'src/formatcode'
265=== added file 'src/formatcode/formatcode.in'
266--- src/formatcode/formatcode.in 1970-01-01 00:00:00 +0000
267+++ src/formatcode/formatcode.in 2016-04-23 15:31:47 +0000
268@@ -0,0 +1,61 @@
269+#!/bin/sh
270+
271+# Copyright (C) 2013-2016 Canonical Ltd
272+#
273+# This program is free software: you can redistribute it and/or modify
274+# it under the terms of the GNU Lesser General Public License version 3 as
275+# published by the Free Software Foundation.
276+#
277+# This program is distributed in the hope that it will be useful,
278+# but WITHOUT ANY WARRANTY; without even the implied warranty of
279+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
280+# GNU Lesser General Public License for more details.
281+#
282+# You should have received a copy of the GNU Lesser General Public License
283+# along with this program. If not, see <http://www.gnu.org/licenses/>.
284+#
285+# Authors:
286+# Michi Henning <michi.henning@canonical.com>
287+# Charles Kerr <charles.kerr@canonical.com>
288+
289+# Simple script to format files with astyle, followed by clang-format (which
290+# undoes some damage that's done by astyle, without wiping out astyle edits we want
291+# to happen).
292+#
293+# usage: formatcode [FILE]...
294+#
295+# If no arguments are provided, we format stdin and write to stdout.
296+
297+astyle="@FC_ASTYLE@"
298+astyle_config="@FC_ASTYLE_CONFIG@"
299+cformat="@FC_CFORMAT@"
300+cformat_style="@FC_CFORMAT_STYLE@"
301+
302+# if no arguments were provided, read stdin and write stdout.
303+files="$@"
304+[ $# -eq 0 ] && {
305+ tmpdir=`mktemp -d`
306+ tmp=`mktemp -p $tmpdir`
307+ cat >$tmp
308+ files="$tmp"
309+}
310+
311+# maybe run astyle
312+[ -n "$astyle" -a -n "$astyle_config" ] && {
313+ "$astyle" -q --options="$astyle_config" --lineend=linux -n "$files"
314+}
315+
316+# maybe run clang-format
317+[ -n "$cformat" -a -n "$cformat_style" ] && {
318+ "$cformat" -i -style="$cformat_style" "$files"
319+}
320+
321+# if no arguments were provided, read stdin and write stdout.
322+[ $# -eq 0 ] && {
323+ cat "$tmp"
324+ rm -rf $tmpdir
325+}
326+
327+exit $?
328+
329+
330
331=== added file 'src/formatcode/formatcode_common.cmake'
332--- src/formatcode/formatcode_common.cmake 1970-01-01 00:00:00 +0000
333+++ src/formatcode/formatcode_common.cmake 2016-04-23 15:31:47 +0000
334@@ -0,0 +1,79 @@
335+#=============================================================================
336+# Copyright 2016 Canonical Ltd
337+#
338+# This file may be licensed under the terms of the
339+# GNU Lesser General Public License Version 3 (the ``LGPL''),
340+# or (at your option) any later version.
341+#
342+# Software distributed under the License is distributed
343+# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
344+# express or implied. See the LGPL for the specific language
345+# governing rights and limitations.
346+#
347+# You should have received a copy of the LGPL along with this
348+# program. If not, go to http://www.gnu.org/licenses/lgpl.html
349+# or write to the Free Software Foundation, Inc.,
350+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
351+#=============================================================================
352+
353+# formatting funcs
354+
355+function(formatcode_format_file fc_command filename)
356+ execute_process(COMMAND ${fc_command} ${filename})
357+endfunction()
358+
359+function(formatcode_format_files fc_command filenames)
360+ foreach(filename IN LISTS filenames)
361+ formatcode_format_file("${fc_command}" "${filename}")
362+ endforeach(filename)
363+endfunction()
364+
365+# testing funcs
366+
367+set(FORMATCODE_TEST_DIR ${CMAKE_BINARY_DIR}/formatted)
368+
369+function(formatcode_test_file success fc_command filename)
370+
371+ # copy the file into a relative path underneath $build/formatted/
372+ # so that, if the test fails, we can leave the formatted copy behind
373+ # as a breadcrumb without clutting any other directories
374+ file(RELATIVE_PATH rel ${CMAKE_SOURCE_DIR} ${filename})
375+ set(tmpfile ${FORMATCODE_TEST_DIR}/${rel})
376+ get_filename_component(base ${tmpfile} NAME)
377+ file(MAKE_DIRECTORY base)
378+ file(REMOVE ${tmpfile})
379+ file(READ ${filename} input)
380+ file(WRITE ${tmpfile} "${input}")
381+
382+ # format the file
383+ formatcode_format_file("${fc_command}" ${tmpfile})
384+
385+ # if the format changed, then $filename didn't match the style guide
386+ string(MD5 md5in "${input}")
387+ file(MD5 ${tmpfile} md5out)
388+ if(md5in STREQUAL md5out)
389+ file(REMOVE ${tmpfile})
390+ set(${success} TRUE PARENT_SCOPE)
391+ else()
392+ message(STATUS "leaving formatted copy in ${tmpfile}")
393+ set(${success} FALSE PARENT_SCOPE)
394+ endif()
395+
396+endfunction()
397+
398+function(formatcode_test_files fc_command filenames)
399+ set(error_count 0)
400+ foreach(filename IN LISTS filenames)
401+ formatcode_test_file(success "${fc_command}" "${filename}")
402+ if(NOT success)
403+ MATH(EXPR error_count "${error_count}+1")
404+ endif()
405+ endforeach(filename)
406+ if(error_count)
407+ message(FATAL_ERROR "formatcode test failed in ${error_count} files")
408+ else()
409+ # if nothing failed, clean up the test directory
410+ file(REMOVE_RECURSE ${FORMATCODE_TEST_DIR})
411+ endif()
412+endfunction()
413+
414
415=== added file 'src/formatcode/formatcode_format.cmake.in'
416--- src/formatcode/formatcode_format.cmake.in 1970-01-01 00:00:00 +0000
417+++ src/formatcode/formatcode_format.cmake.in 2016-04-23 15:31:47 +0000
418@@ -0,0 +1,31 @@
419+#=============================================================================
420+# Copyright 2016 Canonical Ltd
421+#
422+# This file may be licensed under the terms of the
423+# GNU Lesser General Public License Version 3 (the ``LGPL''),
424+# or (at your option) any later version.
425+#
426+# Software distributed under the License is distributed
427+# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
428+# express or implied. See the LGPL for the specific language
429+# governing rights and limitations.
430+#
431+# You should have received a copy of the LGPL along with this
432+# program. If not, go to http://www.gnu.org/licenses/lgpl.html
433+# or write to the Free Software Foundation, Inc.,
434+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
435+#=============================================================================
436+
437+set(CMAKE_BINARY_DIR @CMAKE_BINARY_DIR@)
438+set(CMAKE_SOURCE_DIR @CMAKE_SOURCE_DIR@)
439+
440+set(FC_COMMAND @FC_COMMAND@)
441+set(FC_SOURCES @FC_SOURCES@)
442+
443+include(@FC_CMAKE_MODULE_DIR@/formatcode_common.cmake)
444+
445+formatcode_format_files(
446+ "${FC_COMMAND}"
447+ "${FC_SOURCES}"
448+)
449+
450
451=== added file 'src/formatcode/formatcode_test.cmake.in'
452--- src/formatcode/formatcode_test.cmake.in 1970-01-01 00:00:00 +0000
453+++ src/formatcode/formatcode_test.cmake.in 2016-04-23 15:31:47 +0000
454@@ -0,0 +1,31 @@
455+#=============================================================================
456+# Copyright 2016 Canonical Ltd
457+#
458+# This file may be licensed under the terms of the
459+# GNU Lesser General Public License Version 3 (the ``LGPL''),
460+# or (at your option) any later version.
461+#
462+# Software distributed under the License is distributed
463+# on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
464+# express or implied. See the LGPL for the specific language
465+# governing rights and limitations.
466+#
467+# You should have received a copy of the LGPL along with this
468+# program. If not, go to http://www.gnu.org/licenses/lgpl.html
469+# or write to the Free Software Foundation, Inc.,
470+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
471+#=============================================================================
472+
473+set(CMAKE_BINARY_DIR @CMAKE_BINARY_DIR@)
474+set(CMAKE_SOURCE_DIR @CMAKE_SOURCE_DIR@)
475+
476+set(FC_COMMAND @FC_COMMAND@)
477+set(FC_SOURCES @FC_SOURCES@)
478+
479+include(@FC_CMAKE_MODULE_DIR@/formatcode_common.cmake)
480+
481+formatcode_test_files(
482+ "${FC_COMMAND}"
483+ "${FC_SOURCES}"
484+)
485+
486
487=== added file 'src/formatcode/unity-api.astyle'
488--- src/formatcode/unity-api.astyle 1970-01-01 00:00:00 +0000
489+++ src/formatcode/unity-api.astyle 2016-04-23 15:31:47 +0000
490@@ -0,0 +1,30 @@
491+# Options for formatting code with astyle.
492+#
493+# This helps to make code match the style guide.
494+#
495+# Use like this:
496+#
497+# astyle --options=astyle-config mfile.h myfile.cpp
498+#
499+# Occasionally, astyle does something silly (particularly with lambdas), so it's
500+# still necessary to scan the changes for things that are wrong.
501+# But, for most files, it does a good job.
502+#
503+# Please consider using this before checking code in for review. Code reviews shouldn't
504+# have to deal with layout issues, they are just a distraction. It's better to be able
505+# to focus on semantics in a code review, with style issues out of the way.
506+
507+--formatted
508+--style=allman
509+--min-conditional-indent=2
510+--indent-switches
511+--max-instatement-indent=120
512+--pad-header
513+--align-pointer=type
514+--align-reference=type
515+--add-brackets
516+--convert-tabs
517+--close-templates
518+--max-code-length=120
519+--pad-oper
520+
521
522=== added file 'src/formatcode/unity-api.clang-format'
523--- src/formatcode/unity-api.clang-format 1970-01-01 00:00:00 +0000
524+++ src/formatcode/unity-api.clang-format 2016-04-23 15:31:47 +0000
525@@ -0,0 +1,49 @@
526+---
527+AccessModifierOffset: -4
528+AlignEscapedNewlinesLeft: true
529+AlignTrailingComments: true
530+AllowAllParametersOfDeclarationOnNextLine: true
531+AllowShortFunctionsOnASingleLine: false
532+AllowShortIfStatementsOnASingleLine: false
533+AllowShortLoopsOnASingleLine: false
534+AlwaysBreakBeforeMultilineStrings: true
535+AlwaysBreakTemplateDeclarations: true
536+BinPackParameters: false
537+BreakBeforeBinaryOperators: false
538+BreakBeforeBraces: Allman
539+BreakBeforeTernaryOperators: false
540+BreakConstructorInitializersBeforeComma: true
541+ColumnLimit: 120
542+ConstructorInitializerAllOnOneLineOrOnePerLine: false
543+ConstructorInitializerIndentWidth: 4
544+ContinuationIndentWidth: 4
545+Cpp11BracedListStyle: true
546+DerivePointerBinding: true
547+ExperimentalAutoDetectBinPacking: false
548+IndentCaseLabels: true
549+IndentFunctionDeclarationAfterType: true
550+IndentWidth: 4
551+Language: Cpp
552+MaxEmptyLinesToKeep: 1
553+NamespaceIndentation: None
554+ObjCSpaceBeforeProtocolList: false
555+PenaltyBreakBeforeFirstCallParameter: 1
556+PenaltyBreakComment: 60
557+PenaltyBreakFirstLessLess: 120
558+PenaltyBreakString: 1000
559+PenaltyExcessCharacter: 1000000
560+PenaltyReturnTypeOnItsOwnLine: 200
561+PointerBindsToType: true
562+SortIncludes: false
563+SpaceBeforeAssignmentOperators: true
564+SpaceBeforeParens: ControlStatements
565+SpaceInEmptyParentheses: false
566+SpacesBeforeTrailingComments: 2
567+SpacesInAngles: false
568+SpacesInCStyleCastParentheses: false
569+SpacesInParentheses: false
570+Standard: Cpp11
571+TabWidth: 8
572+UseTab: Never
573+...
574+

Subscribers

People subscribed via source and target branches

to all changes: