diff --git a/.gitignore b/.gitignore index 59c526d2d..888c6a6b2 100644 --- a/.gitignore +++ b/.gitignore @@ -45,9 +45,6 @@ null.d .sconsign.dblite -# Visual Studio Code -/.vscode - # bundle output /dist /artifacts-default diff --git a/.gitmodules b/.gitmodules index 6f73e125a..df5bf648f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -23,9 +23,6 @@ [submodule "lib/mbedtls"] path = lib/mbedtls url = https://github.com/Mbed-TLS/mbedtls.git -[submodule "lib/cxxheaderparser"] - path = lib/cxxheaderparser - url = https://github.com/robotpy/cxxheaderparser.git [submodule "lib/heatshrink"] path = lib/heatshrink url = https://github.com/flipperdevices/heatshrink.git diff --git a/.vscode/example/settings.json b/.vscode/example/settings.json.tmpl similarity index 72% rename from .vscode/example/settings.json rename to .vscode/example/settings.json.tmpl index 9afabf926..5e5b5dcf4 100644 --- a/.vscode/example/settings.json +++ b/.vscode/example/settings.json.tmpl @@ -1,11 +1,7 @@ { - "C_Cpp.default.cStandard": "gnu23", - "C_Cpp.default.cppStandard": "c++20", - "python.formatting.provider": "black", "workbench.tree.indent": 12, "cortex-debug.enableTelemetry": false, "cortex-debug.variableUseNaturalFormat": true, - "cortex-debug.showRTOS": true, "cortex-debug.armToolchainPath": "${workspaceFolder}/toolchain/current/bin", "cortex-debug.openocdPath": "${workspaceFolder}/toolchain/current/bin/openocd", "cortex-debug.gdbPath": "${workspaceFolder}/toolchain/current/bin/arm-none-eabi-gdb-py3", @@ -16,9 +12,9 @@ "SConstruct": "python", "*.fam": "python" }, + "clangd.path": "${workspaceFolder}/toolchain/current/bin/clangd@FBT_PLATFORM_EXECUTABLE_EXT@", "clangd.arguments": [ - // We might be able to tighten this a bit more to only include the correct toolchain. - "--query-driver=**", + "--query-driver=**/arm-none-eabi-*", "--compile-commands-dir=${workspaceFolder}/build/latest", "--clang-tidy", "--header-insertion=never" diff --git a/SConstruct b/SConstruct index 268472a7c..48baaa95e 100644 --- a/SConstruct +++ b/SConstruct @@ -43,10 +43,10 @@ distenv = coreenv.Clone( "blackmagic", "jflash", "doxygen", + "textfile", ], ENV=os.environ, UPDATE_BUNDLE_DIR="dist/${DIST_DIR}/f${TARGET_HW}-update-${DIST_SUFFIX}", - VSCODE_LANG_SERVER=ARGUMENTS.get("LANG_SERVER", "cpptools"), ) firmware_env = distenv.AddFwProject( @@ -403,14 +403,23 @@ distenv.PhonyTarget( ) # Prepare vscode environment -VSCODE_LANG_SERVER = cmd_environment["LANG_SERVER"] vscode_dist = distenv.Install( "#.vscode", [ - distenv.Glob("#.vscode/example/*.json"), - distenv.Glob(f"#.vscode/example/{VSCODE_LANG_SERVER}/*.json"), + distenv.Glob("#.vscode/example/*.json", exclude="*.tmpl"), + distenv.Glob("#.vscode/example/${LANG_SERVER}/*.json"), ], ) +for template_file in distenv.Glob("#.vscode/example/*.tmpl"): + vscode_dist.append( + distenv.Substfile( + distenv.Dir("#.vscode").File(template_file.name.replace(".tmpl", "")), + template_file, + SUBST_DICT={ + "@FBT_PLATFORM_EXECUTABLE_EXT@": ".exe" if os.name == "nt" else "" + }, + ) + ) distenv.Precious(vscode_dist) distenv.NoClean(vscode_dist) distenv.Alias("vscode_dist", (vscode_dist, firmware_env["FW_CDB"])) diff --git a/lib/cxxheaderparser b/lib/cxxheaderparser deleted file mode 160000 index ba4222560..000000000 --- a/lib/cxxheaderparser +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ba4222560fc1040670b1a917d5d357198e8ec5d6 diff --git a/scripts/fbt/sdk/collector.py b/scripts/fbt/sdk/collector.py index 1dd3bc4eb..5615f105e 100644 --- a/scripts/fbt/sdk/collector.py +++ b/scripts/fbt/sdk/collector.py @@ -38,7 +38,6 @@ from cxxheaderparser.types import ( from cxxheaderparser.parserstate import ( State, - EmptyBlockState, ClassBlockState, ExternBlockState, NamespaceBlockState, @@ -180,12 +179,6 @@ class SdkCxxVisitor: def on_include(self, state: State, filename: str) -> None: pass - def on_empty_block_start(self, state: EmptyBlockState) -> None: - pass - - def on_empty_block_end(self, state: EmptyBlockState) -> None: - pass - def on_extern_block_start(self, state: ExternBlockState) -> None: pass @@ -230,3 +223,6 @@ class SdkCxxVisitor: def on_class_end(self, state: ClassBlockState) -> None: pass + + def on_parse_start(self, state: NamespaceBlockState) -> None: + pass diff --git a/scripts/toolchain/fbtenv.cmd b/scripts/toolchain/fbtenv.cmd index 635affdd4..c0a3cd870 100644 --- a/scripts/toolchain/fbtenv.cmd +++ b/scripts/toolchain/fbtenv.cmd @@ -13,7 +13,7 @@ if not ["%FBT_NOENV%"] == [""] ( exit /b 0 ) -set "FLIPPER_TOOLCHAIN_VERSION=37" +set "FLIPPER_TOOLCHAIN_VERSION=38" if ["%FBT_TOOLCHAIN_PATH%"] == [""] ( set "FBT_TOOLCHAIN_PATH=%FBT_ROOT%" diff --git a/scripts/toolchain/fbtenv.sh b/scripts/toolchain/fbtenv.sh index 3730a5539..ed3d653d5 100755 --- a/scripts/toolchain/fbtenv.sh +++ b/scripts/toolchain/fbtenv.sh @@ -4,7 +4,7 @@ # public variables DEFAULT_SCRIPT_PATH="$(pwd -P)"; -FBT_TOOLCHAIN_VERSION="${FBT_TOOLCHAIN_VERSION:-"37"}"; +FBT_TOOLCHAIN_VERSION="${FBT_TOOLCHAIN_VERSION:-"38"}"; if [ -z ${FBT_TOOLCHAIN_PATH+x} ] ; then FBT_TOOLCHAIN_PATH_WAS_SET=0; diff --git a/scripts/ufbt/SConstruct b/scripts/ufbt/SConstruct index 26b1046ee..18c4d1cac 100644 --- a/scripts/ufbt/SConstruct +++ b/scripts/ufbt/SConstruct @@ -403,6 +403,9 @@ for template_file in project_template_dir.Dir(".vscode").glob("*"): "@UFBT_FIRMWARE_ELF@": PosixPathWrapper.fix_path( dist_env["FW_ELF"].abspath ), + "@UFBT_TOOLCHAIN_CLANGD@": PosixPathWrapper.fix_path( + dist_env.WhereIs("clangd") + ), }, ) ) diff --git a/scripts/ufbt/project_template/.clang-format b/scripts/ufbt/project_template/.clang-format index 4b76f7fa4..ad3484ba0 100644 --- a/scripts/ufbt/project_template/.clang-format +++ b/scripts/ufbt/project_template/.clang-format @@ -3,22 +3,55 @@ Language: Cpp AccessModifierOffset: -4 AlignAfterOpenBracket: AlwaysBreak AlignArrayOfStructures: None -AlignConsecutiveMacros: None -AlignConsecutiveAssignments: None -AlignConsecutiveBitFields: None -AlignConsecutiveDeclarations: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseColons: false AlignEscapedNewlines: Left AlignOperands: Align -AlignTrailingComments: false +AlignTrailingComments: + Kind: Never + OverEmptyLines: 0 AllowAllArgumentsOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: false -AllowShortEnumsOnASingleLine: true +AllowBreakBeforeNoexceptSpecifier: Never AllowShortBlocksOnASingleLine: Never AllowShortCaseLabelsOnASingleLine: false +AllowShortCompoundRequirementOnASingleLine: true +AllowShortEnumsOnASingleLine: true AllowShortFunctionsOnASingleLine: None -AllowShortLambdasOnASingleLine: All AllowShortIfStatementsOnASingleLine: WithoutElse -AllowShortLoopsOnASingleLine: true +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false @@ -27,17 +60,18 @@ 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 - AfterExternBlock: false BeforeCatch: false BeforeElse: false BeforeLambdaBody: false @@ -46,33 +80,29 @@ BraceWrapping: SplitEmptyFunction: true SplitEmptyRecord: true SplitEmptyNamespace: true -BreakBeforeBinaryOperators: None -BreakBeforeConceptDeclarations: true -BreakBeforeBraces: Attach -BreakBeforeInheritanceComma: false -BreakInheritanceList: BeforeColon -BreakBeforeTernaryOperators: false -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeComma +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:' -QualifierAlignment: Leave CompactNamespaces: false ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true -DeriveLineEnding: true DerivePointerAlignment: false DisableFormat: false EmptyLineAfterAccessModifier: Never EmptyLineBeforeAccessModifier: LogicalBlock ExperimentalAutoDetectBinPacking: false -PackConstructorInitializers: BinPack -BasedOnStyle: '' -ConstructorInitializerAllOnOneLineOrOnePerLine: false -AllowAllConstructorInitializersOnNextLine: true FixNamespaceComments: false ForEachMacros: - foreach @@ -97,19 +127,30 @@ IncludeCategories: IncludeIsMainRegex: '(Test)?$' IncludeIsMainSourceRegex: '' IndentAccessModifiers: false -IndentCaseLabels: false IndentCaseBlocks: false +IndentCaseLabels: false +IndentExternBlock: AfterExternBlock IndentGotoLabels: true IndentPPDirectives: None -IndentExternBlock: AfterExternBlock -IndentRequires: false +IndentRequiresClause: false IndentWidth: 4 IndentWrappedFunctionNames: true +InsertBraces: false +InsertNewlineAtEOF: false 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 @@ -119,34 +160,44 @@ 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 -PenaltyReturnTypeOnItsOwnLine: 60 PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Left PPIndentWidth: -1 +QualifierAlignment: Leave ReferenceAlignment: Pointer ReflowComments: false RemoveBracesLLVM: false +RemoveParentheses: Leave +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope SeparateDefinitionBlocks: Leave ShortNamespaceLines: 1 +SkipMacroDefinitionBody: false SortIncludes: Never SortJavaStaticImport: Before -SortUsingDeclarations: false +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 @@ -155,23 +206,26 @@ SpaceBeforeParensOptions: AfterFunctionDeclarationName: false AfterIfMacros: false AfterOverloadedOperator: false + AfterPlacementOperator: true + AfterRequiresInClause: false + AfterRequiresInExpression: false BeforeNonEmptyParentheses: false -SpaceAroundPointerQualifiers: Default SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false SpaceInEmptyBlock: false -SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1 SpacesInAngles: Never -SpacesInConditionalStatement: false SpacesInContainerLiterals: false -SpacesInCStyleCastParentheses: false SpacesInLineCommentPrefix: Minimum: 1 Maximum: -1 -SpacesInParentheses: false +SpacesInParens: Never +SpacesInParensOptions: + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false SpacesInSquareBrackets: false -SpaceBeforeSquareBrackets: false -BitFieldColonSpacing: Both Standard: c++03 StatementAttributeLikeMacros: - Q_EMIT @@ -179,8 +233,8 @@ StatementMacros: - Q_UNUSED - QT_REQUIRE_VERSION TabWidth: 4 -UseCRLF: false UseTab: Never +VerilogBreakBetweenInstancePorts: true WhitespaceSensitiveMacros: - STRINGIZE - PP_STRINGIZE diff --git a/scripts/ufbt/project_template/.clangd b/scripts/ufbt/project_template/.clangd new file mode 100644 index 000000000..12e13751d --- /dev/null +++ b/scripts/ufbt/project_template/.clangd @@ -0,0 +1,17 @@ +CompileFlags: + Add: + - -Wno-unknown-warning-option + - -Wno-format + Remove: + - -mword-relocations + +Diagnostics: + ClangTidy: + FastCheckFilter: None + +--- + +If: + PathMatch: .*\.h +Diagnostics: + UnusedIncludes: None diff --git a/scripts/ufbt/project_template/.gitignore b/scripts/ufbt/project_template/.gitignore index 81a8981f7..dd6a4750d 100644 --- a/scripts/ufbt/project_template/.gitignore +++ b/scripts/ufbt/project_template/.gitignore @@ -1,6 +1,7 @@ dist/* .vscode .clang-format +.clangd .editorconfig .env .ufbt diff --git a/scripts/ufbt/project_template/.vscode/extensions.json b/scripts/ufbt/project_template/.vscode/extensions.json index 9daefb430..dc92d3bbd 100644 --- a/scripts/ufbt/project_template/.vscode/extensions.json +++ b/scripts/ufbt/project_template/.vscode/extensions.json @@ -8,7 +8,7 @@ // List of extensions which should be recommended for users of this workspace. "recommendations": [ "ms-python.black-formatter", - "ms-vscode.cpptools", + "llvm-vs-code-extensions.vscode-clangd", "amiralizadeh9480.cpp-helper", "marus25.cortex-debug", "zxh404.vscode-proto3", @@ -18,6 +18,7 @@ // List of extensions recommended by VS Code that should not be recommended for users of this workspace. "unwantedRecommendations": [ "twxs.cmake", + "ms-vscode.cpptools", "ms-vscode.cmake-tools" ] } \ No newline at end of file diff --git a/scripts/ufbt/project_template/.vscode/settings.json b/scripts/ufbt/project_template/.vscode/settings.json index ce5210f5f..d304752a9 100644 --- a/scripts/ufbt/project_template/.vscode/settings.json +++ b/scripts/ufbt/project_template/.vscode/settings.json @@ -5,7 +5,6 @@ { "cortex-debug.enableTelemetry": false, "cortex-debug.variableUseNaturalFormat": false, - "cortex-debug.showRTOS": true, "cortex-debug.armToolchainPath": "@UFBT_TOOLCHAIN_ARM_TOOLCHAIN_DIR@", "cortex-debug.openocdPath": "@UFBT_TOOLCHAIN_OPENOCD@", "cortex-debug.gdbPath": "@UFBT_TOOLCHAIN_GDB_PY@", @@ -16,9 +15,15 @@ "SConstruct": "python", "*.fam": "python" }, - "cortex-debug.registerUseNaturalFormat": false, "python.analysis.typeCheckingMode": "off", "[python]": { "editor.defaultFormatter": "ms-python.black-formatter" - } + }, + "clangd.path": "@UFBT_TOOLCHAIN_CLANGD@", + "clangd.arguments": [ + "--query-driver=**/arm-none-eabi-*", + "--compile-commands-dir=${workspaceFolder}/.vscode", + "--clang-tidy", + "--header-insertion=never" + ] } \ No newline at end of file diff --git a/site_scons/commandline.scons b/site_scons/commandline.scons index c36a9a6b6..c4c2fb5ab 100644 --- a/site_scons/commandline.scons +++ b/site_scons/commandline.scons @@ -268,7 +268,7 @@ vars.AddVariables( EnumVariable( "LANG_SERVER", help="Language server type for vscode_dist.", - default="cpptools", + default="clangd", allowed_values=[ "cpptools", "clangd", diff --git a/site_scons/site_init.py b/site_scons/site_init.py index b763a3a7c..5b297e80e 100644 --- a/site_scons/site_init.py +++ b/site_scons/site_init.py @@ -6,7 +6,6 @@ import atexit from ansi.color import fg, fx sys.path.insert(0, os.path.join(os.getcwd(), "scripts")) -sys.path.insert(0, os.path.join(os.getcwd(), "lib/cxxheaderparser")) def bf_to_str(bf):