Explorar el Código

dev: nova toolbelt

Ihar Biaspalau hace 10 meses
padre
commit
0159946b52
Se han modificado 6 ficheros con 344 adiciones y 3 borrados
  1. 246 0
      .clang-format
  2. 13 0
      .editorconfig
  3. 3 3
      .gitignore
  4. 17 0
      .nova/Tasks/Dev.json
  5. 8 0
      README.md
  6. 57 0
      nova.sh

+ 246 - 0
.clang-format

@@ -0,0 +1,246 @@
+---
+Language:        Cpp
+AccessModifierOffset: -4
+AlignAfterOpenBracket: AlwaysBreak
+AlignArrayOfStructures: None
+AlignConsecutiveAssignments:
+  Enabled:         false
+  AcrossEmptyLines: false
+  AcrossComments:  false
+  AlignCompound:   false
+  AlignFunctionPointers: false
+  PadOperators:    true
+AlignConsecutiveBitFields:
+  Enabled:         true
+  AcrossEmptyLines: true
+  AcrossComments:  true
+  AlignCompound:   false
+  AlignFunctionPointers: false
+  PadOperators:    true
+AlignConsecutiveDeclarations:
+  Enabled:         false
+  AcrossEmptyLines: false
+  AcrossComments:  false
+  AlignCompound:   false
+  AlignFunctionPointers: false
+  PadOperators:    true
+AlignConsecutiveMacros:
+  Enabled:         true
+  AcrossEmptyLines: false
+  AcrossComments:  true
+  AlignCompound:   true
+  AlignFunctionPointers: false
+  PadOperators:    true
+AlignConsecutiveShortCaseStatements:
+  Enabled:         false
+  AcrossEmptyLines: false
+  AcrossComments:  false
+  AlignCaseColons: false
+AlignEscapedNewlines: Left
+AlignOperands:   Align
+AlignTrailingComments:
+  Kind:            Never
+  OverEmptyLines:  0
+AllowAllArgumentsOnNextLine: true
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowBreakBeforeNoexceptSpecifier: Never
+AllowShortBlocksOnASingleLine: Never
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortCompoundRequirementOnASingleLine: true
+AllowShortEnumsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: WithoutElse
+AllowShortLambdasOnASingleLine: All
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: Yes
+AttributeMacros:
+  - __capability
+BinPackArguments: false
+BinPackParameters: false
+BitFieldColonSpacing: Both
+BraceWrapping:
+  AfterCaseLabel:  false
+  AfterClass:      false
+  AfterControlStatement: Never
+  AfterEnum:       false
+  AfterExternBlock: false
+  AfterFunction:   false
+  AfterNamespace:  false
+  AfterObjCDeclaration: false
+  AfterStruct:     false
+  AfterUnion:      false
+  BeforeCatch:     false
+  BeforeElse:      false
+  BeforeLambdaBody: false
+  BeforeWhile:     false
+  IndentBraces:    false
+  SplitEmptyFunction: true
+  SplitEmptyRecord: true
+  SplitEmptyNamespace: true
+BreakAdjacentStringLiterals: true
+BreakAfterAttributes: Leave
+BreakAfterJavaFieldAnnotations: false
+BreakArrays:     true
+BreakBeforeBinaryOperators: None
+BreakBeforeConceptDeclarations: Always
+BreakBeforeBraces: Attach
+BreakBeforeInlineASMColon: OnlyMultiline
+BreakBeforeTernaryOperators: false
+BreakConstructorInitializers: BeforeComma
+BreakInheritanceList: BeforeColon
+BreakStringLiterals: false
+ColumnLimit:     99
+CommentPragmas:  '^ IWYU pragma:'
+CompactNamespaces: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DerivePointerAlignment: false
+DisableFormat:   false
+EmptyLineAfterAccessModifier: Never
+EmptyLineBeforeAccessModifier: LogicalBlock
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: false
+ForEachMacros:
+  - foreach
+  - Q_FOREACH
+  - BOOST_FOREACH
+  - M_EACH
+IfMacros:
+  - KJ_IF_MAYBE
+IncludeBlocks:   Preserve
+IncludeCategories:
+  - Regex:           '.*'
+    Priority:        1
+    SortPriority:    0
+    CaseSensitive:   false
+  - Regex:           '^(<|"(gtest|gmock|isl|json)/)'
+    Priority:        3
+    SortPriority:    0
+    CaseSensitive:   false
+  - Regex:           '.*'
+    Priority:        1
+    SortPriority:    0
+    CaseSensitive:   false
+IncludeIsMainRegex: '(Test)?$'
+IncludeIsMainSourceRegex: ''
+IndentAccessModifiers: false
+IndentCaseBlocks: false
+IndentCaseLabels: false
+IndentExternBlock: AfterExternBlock
+IndentGotoLabels: true
+IndentPPDirectives: None
+IndentRequiresClause: false
+IndentWidth:     4
+IndentWrappedFunctionNames: true
+InsertBraces:    false
+InsertNewlineAtEOF: true
+InsertTrailingCommas: None
+IntegerLiteralSeparator:
+  Binary:          0
+  BinaryMinDigits: 0
+  Decimal:         0
+  DecimalMinDigits: 0
+  Hex:             0
+  HexMinDigits:    0
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+KeepEmptyLinesAtEOF: false
+LambdaBodyIndentation: Signature
+LineEnding:      DeriveLF
+MacroBlockBegin: ''
+MacroBlockEnd:   ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBinPackProtocolList: Auto
+ObjCBlockIndentWidth: 4
+ObjCBreakBeforeNestedBlockParam: true
+ObjCSpaceAfterProperty: true
+ObjCSpaceBeforeProtocolList: true
+PackConstructorInitializers: BinPack
+PenaltyBreakAssignment: 10
+PenaltyBreakBeforeFirstCallParameter: 30
+PenaltyBreakComment: 10
+PenaltyBreakFirstLessLess: 0
+PenaltyBreakOpenParenthesis: 0
+PenaltyBreakScopeResolution: 500
+PenaltyBreakString: 10
+PenaltyBreakTemplateDeclaration: 10
+PenaltyExcessCharacter: 100
+PenaltyIndentedWhitespace: 0
+PenaltyReturnTypeOnItsOwnLine: 60
+PointerAlignment: Left
+PPIndentWidth:   -1
+QualifierAlignment: Leave
+ReferenceAlignment: Pointer
+ReflowComments:  false
+RemoveBracesLLVM: false
+RemoveParentheses: Leave
+RemoveSemicolon: true
+RequiresClausePosition: OwnLine
+RequiresExpressionIndentation: OuterScope
+SeparateDefinitionBlocks: Leave
+ShortNamespaceLines: 1
+SkipMacroDefinitionBody: false
+SortIncludes:    Never
+SortJavaStaticImport: Before
+SortUsingDeclarations: Never
+SpaceAfterCStyleCast: false
+SpaceAfterLogicalNot: false
+SpaceAfterTemplateKeyword: true
+SpaceAroundPointerQualifiers: Default
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeCaseColon: false
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
+SpaceBeforeJsonColon: false
+SpaceBeforeParens: Never
+SpaceBeforeParensOptions:
+  AfterControlStatements: false
+  AfterForeachMacros: false
+  AfterFunctionDefinitionName: false
+  AfterFunctionDeclarationName: false
+  AfterIfMacros:   false
+  AfterOverloadedOperator: false
+  AfterPlacementOperator: true
+  AfterRequiresInClause: false
+  AfterRequiresInExpression: false
+  BeforeNonEmptyParentheses: false
+SpaceBeforeRangeBasedForLoopColon: true
+SpaceBeforeSquareBrackets: false
+SpaceInEmptyBlock: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles:  Never
+SpacesInContainerLiterals: false
+SpacesInLineCommentPrefix:
+  Minimum:         1
+  Maximum:         -1
+SpacesInParens:  Never
+SpacesInParensOptions:
+  InCStyleCasts:   false
+  InConditionalStatements: false
+  InEmptyParentheses: false
+  Other:           false
+SpacesInSquareBrackets: false
+Standard:        c++20
+StatementAttributeLikeMacros:
+  - Q_EMIT
+StatementMacros:
+  - Q_UNUSED
+  - QT_REQUIRE_VERSION
+TabWidth:        4
+UseTab:          Never
+VerilogBreakBetweenInstancePorts: true
+WhitespaceSensitiveMacros:
+  - STRINGIZE
+  - PP_STRINGIZE
+  - BOOST_PP_STRINGIZE
+  - NS_SWIFT_NAME
+  - CF_SWIFT_NAME
+...
+

+ 13 - 0
.editorconfig

@@ -0,0 +1,13 @@
+root = true
+
+[*]
+end_of_line = lf
+insert_final_newline = true
+charset = utf-8
+
+[*.{cpp,h,c,py,sh}]
+indent_style = space
+indent_size = 4
+
+[{Makefile,*.mk}]
+indent_size = tab

+ 3 - 3
.gitignore

@@ -1,11 +1,11 @@
 dist/*
 .vscode
-.clang-format
 .clangd
-.editorconfig
 .env
 .ufbt
 .cache
-.nova
+.nova/*
+!.nova/Tasks/
+!.nova/Tasks/Dev.json
 .DS_Store
 compile_commands.json

+ 17 - 0
.nova/Tasks/Dev.json

@@ -0,0 +1,17 @@
+{
+  "actions" : {
+    "build" : {
+      "enabled" : true,
+      "script" : "ufbt -c && ufbt && rm -rf .vscode"
+    },
+    "clean" : {
+      "enabled" : true,
+      "script" : "ufbt -c"
+    },
+    "run" : {
+      "enabled" : true,
+      "script" : "ufbt launch"
+    }
+  },
+  "openLogOnRun" : "fail"
+}

+ 8 - 0
README.md

@@ -51,6 +51,14 @@ ufbt launch
 ```
 > This command deploys app to Flipper Zero and launches an application
 
+### Nova
+For Nova there is a helpful script to setup dev env.
+
+1. Install C-Dragon extension
+2. Run `./nova.sh`
+3. Update C-Dragon settings to use Custom clangd and set Language server Path to one produced by `./nova.sh` command
+4. Restart Nova and enjoy
+
 ## Contibuting
 
 1. Fork repo

+ 57 - 0
nova.sh

@@ -0,0 +1,57 @@
+#!/bin/bash
+
+if [[ "$OSTYPE" != "darwin"* ]]; then
+    echo "Unsupported OS"
+    exit 1
+fi
+
+PROJECT_PATH="$(pwd)"
+VSCODE_PATH="${PROJECT_PATH}/.vscode"
+CONFIG="compile_commands.json"
+
+VSCODE_CONFIG_PATH="${VSCODE_PATH}/${CONFIG}"
+PROJECT_CONFIG_PATH="${PROJECT_PATH}/${CONFIG}"
+TMP_PATH="${PROJECT_PATH}/tmp.json"
+TOOLCHAIN_PATH="${HOME}/.ufbt/toolchain/arm64-darwin"
+CLANGD_PATH="${TOOLCHAIN_PATH}/bin/clangd"
+
+FLAGS_TO_ADD=" --target=arm-none-eabi -Wno-unused-include-directive --sysroot=${TOOLCHAIN_PATH}/arm-none-eabi"
+FLAGS_TO_REMOVE="-mword-relocations"
+FLAGS_TO_REMOVE_ARRAY=$(echo "$FLAGS_TO_REMOVE" | jq -R 'split(" ")')
+
+echo "Installing ufbt..."
+python3 -m pip install --upgrade ufbt
+
+echo "Updating ufbt..."
+ufbt update
+
+echo "Generate compile_commands.json"
+ufbt cdb
+
+echo "Move compile_commands.json to project root"
+mv "${VSCODE_CONFIG_PATH}" "${PROJECT_CONFIG_PATH}"
+
+echo "Add extra flags to compile_commands.json"
+jq --arg flags "${FLAGS_TO_ADD}" 'map(.command += $flags)' "${PROJECT_CONFIG_PATH}" > "${TMP_PATH}" && mv "${TMP_PATH}" "${PROJECT_CONFIG_PATH}"
+
+echo "Remove conflicting flags from compile_commands.json"
+jq --argjson flags "${FLAGS_TO_REMOVE_ARRAY}" '
+  map(
+    .command = (
+      (.command | split(" "))
+      | map(select(. as $word | $flags | index($word) | not))
+      | join(" ")
+    )
+  )
+' "${PROJECT_CONFIG_PATH}" > "${TMP_PATH}" && mv "${TMP_PATH}" "${PROJECT_CONFIG_PATH}"
+
+echo "Remove .vscode dir"
+rm -rf "${VSCODE_PATH}"
+
+echo "Remove .clangd file"
+rm -rf "${PROJECT_PATH}/.clangd"
+
+printf "Done\n\n"
+
+echo "Update Language Server path in C-Dragon extension settings to:"
+echo "${CLANGD_PATH}"