Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

MBED_CONF_RTOS_PRESENT incorrectly pass to in-tree static library or conversely #407

Open
ccli8 opened this issue Dec 27, 2024 · 2 comments

Comments

@ccli8
Copy link

ccli8 commented Dec 27, 2024

MBED_CONF_RTOS_PRESENT is defined in mbed-rtos-flags. For libraries which need to distinguish between mbed-os or mbed-bardmetal build, e.g. ESP8266Interface.h, they need to determine to link mbed-rtos-flags to get in MBED_CONF_RTOS_PRESENT (for linking mbed-os) or not (for linking mbed-baremetal). But only application-level CMakeLists.txt knows which of mbed-os and mbed-baremetal is linked, and this information isn't passed to these libraries which rely on MBED_CONF_RTOS_PRESENT. This will generate such error: application linking mbed-baremetal but libraries having MBED_CONF_RTOS_PRESENT definedㄝor conversely.

One rough fix is these libraries all link mbed-core-flags and let application-level CMakeLists.txt determine to link mbed-rtos-flags additionally for these libraries. But this fix isn't compatible and isn't easy to apply.

ccli8 added a commit to ccli8/NuMaker-mbed-ce-lorawan-example that referenced this issue Dec 27, 2024
1.  Common change for migration to Mbed CE from Mbed CLI 1/2
    (1) Remove *.lib originally for library import. Replace with git submodule.
    (2) Rename mbed_app.json/mbed_lib.json to mbed_app.json5/mbed_lib.json5
    (3) Add/update CMakeLists.txt
    (4) Remove .mbedignore originally for Mbed CLI 1
    (5) Update document
2.  Support VS Code development
3.  Temporary fix to build profile inconsistent with mbed-lora library build
    See: mbed-ce/mbed-os#407
@multiplemonomials
Copy link
Collaborator

One rough fix is these libraries all link mbed-core-flags and let application-level CMakeLists.txt determine to link mbed-rtos-flags additionally for these libraries. But this fix isn't compatible and isn't easy to apply.

Yeah, that's basically what I have done until now. But honestly, it's an ugly way to do it, and it can cause a lot of unexpected issues.

I've been seriously considering just making it so a given project is set to "baremetal mode" or "OS mode" and then that globally controls whether mbed-core-flags and mbed-rtos-flags are linked together or not. That would remove the ability to have some apps build with baremetal and others build with OS within a single project. But honestly, I am not sure anyone is actually using that feature.

So basically, I'd accept a PR to fix this mess by only having one of mbed-baremetal or mbed-os active at a time, set by a JSON option.

@ccli8
Copy link
Author

ccli8 commented Dec 30, 2024

That would remove the ability to have some apps build with baremetal and others build with OS within a single project. But honestly, I am not sure anyone is actually using that feature.

This feature needs two build modes at the same time for single static library, like mbed-os and mbed-baremetal. But currently these static libraries only have single build mode: either mbed-core-flags or mbed-core-flags/mbed-rtos-flags exclusively. So I think this feature can be not taken into account, except these static libraries also support two build modes simultanelusly.

ccli8 added a commit to ccli8/NuMaker-mbed-ce-lorawan-example that referenced this issue Dec 30, 2024
1.  Common change for migration to Mbed CE from Mbed CLI 1/2
    (1) Remove *.lib originally for library import. Replace with git submodule.
    (2) Rename mbed_app.json/mbed_lib.json to mbed_app.json5/mbed_lib.json5
    (3) Add/update CMakeLists.txt
    (4) Remove .mbedignore originally for Mbed CLI 1
    (5) Update document
2.  Support VS Code development
3.  Temporary fix to build profile inconsistent with mbed-lora library build
    See: mbed-ce/mbed-os#407
ccli8 added a commit to ccli8/NuMaker-mbed-ce-lorawan-example that referenced this issue Jan 10, 2025
1.  Common change for migration to Mbed CE from Mbed CLI 1/2
    (1) Remove *.lib originally for library import. Replace with git submodule.
    (2) Rename mbed_app.json/mbed_lib.json to mbed_app.json5/mbed_lib.json5
    (3) Add/update CMakeLists.txt
    (4) Remove .mbedignore originally for Mbed CLI 1
    (5) Update document
2.  Support VS Code development
3.  Temporary fix to build profile inconsistent with mbed-lora library build
    See: mbed-ce/mbed-os#407
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants