From 22567d107fffe7a6833b96cc99d531e5303b47dd Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Sat, 25 Mar 2017 19:12:18 +0100 Subject: Add clang format & skip build if no source file modified (#5433) * [BUILD] Add clang format + build skipping * Add clang-format tool to check codestyle. Warning: it check the whole modified file, not the diff part, it's why it's lazy. Please also look if rules are perfect, i take the Linux codestyle from LLVM site Fix issue #5415 * Skip building project if no file is modified * Fix a wrong brace to trigger LINT * Make lint step outside of unix build scope * Add AccessModifierOffset: -8 * Typo fix & needs compile fix * Fix header priorities --- .clang-format | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .clang-format (limited to '.clang-format') diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..82e2abf15 --- /dev/null +++ b/.clang-format @@ -0,0 +1,12 @@ +BasedOnStyle: LLVM +IndentWidth: 8 +UseTab: Always +BreakBeforeBraces: Linux +AllowShortIfStatementsOnASingleLine: false +IndentCaseLabels: false +AccessModifierOffset: -8 +IncludeCategories: + - Regex: '^".*' + Priority: 2 + - Regex: '^<.*' + Priority: 1 -- cgit v1.2.3 From a4874270f791fae8745cac23e153c59bef81bd1e Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Fri, 31 Mar 2017 22:29:34 +0200 Subject: Fix clang-format Columns Width Also fix l_client.cpp/h and remove them from whitelist --- .clang-format | 1 + src/script/lua_api/l_client.cpp | 13 ++++++------- src/script/lua_api/l_client.h | 4 ++-- util/travis/clang-format-whitelist.txt | 2 -- 4 files changed, 9 insertions(+), 11 deletions(-) (limited to '.clang-format') diff --git a/.clang-format b/.clang-format index 82e2abf15..547df6a95 100644 --- a/.clang-format +++ b/.clang-format @@ -5,6 +5,7 @@ BreakBeforeBraces: Linux AllowShortIfStatementsOnASingleLine: false IndentCaseLabels: false AccessModifierOffset: -8 +ColumnLimit: 90 IncludeCategories: - Regex: '^".*' Priority: 2 diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp index 52c7f6f30..7cb89188d 100644 --- a/src/script/lua_api/l_client.cpp +++ b/src/script/lua_api/l_client.cpp @@ -19,13 +19,13 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "l_client.h" -#include "l_internal.h" -#include "util/string.h" +#include "common/c_content.h" +#include "common/c_converter.h" #include "cpp_api/s_base.h" #include "gettext.h" -#include "common/c_converter.h" -#include "common/c_content.h" +#include "l_internal.h" #include "lua_api/l_item.h" +#include "util/string.h" int ModApiClient::l_get_current_modname(lua_State *L) { @@ -88,7 +88,7 @@ int ModApiClient::l_get_player_names(lua_State *L) // show_formspec(formspec) int ModApiClient::l_show_formspec(lua_State *L) { - if ( !lua_isstring(L, 1) || !lua_isstring(L, 2) ) + if (!lua_isstring(L, 1) || !lua_isstring(L, 2)) return 0; ClientEvent event; @@ -142,8 +142,7 @@ int ModApiClient::l_get_node_or_nil(lua_State *L) if (pos_ok) { // Return node pushnode(L, n, getClient(L)->ndef()); - } - else { + } else { lua_pushnil(L); } return 1; diff --git a/src/script/lua_api/l_client.h b/src/script/lua_api/l_client.h index fcf8c39ea..b79cc670d 100644 --- a/src/script/lua_api/l_client.h +++ b/src/script/lua_api/l_client.h @@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "lua_api/l_base.h" -class ModApiClient: public ModApiBase +class ModApiClient : public ModApiBase { private: // get_current_modname() @@ -31,7 +31,7 @@ private: // display_chat_message(message) static int l_display_chat_message(lua_State *L); - + // get_player_names() static int l_get_player_names(lua_State *L); diff --git a/util/travis/clang-format-whitelist.txt b/util/travis/clang-format-whitelist.txt index 519e594f9..0d99793b4 100644 --- a/util/travis/clang-format-whitelist.txt +++ b/util/travis/clang-format-whitelist.txt @@ -287,8 +287,6 @@ src/script/lua_api/l_areastore.cpp src/script/lua_api/l_areastore.h src/script/lua_api/l_base.cpp src/script/lua_api/l_base.h -src/script/lua_api/l_client.cpp -src/script/lua_api/l_client.h src/script/lua_api/l_craft.cpp src/script/lua_api/l_craft.h src/script/lua_api/l_env.cpp -- cgit v1.2.3 From 00138a52d892b6f07d6f6d70c27bb9c61ee191c3 Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Thu, 6 Apr 2017 15:27:47 +0200 Subject: Clang format brace style fix --- .clang-format | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to '.clang-format') diff --git a/.clang-format b/.clang-format index 547df6a95..63d884a09 100644 --- a/.clang-format +++ b/.clang-format @@ -1,7 +1,17 @@ BasedOnStyle: LLVM IndentWidth: 8 UseTab: Always -BreakBeforeBraces: Linux +BreakBeforeBraces: Custom +BraceWrapping: + AfterClass: true + AfterControlStatement: false + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterStruct: true + AfterUnion: true + BeforeCatch: false + BeforeElse: false AllowShortIfStatementsOnASingleLine: false IndentCaseLabels: false AccessModifierOffset: -8 -- cgit v1.2.3 From be0663696514dd3d3525949be7c317c9eae9dbb0 Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Thu, 6 Apr 2017 15:37:02 +0200 Subject: Clang-format continuation indent fixes + .gitignore additions * Proper support for continuation indents in clang format * make src/wieldmesh.h proper and remove it from whitelist * Add CLion default build directories in .gitignore --- .clang-format | 2 ++ .gitignore | 2 ++ src/wieldmesh.h | 20 ++++++++------------ util/travis/clang-format-whitelist.txt | 1 - 4 files changed, 12 insertions(+), 13 deletions(-) (limited to '.clang-format') diff --git a/.clang-format b/.clang-format index 63d884a09..05a6b3385 100644 --- a/.clang-format +++ b/.clang-format @@ -21,3 +21,5 @@ IncludeCategories: Priority: 2 - Regex: '^<.*' Priority: 1 +AlignAfterOpenBracket: DontAlign +ContinuationIndentWidth: 16 diff --git a/.gitignore b/.gitignore index c2600afeb..c51cced03 100644 --- a/.gitignore +++ b/.gitignore @@ -75,6 +75,8 @@ locale/ *.ninja .ninja* *.gch +cmake-build-debug/ +cmake-build-release/ ## Android build files build/android/src/main/assets diff --git a/src/wieldmesh.h b/src/wieldmesh.h index 2e78232ae..200587058 100644 --- a/src/wieldmesh.h +++ b/src/wieldmesh.h @@ -20,8 +20,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef WIELDMESH_HEADER #define WIELDMESH_HEADER -#include "irrlichttypes_extrabloated.h" #include +#include "irrlichttypes_extrabloated.h" struct ItemStack; class Client; @@ -31,30 +31,27 @@ struct TileSpec; /* Wield item scene node, renders the wield mesh of some item */ -class WieldMeshSceneNode: public scene::ISceneNode +class WieldMeshSceneNode : public scene::ISceneNode { public: WieldMeshSceneNode(scene::ISceneNode *parent, scene::ISceneManager *mgr, s32 id = -1, bool lighting = false); virtual ~WieldMeshSceneNode(); - void setCube(const TileSpec tiles[6], - v3f wield_scale, ITextureSource *tsrc); - void setExtruded(const std::string &imagename, - v3f wield_scale, ITextureSource *tsrc, u8 num_frames); + void setCube(const TileSpec tiles[6], v3f wield_scale, ITextureSource *tsrc); + void setExtruded(const std::string &imagename, v3f wield_scale, + ITextureSource *tsrc, u8 num_frames); void setItem(const ItemStack &item, Client *client); // Sets the vertex color of the wield mesh. // Must only be used if the constructor was called with lighting = false void setColor(video::SColor color); - scene::IMesh *getMesh() - { return m_meshnode->getMesh(); } + scene::IMesh *getMesh() { return m_meshnode->getMesh(); } virtual void render(); - virtual const aabb3f &getBoundingBox() const - { return m_bounding_box; } + virtual const aabb3f &getBoundingBox() const { return m_bounding_box; } private: void changeToMesh(scene::IMesh *mesh); @@ -84,6 +81,5 @@ private: scene::IMesh *getItemMesh(Client *client, const ItemStack &item); -scene::IMesh *getExtrudedMesh(ITextureSource *tsrc, - const std::string &imagename); +scene::IMesh *getExtrudedMesh(ITextureSource *tsrc, const std::string &imagename); #endif diff --git a/util/travis/clang-format-whitelist.txt b/util/travis/clang-format-whitelist.txt index 352fe2973..0dcc7713d 100644 --- a/util/travis/clang-format-whitelist.txt +++ b/util/travis/clang-format-whitelist.txt @@ -438,4 +438,3 @@ src/voxelalgorithms.h src/voxel.cpp src/voxel.h src/wieldmesh.cpp -src/wieldmesh.h -- cgit v1.2.3 From b4106ca58f723a64bcaec619b7f5c686f5e4abb2 Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Mon, 10 Apr 2017 09:17:53 +0200 Subject: Clang-format styles fixes since previous commit --- .clang-format | 3 +++ src/script/lua_api/l_localplayer.cpp | 19 ++++++++++++++----- src/wieldmesh.h | 2 +- util/travis/clang-format-whitelist.txt | 1 + 4 files changed, 19 insertions(+), 6 deletions(-) (limited to '.clang-format') diff --git a/.clang-format b/.clang-format index 05a6b3385..d2e2f2940 100644 --- a/.clang-format +++ b/.clang-format @@ -2,6 +2,7 @@ BasedOnStyle: LLVM IndentWidth: 8 UseTab: Always BreakBeforeBraces: Custom +Standard: Cpp03 BraceWrapping: AfterClass: true AfterControlStatement: false @@ -16,6 +17,8 @@ AllowShortIfStatementsOnASingleLine: false IndentCaseLabels: false AccessModifierOffset: -8 ColumnLimit: 90 +AllowShortFunctionsOnASingleLine: Inline +SortIncludes: false IncludeCategories: - Regex: '^".*' Priority: 2 diff --git a/src/script/lua_api/l_localplayer.cpp b/src/script/lua_api/l_localplayer.cpp index 87190cb39..8aac5355c 100644 --- a/src/script/lua_api/l_localplayer.cpp +++ b/src/script/lua_api/l_localplayer.cpp @@ -21,7 +21,10 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "l_internal.h" #include "script/common/c_converter.h" -LuaLocalPlayer::LuaLocalPlayer(LocalPlayer *m) { m_localplayer = m; } +LuaLocalPlayer::LuaLocalPlayer(LocalPlayer *m) +{ + m_localplayer = m; +} void LuaLocalPlayer::create(lua_State *L, LocalPlayer *m) { @@ -332,7 +335,10 @@ LuaLocalPlayer *LuaLocalPlayer::checkobject(lua_State *L, int narg) return *(LuaLocalPlayer **)ud; } -LocalPlayer *LuaLocalPlayer::getobject(LuaLocalPlayer *ref) { return ref->m_localplayer; } +LocalPlayer *LuaLocalPlayer::getobject(LuaLocalPlayer *ref) +{ + return ref->m_localplayer; +} LocalPlayer *LuaLocalPlayer::getobject(lua_State *L, int narg) { @@ -376,8 +382,10 @@ void LuaLocalPlayer::Register(lua_State *L) } const char LuaLocalPlayer::className[] = "LocalPlayer"; -const luaL_reg LuaLocalPlayer::methods[] = {luamethod(LuaLocalPlayer, get_velocity), - luamethod(LuaLocalPlayer, get_hp), luamethod(LuaLocalPlayer, get_name), +const luaL_reg LuaLocalPlayer::methods[] = { + luamethod(LuaLocalPlayer, get_velocity), + luamethod(LuaLocalPlayer, get_hp), + luamethod(LuaLocalPlayer, get_name), luamethod(LuaLocalPlayer, is_teleported), luamethod(LuaLocalPlayer, is_attached), luamethod(LuaLocalPlayer, is_touching_ground), @@ -404,4 +412,5 @@ const luaL_reg LuaLocalPlayer::methods[] = {luamethod(LuaLocalPlayer, get_veloci luamethod(LuaLocalPlayer, get_movement_speed), luamethod(LuaLocalPlayer, get_movement), - {0, 0}}; + {0, 0} +}; diff --git a/src/wieldmesh.h b/src/wieldmesh.h index dee18ca23..d3946b4e0 100644 --- a/src/wieldmesh.h +++ b/src/wieldmesh.h @@ -36,7 +36,7 @@ struct ItemMesh * If the boolean is true, the color is fixed, else * palettes can modify it. */ - std::vector> buffer_colors; + std::vector > buffer_colors; ItemMesh() : mesh(NULL), buffer_colors() {} }; diff --git a/util/travis/clang-format-whitelist.txt b/util/travis/clang-format-whitelist.txt index 1f8c10ebb..acb6d51e4 100644 --- a/util/travis/clang-format-whitelist.txt +++ b/util/travis/clang-format-whitelist.txt @@ -284,6 +284,7 @@ src/script/lua_api/l_item.cpp src/script/lua_api/l_item.h src/script/lua_api/l_itemstackmeta.cpp src/script/lua_api/l_itemstackmeta.h +src/script/lua_api/l_localplayer.cpp src/script/lua_api/l_mainmenu.cpp src/script/lua_api/l_mainmenu.h src/script/lua_api/l_mapgen.cpp -- cgit v1.2.3