What kind of issue is this?
Configuration
Operating system: Win10 x64
PlatformIO Version (platformio --version): 6.0.2
Description of problem
When writing a library, it sometimes is necessary to affect build settings of the projenv environment which is used to build the src/ folder. Such as in this example, where the inclusion of the library should cause all -fno-rtti flags to vanish.
This is only partially possible in the extraScript of a library. Using e.g. as script
Import("env")
global_env = DefaultEnvironment()
for e in (env, global_env):
try:
# key may or may not exist
e['CXXFLAGS'].remove("-fno-rtti")
except:
pass
e['CXXFLAGS'].append("-frtti")
leads to all -fno-rtti flags being removed in the library and framework compilation, but not for the files in src/. This is because the Arduino-ESP8266 adds them back in after it was executed, which the library build script cannot affect.
{
"name": "MyLib",
"version": "1.0.0",
"build": {
"unflags": "-fno-rtti"
}
}
does not work either.
Of course, build_unflags = -fno-rtti can be set in the platformio.ini to counter this, but then the user has to do an extra step when including the library.
Another use case is e.g. this library where users are being told to add extra_script to their platformio.ini that points into the library, because the library.json has no mechanism for post and pre scripts.
lib_deps =
https://github.com/likeablob/ulptool-pio
extra_scripts =
pre:/$PROJECT_LIBDEPS_DIR/$PIOENV/ulptool-pio/pre_extra_script_ulptool.py
post:/$PROJECT_LIBDEPS_DIR/$PIOENV/ulptool-pio/post_extra_script_ulptool.py
It would be nice to specify pre: and post: in the extraScripts field / array of the library.json to allow this better without user interaction.
Steps to Reproduce
- Download and open https://github.com/maxgerhardt/rtti-repro
- Inspect
lib/MyLib/with_rtti.py
- Build project
Actual Results
Compilation failure, -fno-rtti not fully removed.
src\main.cpp: In function 'void setup()':
src\main.cpp:12:40: error: cannot use 'typeid' with '-fno-rtti'
12 | const std::type_info& ti1 = typeid(d);
| ^
Expected Results
Possibility to affect src/ compilation in extraScript, e.g. removing build flags added by later framework builder scripts.
If problems with PlatformIO Build System:
See linked project.
Additional info
-/-
What kind of issue is this?
Start by telling us what problem you’re trying to solve. Often a solution
already exists! Don’t send pull requests to implement new features without first getting our
support. Sometimes we leave features out on purpose to keep the project small.
Configuration
Operating system: Win10 x64
PlatformIO Version (
platformio --version): 6.0.2Description of problem
When writing a library, it sometimes is necessary to affect build settings of the
projenvenvironment which is used to build thesrc/folder. Such as in this example, where the inclusion of the library should cause all-fno-rttiflags to vanish.This is only partially possible in the
extraScriptof a library. Using e.g. as scriptleads to all
-fno-rttiflags being removed in the library and framework compilation, but not for the files insrc/. This is because the Arduino-ESP8266 adds them back in after it was executed, which the library build script cannot affect.{ "name": "MyLib", "version": "1.0.0", "build": { "unflags": "-fno-rtti" } }does not work either.
Of course,
build_unflags = -fno-rttican be set in theplatformio.inito counter this, but then the user has to do an extra step when including the library.Another use case is e.g. this library where users are being told to add
extra_scriptto theirplatformio.inithat points into the library, because thelibrary.jsonhas no mechanism for post and pre scripts.It would be nice to specify
pre:andpost:in theextraScriptsfield / array of thelibrary.jsonto allow this better without user interaction.Steps to Reproduce
lib/MyLib/with_rtti.pyActual Results
Compilation failure,
-fno-rttinot fully removed.Expected Results
Possibility to affect
src/compilation inextraScript, e.g. removing build flags added by later framework builder scripts.If problems with PlatformIO Build System:
See linked project.
Additional info
-/-