Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang format #402

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 178 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -2
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: DontAlign
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortLambdasOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BeforeWhile: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true

BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: true
BreakInheritanceList: BeforeComma
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^\s*(\*)?\s*\\.+'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
# EmptyLineBeforeAccessModifier: Always
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<(gtest|gmock)/.*'
Priority: 1

- Regex: '^".*generated.*'
Priority: 70

- Regex: '^<sc-memory/.*'
Priority: 11

- Regex: '^"sc_.*'
Priority: 21

- Regex: '^"\.\./.*'
Priority: 22

- Regex: '^".*'
Priority: 23

- Regex: '^<boost/.*'
Priority: 30

- Regex: '^<.*'
Priority: 31

- Regex: '.*'
Priority: 100

# IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: false
IndentPPDirectives: AfterHash
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000
PenaltyReturnTypeOnItsOwnLine: 2000
PointerAlignment: Middle
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ''
BasedOnStyle: google
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
# SpaceAroundPointerQualifiers: After/Both
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 2
UseTab: Never
...
15 changes: 14 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: GsActions/commit-message-checker@v1
with:
# A regex pattern to check if a commit message is valid.
pattern: "((\\[(builder|changelog|ci|cmake|codegen|core|doc|docs|git|sc-kpm|sc-memory|sc-network|sc-server|scripts|scs|test|tests|thirdparty|web)\\])+(.)+)|(Review fixes)$"
pattern: "((\\[(builder|changelog|ci|cmake|codegen|core|doc|docs|format|git|sc-kpm|sc-memory|sc-network|sc-server|scripts|scs|test|tests|thirdparty|web)\\])+(.)+)|(Review fixes)$"
# Expression flags change how the expression is interpreted.
flags: # optional, default is gm
# A error message which will be returned in case of an error.
Expand All @@ -32,6 +32,19 @@ jobs:
checkAllCommitMessages: true # optional, default is false
# you must provide GITHUB_TOKEN to this input if checkAllCommitMessages is true
accessToken: ${{ secrets.GITHUB_TOKEN }} # optional, default is false

check_formatting:
name: Check code formatting
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Check
id: check_formatting
run: scripts/ci/check-formatting.sh

run_tests:
name: ${{matrix.config.name}}
runs-on: ${{matrix.config.os}}
Expand Down
21 changes: 16 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,34 @@ project (sc-machine)
site_name (www.ostis.net)
cmake_minimum_required (VERSION 2.8)

include(CTest)
include (CTest)
include (CheckCCompilerFlag)

set(SC_BIN_PATH "${CMAKE_CURRENT_LIST_DIR}/bin")
set (SC_BIN_PATH "${CMAKE_CURRENT_LIST_DIR}/bin")

set(SC_MACHINE_ROOT ${CMAKE_CURRENT_LIST_DIR})
set(SC_MACHINE_THIRDPARTY_PATH "${SC_MACHINE_ROOT}/thirdparty")
set (SC_MACHINE_ROOT ${CMAKE_CURRENT_LIST_DIR})
set (SC_MACHINE_THIRDPARTY_PATH "${SC_MACHINE_ROOT}/thirdparty")

option (SC_AUTO_TEST "Flag to build for automation testing" OFF)
option (SC_KPM_SCP "Flag to build SCP module" OFF)
option (SC_BUILD_SCTP "Flag to turn on/off sctp protocol support" OFF)
option (SC_BUILD_ARM64 "Flag to build arm64" OFF)

set(SC_USE_SANITIZER "none" CACHE STRING "Build with specified sanitizer")
set_property(CACHE SC_USE_SANITIZER PROPERTY STRINGS none address memory)

message ("Sanitizer: ${SC_USE_SANITIZER}")

if (${SC_BUILD_ARM64})
check_c_compiler_flag("-arch arm64" IS_ARM64_SUPPORTED)
if (${IS_ARM64_SUPPORTED})
set (CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "Used architecture" FORCE)
message ("-- Architecture: arm64")
else()
message (FATAL_ERROR "Arm64 platform is not supported by compiler")
endif()
endif()

# codegen
if (${UNIX})
set(SC_CODEGEN_TOOL "${SC_BIN_PATH}/sc-code-generator")
Expand Down Expand Up @@ -91,7 +103,6 @@ if (${APPLE})

set (GLIB2_LIBRARIES ${GLIB_LDFLAGS} ${GLIB2_MODULE_LDFLAGS})

set (LIBCLANG_LLVM_CONFIG_EXECUTABLE "/usr/local/opt/llvm/bin/llvm-config")
if (NOT DEFINED LIBCLANG_LIBRARIES OR NOT DEFINED LIBCLANG_CXXFLAGS OR NOT DEFINED LIBCLANG_LIBDIR)
find_package(LibClang REQUIRED)
endif ()
Expand Down
1 change: 1 addition & 0 deletions cmake/FindLibClang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ if (NOT LIBCLANG_LLVM_CONFIG_EXECUTABLE)
set(llvm_config_names llvm-config)
foreach(minor RANGE 9 0)
list(APPEND llvm_config_names
"llvm-config"
"llvm-config-7"
"llvm-config-6.${minor}"
"llvm-config-5.${minor}"
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- **Build system**:
- Set project binaries path to root (#352)
- Support arm64 build

- **Core**:
- Fix issue with erasing empty sc-link
Expand Down
1 change: 1 addition & 0 deletions docs/dev/pr.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Possible tags:
* `[codegen]` - changes in code generator
* `[core]` - changes in `sc-storage` code
* `[doc]` or `[docs]` - update documentation
* `[format]` - changes in code formatting
* `[git]` - changes in git configuration
* `[sc-kpm]` - changes in `sc-kpm` code
* `[sc-memory]` - changes in `sc-memory` code
Expand Down
11 changes: 5 additions & 6 deletions sc-kpm/sc-ui/translators/uiSc2SCgJsonTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
*/

#include "uiPrecompiled.h"
#include "uiSc2SCgJsonTranslator.h"

#include "uiKeynodes.h"
#include "uiPrecompiled.h"
#include "uiTranslators.h"
#include "uiUtils.h"

Expand All @@ -17,7 +17,6 @@ uiSc2SCgJsonTranslator::uiSc2SCgJsonTranslator()

uiSc2SCgJsonTranslator::~uiSc2SCgJsonTranslator()
{

}

void uiSc2SCgJsonTranslator::runImpl()
Expand All @@ -29,7 +28,7 @@ void uiSc2SCgJsonTranslator::runImpl()

mOutputData = "[";

sc_iterator3 *it = sc_iterator3_f_a_a_new(s_default_ctx, mInputConstructionAddr, sc_type_arc_pos_const_perm, 0);
sc_iterator3 * it = sc_iterator3_f_a_a_new(s_default_ctx, mInputConstructionAddr, sc_type_arc_pos_const_perm, 0);
while (sc_iterator3_next(it) == SC_TRUE)
{
el_type = 0;
Expand All @@ -54,10 +53,10 @@ void uiSc2SCgJsonTranslator::runImpl()

sc_addr beg_addr;
if (sc_memory_get_arc_begin(s_default_ctx, addr, &beg_addr) != SC_RESULT_OK)
continue; //! TODO error logging
continue; //! TODO error logging
sc_addr end_addr;
if (sc_memory_get_arc_end(s_default_ctx, addr, &end_addr) != SC_RESULT_OK)
continue; //! TODO error logging
continue; //! TODO error logging

attrs["begin"] = buildId(beg_addr);
attrs["end"] = buildId(end_addr);
Expand Down Expand Up @@ -90,7 +89,7 @@ void uiSc2SCgJsonTranslator::runImpl()
}

// ------------------------------------------------------------------------------
sc_result uiSc2SCgJsonTranslator::ui_translate_sc2scg_json(const sc_event *event, sc_addr arg)
sc_result uiSc2SCgJsonTranslator::ui_translate_sc2scg_json(const sc_event * event, sc_addr arg)
{
sc_addr cmd_addr, input_addr, format_addr;

Expand Down
Loading