Skip to content

spread common defs to all targets#18

Merged
erhankur merged 1 commit intoespressif:masterfrom
antmak:defs_for_targets
May 28, 2025
Merged

spread common defs to all targets#18
erhankur merged 1 commit intoespressif:masterfrom
antmak:defs_for_targets

Conversation

@antmak
Copy link
Copy Markdown
Collaborator

@antmak antmak commented May 27, 2025

  • adds a top level add_compile_definitions() instead of many target_compile_definitions() for every chip

@github-actions
Copy link
Copy Markdown

Messages
📖 🎉 Good Job! All checks are passing!

👋 Hello antmak, we appreciate your contribution to this project!


Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫 dangerJS against 4a8c2ac

@erhankur
Copy link
Copy Markdown
Collaborator

@antmak In the modern cmake preferred way to have target specific commands. In the changelist, I didn't see many lines removed for every chip. Could you explain what is wrong with the existing command?

@antmak
Copy link
Copy Markdown
Collaborator Author

antmak commented May 27, 2025

@erhankur Before the adding, we have the next command line for building a target's object

[1/3] /home/mak/.espressif/tools/riscv32-esp-elf/esp-14.2.0_20241119/riscv32-esp-elf/bin/riscv32-esp-elf-gcc  -I/home/mak/e/p/flasher-stub/oocd5/contrib/loaders/flash/espressif/esp-stub-lib/include -I/home/mak/e/p/flasher-stub/oocd5/contrib/loaders/flash/espressif/esp-stub-lib/include/esp-stub-lib -I/home/mak/e/p/flasher-stub/oocd5/contrib/loaders/flash/espressif/esp-stub-lib/src/esp32c3/include -Wall -Werror -Wextra -Wshadow -Wundef -Wconversion -Os -nostdlib -fno-builtin -fno-common -g -ffunction-sections -fdata-sections -std=gnu17 -flto -MD -MT esp-stub-lib/esp32c3/CMakeFiles/esp32c3.dir/src/flash.c.obj -MF esp-stub-lib/esp32c3/CMakeFiles/esp32c3.dir/src/flash.c.obj.d -o esp-stub-lib/esp32c3/CMakeFiles/esp32c3.dir/src/flash.c.obj -c /home/mak/e/p/flasher-stub/oocd5/contrib/loaders/flash/espressif/esp-stub-lib/src/esp32c3/src/flash.c

You can see no any -DSTUB_LOG_ENABLED, and if we would add including <log.h> STUB_LOGE will not work.

So we need adding the defs for every target on the low level:

[1/4] /home/mak/.espressif/tools/riscv32-esp-elf/esp-14.2.0_20241119/riscv32-esp-elf/bin/riscv32-esp-elf-gcc -DSTUB_LIB_LOG_UART -DSTUB_LOG_ENABLED -I/home/mak/e/p/flasher-stub/oocd5/contrib/loaders/flash/espressif/esp-stub-lib/include -I/home/mak/e/p/flasher-stub/oocd5/contrib/loaders/flash/espressif/esp-stub-lib/include/esp-stub-lib -I/home/mak/e/p/flasher-stub/oocd5/contrib/loaders/flash/espressif/esp-stub-lib/src/esp32c3/include -Wall -Werror -Wextra -Wshadow -Wundef -Wconversion -Os -nostdlib -fno-builtin -fno-common -g -ffunction-sections -fdata-sections -std=gnu17 -flto -MD -MT esp-stub-lib/esp32c3/CMakeFiles/esp32c3.dir/src/flash.c.obj -MF esp-stub-lib/esp32c3/CMakeFiles/esp32c3.dir/src/flash.c.obj.d -o esp-stub-lib/esp32c3/CMakeFiles/esp32c3.dir/src/flash.c.obj -c /home/mak/e/p/flasher-stub/oocd5/contrib/loaders/flash/espressif/esp-stub-lib/src/esp32c3/src/flash.c

I used add_compile_definitions rather than multiple target_compile_definitions in every src/<chip>/CMakeLists.txt. We already use

include_directories(include)
include_directories(include/esp-stub-lib)

next to the change, with similar semantic.

So you think we need to add the explicit target_compile_definitions(${ESP_TARGET_LIB} STUB_LIB_DEFS) into every <chip>/CMakeLists.txt?

@erhankur
Copy link
Copy Markdown
Collaborator

Thank. Got it. That’s the issue we discussed earlier. Using a global makes sense here. Later, we can consider adding a setup_target() function to eliminate all the repeated patterns.

@erhankur erhankur merged commit 067e5d8 into espressif:master May 28, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants