Skip to content

Commit

Permalink
Add .clang-format file
Browse files Browse the repository at this point in the history
And a Makefile target to format uncommitted code.

Unfortunately clang-format seems to be too strict with indenting, and I
does not work well with C99 designated initializers.

I want to start to use it manually for new code and see if that is
useful or not.
  • Loading branch information
guillaumechereau committed Jul 8, 2024
1 parent 18ac7bf commit d0aebcd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
33 changes: 33 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Style for goxel.
# Still a work in progress.

BasedOnStyle: LLVM

AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: WithoutElse

ColumnLimit: 80
PenaltyExcessCharacter: 1000

# Never use tabs for indentation.
UseTab: Never
TabWidth: 4
IndentWidth: 4

ContinuationIndentWidth: 8
BracedInitializerIndentWidth: 4

BreakBeforeBraces: Linux

BinPackParameters: false
AllowAllArgumentsOnNextLine: true

SortIncludes: true

PenaltyReturnTypeOnItsOwnLine: 10000
PenaltyBreakAssignment: 100
PenaltyIndentedWhitespace: 2

ForEachMacros:
- DL_FOREACH
- DL_FOREACH_SAFE
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ endif

.ONESHELL:

all:
all: .FORCE
scons $(JOBS)

release:
Expand All @@ -19,12 +19,17 @@ profile:
run:
./goxel

clean:
clean: .FORCE
scons -c

analyze:
scan-build scons mode=analyze

# For the moment only apply the format to uncommited changes.
format: .FORCE
git clang-format -f


# Generate an AppImage. Used by github CI.
appimage:
scons mode=release
Expand Down Expand Up @@ -63,3 +68,7 @@ uninstall:
rm -f $(DESTDIR)$(PREFIX)/share/applications/goxel.desktop
rm -f $$(printf '%s%s' $(DESTDIR)$(PREFIX)/share/metainfo/ \
io.github.guillaumechereau.Goxel.metainfo.xml)

.PHONY: all

.FORCE:

0 comments on commit d0aebcd

Please sign in to comment.