Skip to content

Commit 6682c43

Browse files
authored
🏗 Merge C++ into python codebase (esphome#504)
## Description: Move esphome-core codebase into esphome (and a bunch of other refactors). See esphome/feature-requests#97 Yes this is a shit ton of work and no there's no way to automate it :( But it will be worth it 👍 Progress: - Core support (file copy etc): 80% - Base Abstractions (light, switch): ~50% - Integrations: ~10% - Working? Yes, (but only with ported components). Other refactors: - Moves all codegen related stuff into a single class: `esphome.codegen` (imported as `cg`) - Rework coroutine syntax - Move from `component/platform.py` to `domain/component.py` structure as with HA - Move all defaults out of C++ and into config validation. - Remove `make_...` helpers from Application class. Reason: Merge conflicts with every single new integration. - Pointer Variables are stored globally instead of locally in setup(). Reason: stack size limit. Future work: - Rework const.py - Move all `CONF_...` into a conf class (usage `conf.UPDATE_INTERVAL` vs `CONF_UPDATE_INTERVAL`). Reason: Less convoluted import block - Enable loading from `custom_components` folder. **Related issue (if applicable):** esphome/feature-requests#97 **Pull request in [esphome-docs](https://github.com/esphome/esphome-docs) with documentation (if applicable):** esphome/esphome-docs#<esphome-docs PR number goes here> ## Checklist: - [ ] The code change is tested and works locally. - [ ] Tests have been added to verify that the new code works (under `tests/` folder). If user exposed functionality or configuration variables are added/changed: - [ ] Documentation added/updated in [esphomedocs](https://github.com/OttoWinter/esphomedocs).
1 parent 049807e commit 6682c43

File tree

817 files changed

+54105
-10779
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

817 files changed

+54105
-10779
lines changed

.clang-format

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
Language: Cpp
2+
AccessModifierOffset: -1
3+
AlignAfterOpenBracket: Align
4+
AlignConsecutiveAssignments: false
5+
AlignConsecutiveDeclarations: false
6+
AlignEscapedNewlines: DontAlign
7+
AlignOperands: true
8+
AlignTrailingComments: true
9+
AllowAllParametersOfDeclarationOnNextLine: true
10+
AllowShortBlocksOnASingleLine: false
11+
AllowShortCaseLabelsOnASingleLine: false
12+
AllowShortFunctionsOnASingleLine: All
13+
AllowShortIfStatementsOnASingleLine: false
14+
AllowShortLoopsOnASingleLine: false
15+
AlwaysBreakAfterReturnType: None
16+
AlwaysBreakBeforeMultilineStrings: false
17+
AlwaysBreakTemplateDeclarations: MultiLine
18+
BinPackArguments: true
19+
BinPackParameters: true
20+
BraceWrapping:
21+
AfterClass: false
22+
AfterControlStatement: false
23+
AfterEnum: false
24+
AfterFunction: false
25+
AfterNamespace: false
26+
AfterObjCDeclaration: false
27+
AfterStruct: false
28+
AfterUnion: false
29+
AfterExternBlock: false
30+
BeforeCatch: false
31+
BeforeElse: false
32+
IndentBraces: false
33+
SplitEmptyFunction: true
34+
SplitEmptyRecord: true
35+
SplitEmptyNamespace: true
36+
BreakBeforeBinaryOperators: None
37+
BreakBeforeBraces: Attach
38+
BreakBeforeInheritanceComma: false
39+
BreakInheritanceList: BeforeColon
40+
BreakBeforeTernaryOperators: true
41+
BreakConstructorInitializersBeforeComma: false
42+
BreakConstructorInitializers: BeforeColon
43+
BreakAfterJavaFieldAnnotations: false
44+
BreakStringLiterals: true
45+
ColumnLimit: 120
46+
CommentPragmas: '^ IWYU pragma:'
47+
CompactNamespaces: false
48+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
49+
ConstructorInitializerIndentWidth: 4
50+
ContinuationIndentWidth: 4
51+
Cpp11BracedListStyle: true
52+
DerivePointerAlignment: true
53+
DisableFormat: false
54+
ExperimentalAutoDetectBinPacking: false
55+
FixNamespaceComments: true
56+
ForEachMacros:
57+
- foreach
58+
- Q_FOREACH
59+
- BOOST_FOREACH
60+
IncludeBlocks: Preserve
61+
IncludeCategories:
62+
- Regex: '^<ext/.*\.h>'
63+
Priority: 2
64+
- Regex: '^<.*\.h>'
65+
Priority: 1
66+
- Regex: '^<.*'
67+
Priority: 2
68+
- Regex: '.*'
69+
Priority: 3
70+
IncludeIsMainRegex: '([-_](test|unittest))?$'
71+
IndentCaseLabels: true
72+
IndentPPDirectives: None
73+
IndentWidth: 2
74+
IndentWrappedFunctionNames: false
75+
KeepEmptyLinesAtTheStartOfBlocks: false
76+
MacroBlockBegin: ''
77+
MacroBlockEnd: ''
78+
MaxEmptyLinesToKeep: 1
79+
NamespaceIndentation: None
80+
PenaltyBreakAssignment: 2
81+
PenaltyBreakBeforeFirstCallParameter: 1
82+
PenaltyBreakComment: 300
83+
PenaltyBreakFirstLessLess: 120
84+
PenaltyBreakString: 1000
85+
PenaltyBreakTemplateDeclaration: 10
86+
PenaltyExcessCharacter: 1000000
87+
PenaltyReturnTypeOnItsOwnLine: 2000
88+
PointerAlignment: Right
89+
RawStringFormats:
90+
- Language: Cpp
91+
Delimiters:
92+
- cc
93+
- CC
94+
- cpp
95+
- Cpp
96+
- CPP
97+
- 'c++'
98+
- 'C++'
99+
CanonicalDelimiter: ''
100+
BasedOnStyle: google
101+
- Language: TextProto
102+
Delimiters:
103+
- pb
104+
- PB
105+
- proto
106+
- PROTO
107+
EnclosingFunctions:
108+
- EqualsProto
109+
- EquivToProto
110+
- PARSE_PARTIAL_TEXT_PROTO
111+
- PARSE_TEST_PROTO
112+
- PARSE_TEXT_PROTO
113+
- ParseTextOrDie
114+
- ParseTextProtoOrDie
115+
CanonicalDelimiter: ''
116+
BasedOnStyle: google
117+
ReflowComments: true
118+
SortIncludes: false
119+
SortUsingDeclarations: false
120+
SpaceAfterCStyleCast: true
121+
SpaceAfterTemplateKeyword: false
122+
SpaceBeforeAssignmentOperators: true
123+
SpaceBeforeCpp11BracedList: false
124+
SpaceBeforeCtorInitializerColon: true
125+
SpaceBeforeInheritanceColon: true
126+
SpaceBeforeParens: ControlStatements
127+
SpaceBeforeRangeBasedForLoopColon: true
128+
SpaceInEmptyParentheses: false
129+
SpacesBeforeTrailingComments: 2
130+
SpacesInAngles: false
131+
SpacesInContainerLiterals: false
132+
SpacesInCStyleCastParentheses: false
133+
SpacesInParentheses: false
134+
SpacesInSquareBrackets: false
135+
Standard: Auto
136+
TabWidth: 2
137+
UseTab: Never

.clang-tidy

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
Checks: >-
3+
*,
4+
-abseil-*,
5+
-android-*,
6+
-boost-*,
7+
-bugprone-macro-parentheses,
8+
-cert-dcl50-cpp,
9+
-cert-err58-cpp,
10+
-clang-analyzer-core.CallAndMessage,
11+
-clang-analyzer-osx.*,
12+
-clang-analyzer-security.*,
13+
-cppcoreguidelines-avoid-goto,
14+
-cppcoreguidelines-c-copy-assignment-signature,
15+
-cppcoreguidelines-owning-memory,
16+
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
17+
-cppcoreguidelines-pro-bounds-constant-array-index,
18+
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
19+
-cppcoreguidelines-pro-type-const-cast,
20+
-cppcoreguidelines-pro-type-cstyle-cast,
21+
-cppcoreguidelines-pro-type-member-init,
22+
-cppcoreguidelines-pro-type-reinterpret-cast,
23+
-cppcoreguidelines-pro-type-static-cast-downcast,
24+
-cppcoreguidelines-pro-type-union-access,
25+
-cppcoreguidelines-pro-type-vararg,
26+
-cppcoreguidelines-special-member-functions,
27+
-fuchsia-*,
28+
-fuchsia-default-arguments,
29+
-fuchsia-multiple-inheritance,
30+
-fuchsia-overloaded-operator,
31+
-fuchsia-statically-constructed-objects,
32+
-google-build-using-namespace,
33+
-google-explicit-constructor,
34+
-google-readability-braces-around-statements,
35+
-google-readability-casting,
36+
-google-readability-todo,
37+
-google-runtime-int,
38+
-google-runtime-references,
39+
-hicpp-*,
40+
-llvm-header-guard,
41+
-llvm-include-order,
42+
-misc-unconventional-assign-operator,
43+
-misc-unused-parameters,
44+
-modernize-deprecated-headers,
45+
-modernize-pass-by-value,
46+
-modernize-pass-by-value,
47+
-modernize-return-braced-init-list,
48+
-modernize-use-auto,
49+
-modernize-use-default-member-init,
50+
-modernize-use-equals-default,
51+
-mpi-*,
52+
-objc-*,
53+
-performance-unnecessary-value-param,
54+
-readability-braces-around-statements,
55+
-readability-else-after-return,
56+
-readability-implicit-bool-conversion,
57+
-readability-named-parameter,
58+
-readability-redundant-member-init,
59+
-warnings-as-errors,
60+
-zircon-*
61+
WarningsAsErrors: '*'
62+
HeaderFilterRegex: '^.*/src/esphome/.*'
63+
AnalyzeTemporaryDtors: false
64+
FormatStyle: google
65+
CheckOptions:
66+
- key: google-readability-braces-around-statements.ShortStatementLines
67+
value: '1'
68+
- key: google-readability-function-size.StatementThreshold
69+
value: '800'
70+
- key: google-readability-namespace-comments.ShortNamespaceLines
71+
value: '10'
72+
- key: google-readability-namespace-comments.SpacesBeforeComments
73+
value: '2'
74+
- key: modernize-loop-convert.MaxCopySize
75+
value: '16'
76+
- key: modernize-loop-convert.MinConfidence
77+
value: reasonable
78+
- key: modernize-loop-convert.NamingStyle
79+
value: CamelCase
80+
- key: modernize-pass-by-value.IncludeStyle
81+
value: llvm
82+
- key: modernize-replace-auto-ptr.IncludeStyle
83+
value: llvm
84+
- key: modernize-use-nullptr.NullMacros
85+
value: 'NULL'
86+
- key: readability-identifier-naming.LocalVariableCase
87+
value: 'lower_case'
88+
- key: readability-identifier-naming.ClassCase
89+
value: 'CamelCase'
90+
- key: readability-identifier-naming.StructCase
91+
value: 'CamelCase'
92+
- key: readability-identifier-naming.EnumCase
93+
value: 'CamelCase'
94+
- key: readability-identifier-naming.EnumConstantCase
95+
value: 'UPPER_CASE'
96+
- key: readability-identifier-naming.StaticConstantCase
97+
value: 'UPPER_CASE'
98+
- key: readability-identifier-naming.StaticVariableCase
99+
value: 'UPPER_CASE'
100+
- key: readability-identifier-naming.GlobalConstantCase
101+
value: 'UPPER_CASE'
102+
- key: readability-identifier-naming.ParameterCase
103+
value: 'lower_case'
104+
- key: readability-identifier-naming.PrivateMemberPrefix
105+
value: 'NO_PRIVATE_MEMBERS_ALWAYS_USE_PROTECTED'
106+
- key: readability-identifier-naming.PrivateMethodPrefix
107+
value: 'NO_PRIVATE_METHODS_ALWAYS_USE_PROTECTED'
108+
- key: readability-identifier-naming.ClassMemberCase
109+
value: 'lower_case'
110+
- key: readability-identifier-naming.ClassMemberCase
111+
value: 'lower_case'
112+
- key: readability-identifier-naming.ProtectedMemberCase
113+
value: 'lower_case'
114+
- key: readability-identifier-naming.ProtectedMemberSuffix
115+
value: '_'
116+
- key: readability-identifier-naming.FunctionCase
117+
value: 'lower_case'
118+
- key: readability-identifier-naming.ClassMethodCase
119+
value: 'lower_case'
120+
- key: readability-identifier-naming.ProtectedMethodCase
121+
value: 'lower_case'
122+
- key: readability-identifier-naming.ProtectedMethodSuffix
123+
value: '_'
124+
- key: readability-identifier-naming.VirtualMethodCase
125+
value: 'lower_case'
126+
- key: readability-identifier-naming.VirtualMethodSuffix
127+
value: ''

.gitignore

+37-43
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ wheels/
2525
*.egg
2626
MANIFEST
2727

28-
# PyInstaller
29-
# Usually these files are written by a python script from a template
30-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31-
*.manifest
32-
*.spec
33-
3428
# Installer logs
3529
pip-log.txt
3630
pip-delete-this-directory.txt
@@ -51,36 +45,9 @@ coverage.xml
5145
*.mo
5246
*.pot
5347

54-
# Django stuff:
55-
*.log
56-
local_settings.py
57-
db.sqlite3
58-
59-
# Flask stuff:
60-
instance/
61-
.webassets-cache
62-
63-
# Scrapy stuff:
64-
.scrapy
65-
66-
# Sphinx documentation
67-
docs/_build/
68-
69-
# PyBuilder
70-
target/
71-
72-
# Jupyter Notebook
73-
.ipynb_checkpoints
74-
7548
# pyenv
7649
.python-version
7750

78-
# celery beat schedule file
79-
celerybeat-schedule
80-
81-
# SageMath parsed files
82-
*.sage.py
83-
8451
# Environments
8552
.env
8653
.venv
@@ -90,19 +57,46 @@ ENV/
9057
env.bak/
9158
venv.bak/
9259

93-
# Spyder project settings
94-
.spyderproject
95-
.spyproject
96-
97-
# Rope project settings
98-
.ropeproject
99-
100-
# mkdocs documentation
101-
/site
102-
10360
# mypy
10461
.mypy_cache/
10562

63+
.pioenvs
64+
.piolibdeps
65+
.vscode
66+
CMakeListsPrivate.txt
67+
CMakeLists.txt
68+
69+
# User-specific stuff:
70+
.idea/**/workspace.xml
71+
.idea/**/tasks.xml
72+
.idea/dictionaries
73+
74+
# Sensitive or high-churn files:
75+
.idea/**/dataSources/
76+
.idea/**/dataSources.ids
77+
.idea/**/dataSources.xml
78+
.idea/**/dataSources.local.xml
79+
.idea/**/dynamic.xml
80+
81+
# CMake
82+
cmake-build-debug/
83+
cmake-build-release/
84+
85+
CMakeCache.txt
86+
CMakeFiles
87+
CMakeScripts
88+
Testing
89+
Makefile
90+
cmake_install.cmake
91+
install_manifest.txt
92+
compile_commands.json
93+
CTestTestfile.cmake
94+
/*.cbp
95+
96+
.clang_complete
97+
.gcc-flags.json
98+
10699
config/
107100
tests/build/
108101
tests/.esphome/
102+
/.temp-clang-tidy.cpp

0 commit comments

Comments
 (0)