Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix release name macro expansion #4309

Open
wants to merge 2 commits into
base: 0_15
Choose a base branch
from

Conversation

netmindz
Copy link
Collaborator

Fix for #4260

@netmindz netmindz added this to the 0.15.0-final candidate milestone Nov 23, 2024
@netmindz netmindz marked this pull request as ready for review November 23, 2024 16:09
@netmindz netmindz changed the title Swap release name to avoid macro expansion Fix release name macro expansion Nov 23, 2024
@softhack007
Copy link
Collaborator

Error: The path for one of the files in artifact is not valid: /WLED_0.15.0-b7_"ESP8266".bin. Contains the following character: Double quote "

@netmindz I think output_bins.py needs to be adjusted - might be that simply deleting any " and ' from the release_name before copy files might be sufficient.

@@ -19,7 +19,7 @@ def _create_dirs(dirs=["map", "release", "firmware"]):
os.makedirs(os.path.join(OUTPUT_DIR, d), exist_ok=True)

def create_release(source):
release_name = _get_cpp_define_value(env, "WLED_RELEASE_NAME")
release_name = _get_cpp_define_value(env, "WLED_RELEASE_NAME").replace("\\\"", "")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quote stripping needs to be inside the if below, in case it's not defined and _get_cpp_define_value returns None.

@blazoncek
Copy link
Collaborator

I'm wondering what's wrong with stringification? https://gcc.gnu.org/onlinedocs/gcc-4.8.5/cpp/Stringification.html

There are some other places that use TOSTRING() too.

@willmmiles
Copy link
Collaborator

I'm wondering what's wrong with stringification? https://gcc.gnu.org/onlinedocs/gcc-4.8.5/cpp/Stringification.html

There are some other places that use TOSTRING() too.

It macro-expands recursively -- there is no way to expand exactly once. Eg: -DESP32=Stuff -D WLED_RELEASE_NAME=ESP32 means that TOSTRING(WLED_RELEASE_NAME) expands to "Stuff" -- eg WLED_RELEASE_NAME->ESP32->Stuff. Since ESP32 happens to be #defined somewhere (FastLED, if nowhere else!), it expands to something unhelpful before it's converted to a string literal.

@blazoncek
Copy link
Collaborator

It macro-expands recursively -- there is no way to expand exactly once. Eg: -DESP32=Stuff -D WLED_RELEASE_NAME=ESP32 means that TOSTRING(WLED_RELEASE_NAME) expands to "Stuff" -- eg WLED_RELEASE_NAME->ESP32->Stuff. Since ESP32 happens to be #defined somewhere (FastLED, if nowhere else!), it expands to something unhelpful before it's converted to a string literal.

That explains 1 seen in builds.

So the simplest solution is to use something unique that has no ordinary/recursive counterpart. I.e. rename "ESP32" with "ESP32plain" in platformio.ini. IMO that's acceptable as no previous builds have "ESP32" (or "ESP8266") compiled in due to the recursion flaw.

This (adding unique WLED_RELEASE_NAME) would also help differentiate builds @Moustachauve wants to implement in his mobile app.

@netmindz
Copy link
Collaborator Author

It macro-expands recursively -- there is no way to expand exactly once. Eg: -DESP32=Stuff -D WLED_RELEASE_NAME=ESP32 means that TOSTRING(WLED_RELEASE_NAME) expands to "Stuff" -- eg WLED_RELEASE_NAME->ESP32->Stuff. Since ESP32 happens to be #defined somewhere (FastLED, if nowhere else!), it expands to something unhelpful before it's converted to a string literal.

That explains 1 seen in builds.

So the simplest solution is to use something unique that has no ordinary/recursive counterpart. I.e. rename "ESP32" with "ESP32plain" in platformio.ini. IMO that's acceptable as no previous builds have "ESP32" (or "ESP8266") compiled in due to the recursion flaw.

This (adding unique WLED_RELEASE_NAME) would also help differentiate builds @Moustachauve wants to implement in his mobile app.

My initial version of this PR changed the value to be WLED_ESP32, the removed the hard coded WLED from the rename python script, but that's a bigger change, hence swapping to @willmmiles suggestion for a smaller change

@blazoncek
Copy link
Collaborator

Or perhaps just:

#ifndef WLED_RELEASE_NAME
  #define WLED_RELEASE_NAME dev_release
#else
  #if WLED_RELEASE_NAME == ESP32 || WLED_RELEASE_NAME == ESP8266
    #error Wrong WLED_RELEASE_NAME.
  #endif
#endif

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.

4 participants