My Home-IoT
Find a file
Andrew Zaborowski c7c71089ce
codegen: Lambda improvements (#1476)
* Use #line directives in generated C++ code for lambdas

The #line directive in gcc is meant specifically for pieces of imported
code included in generated code, exactly what happens with lambdas in
the yaml files: https://gcc.gnu.org/onlinedocs/cpp/Line-Control.html

With this change, if I add the following at line 165 of kithen.yaml:
    - lambda: undefined_var == 5;

then "$ esphome kitchen.yaml compile" shows the following:

INFO Reading configuration kitchen.yaml...
INFO Generating C++ source...
INFO Compiling app...
INFO Running:  platformio run -d kitchen
<...>
Compiling .pioenvs/kitchen/src/main.cpp.o
kitchen.yaml: In lambda function:
kitchen.yaml:165:7: error: 'undefined_var' was not declared in this scope
*** [.pioenvs/kitchen/src/main.cpp.o] Error 1
== [FAILED] Took 2.37 seconds ==

* Silence gcc warning on multiline macros in lambdas

When the \ is used at the end of the C++ source in a lambda (line
continuation, often used in preprocessor macros), esphome will copy that
into main.cpp once as code and once as a // commment.  gcc will complain
about the multiline commment:

Compiling .pioenvs/kitchen/src/main.cpp.o
kitchen.yaml:640:3: warning: multi-line comment [-Wcomment]

Try to replace the \ with a "<cont>" for lack of a better idea.
2021-01-23 20:17:15 -03:00
.devcontainer Add lambda to devcontainer config (#1059) 2020-05-19 21:02:10 -03:00
.github Update actions to move away from set-env (#1349) 2020-11-02 11:49:08 +13:00
.vscode Run task for VS Code (#1361) 2020-12-13 16:24:26 -03:00
docker Expose port 6052 in Dockerfile (#1437) 2020-12-30 22:58:09 +13:00
esphome codegen: Lambda improvements (#1476) 2021-01-23 20:17:15 -03:00
script Add rc522 (#1298) 2020-10-27 12:41:57 +13:00
tests add http request tests (#1448) 2021-01-23 19:44:20 -03:00
.clang-format 🏗 Merge C++ into python codebase (#504) 2019-04-17 12:06:00 +02:00
.clang-tidy 🏗 Merge C++ into python codebase (#504) 2019-04-17 12:06:00 +02:00
.coveragerc Unittests for esphome python code (#931) 2020-03-12 14:27:22 -07:00
.dockerignore Fix docker build 2018-09-25 10:30:45 +02:00
.editorconfig Formatted test yaml files (#1382) 2020-11-19 23:59:19 -03:00
.gitignore Run task for VS Code (#1361) 2020-12-13 16:24:26 -03:00
.gitpod.yml extract and use current version of python 3 (#938) 2020-01-09 13:27:39 -08:00
.pre-commit-config.yaml Bugfix/normalize core comparisons (and Python 3 update fixes) (#952) 2020-01-13 14:35:55 -08:00
CODE_OF_CONDUCT.md Add Code of Conduct (Contributor Covenant) (#168) 2018-10-12 11:26:26 +02:00
CODEOWNERS Inkplate 6 support for ESPHome (#1283) 2021-01-16 13:19:35 +13:00
CONTRIBUTING.md Rename esphomeyaml to esphome (#426) 2019-02-13 16:54:02 +01:00
LICENSE 🏗 Merge C++ into python codebase (#504) 2019-04-17 12:06:00 +02:00
MANIFEST.in Fix sdist missing requirements.txt (#1214) 2020-07-28 14:29:01 +02:00
platformio.ini Bump ESPAsyncTCP from 1.2.2 to 1.2.3 (#1227) 2020-07-30 11:38:57 +02:00
pylintrc Revert "Sort keys in dicts in output yaml for 'config' command (#1049)" (#1191) 2020-07-25 14:21:56 +02:00
pytest.ini Unittests for esphome python code (#931) 2020-03-12 14:27:22 -07:00
README.md Update README.md 2019-02-14 13:49:22 +01:00
requirements.txt Bump voluptuous from 0.12.0 to 0.12.1 (#1411) 2021-01-12 23:53:35 -03:00
requirements_test.txt Bump pytest-mock from 3.3.1 to 3.5.1 (#1458) 2021-01-12 10:12:25 -03:00
setup.cfg Bugfix/normalize core comparisons (and Python 3 update fixes) (#952) 2020-01-13 14:35:55 -08:00
setup.py Improve setup.py 2020-07-24 10:35:07 +02:00

ESPHome Build Status Discord Chat GitHub release

ESPHome Logo

Documentation: https://esphome.io/

For issues, please go to the issue tracker.

For feature requests, please see feature requests.