You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "xuxin930 (via GitHub)" <gi...@apache.org> on 2024/04/26 11:33:52 UTC

[PR] cmake:bugfix generate config.h contain ; characters will be handled incorrectly [nuttx]

xuxin930 opened a new pull request, #12237:
URL: https://github.com/apache/nuttx/pull/12237

   ## Summary
   ### Issue
   `;` is treated as a list separator in CMake.
   when setting a configuration similar to the following,
   an error will occur when generating config.h
   ```
   CONFIG_LV_TXT_BREAK_CHARS " ,.;:-_)]}"
   ```
   > [!CAUTION]
   > This header file is completely wrong from line 237 onwards
   ![img_v2_cfa97d61-86f3-43ff-b771-3be50c2602dl](https://github.com/apache/nuttx/assets/31881278/38687fbe-f00c-4b52-bd47-a0ffdd3bf2a7)
   
   ### Reason
   
   This is because the file(STRING) function will read the wrong .config value line.
   and  string(REGEX REPLACE) will also incorrectly handle lines containing `;` .
   
   ### Solution
   
   I changed the reading process to parse the entire .config as a big string.
   parse each line character by character.
   when there is a special character `;` , it is treated as a list and finally spliced.
   
   ## Impact
   
   ## Testing
   CI build
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] cmake:bugfix generate config.h contain ; characters will be handled incorrectly [nuttx]

Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on PR #12237:
URL: https://github.com/apache/nuttx/pull/12237#issuecomment-2081271700

   This issue not caused by `';'` character, which should be `foreach()` treated close bracket ` ']' ` as a regular expression:
   https://stackoverflow.com/questions/26057678/escape-characters-in-a-semicolon-separated-list-in-cmake
   https://cmake.org/pipermail/cmake/2016-March/063030.html
   
   @xuxin930 try this patch to check if there is any improvement.
   ```
   diff --git a/cmake/nuttx_mkconfig.cmake b/cmake/nuttx_mkconfig.cmake
   index fc040eb840..88353e2042 100644
   --- a/cmake/nuttx_mkconfig.cmake
   +++ b/cmake/nuttx_mkconfig.cmake
   @@ -92,7 +92,11 @@ file(APPEND ${CONFIG_H}
    file(APPEND ${CONFIG_H} "#define CONFIG_BASE_DEFCONFIG \"${BASE_DEFCONFIG}\"\n")
    
    file(STRINGS ${CMAKE_BINARY_DIR}/.config ConfigContents)
   +STRING(REGEX REPLACE "\\[" "__OPEN_BRACKET__" ConfigContents "${ConfigContents}")
   +STRING(REGEX REPLACE "\\]" "__CLOSE_BRACKET__" ConfigContents "${ConfigContents}")
    foreach(NameAndValue ${ConfigContents})
   +  STRING(REGEX REPLACE "__OPEN_BRACKET__" "[" NameAndValue "${NameAndValue}")
   +  STRING(REGEX REPLACE "__CLOSE_BRACKET__" "]" NameAndValue "${NameAndValue}")
      string(REGEX REPLACE "^[ ]+" "" NameAndValue ${NameAndValue})
      string(REGEX MATCH "^CONFIG[^=]+" NAME ${NameAndValue})
      # skip BASE_DEFCONFIG here as it is handled above
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] cmake:bugfix generate config.h contain ; characters will be handled incorrectly [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #12237:
URL: https://github.com/apache/nuttx/pull/12237#discussion_r1581746512


##########
cmake/nuttx_mkconfig.cmake:
##########
@@ -91,13 +91,21 @@ file(APPEND ${CONFIG_H}
      "/* General Definitions ***********************************/\n")
 file(APPEND ${CONFIG_H} "#define CONFIG_BASE_DEFCONFIG \"${BASE_DEFCONFIG}\"\n")
 
-file(STRINGS ${CMAKE_BINARY_DIR}/.config ConfigContents)
-foreach(NameAndValue ${ConfigContents})
+function(process_individual_rows)
+  set(NameAndValue ${ARGN})
+  list(LENGTH NameAndValue LENGTH_RESULT)

Review Comment:
   let's keep the naming style consistent (NameAndValue, LENGTH_RESULT, configFileContent).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] cmake:bugfix generate config.h contain ; characters will be handled incorrectly [nuttx]

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on PR #12237:
URL: https://github.com/apache/nuttx/pull/12237#issuecomment-2079523955

   @xuxin930 nice description of a problem and its solution! Kudos!!!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] cmake:bugfix generate config.h contain ; characters will be handled incorrectly [nuttx]

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis merged PR #12237:
URL: https://github.com/apache/nuttx/pull/12237


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] cmake:bugfix generate config.h contain ; characters will be handled incorrectly [nuttx]

Posted by "xuxin930 (via GitHub)" <gi...@apache.org>.
xuxin930 commented on PR #12237:
URL: https://github.com/apache/nuttx/pull/12237#issuecomment-2079220087

   Hi @anchao @XuNeo 
   please help review whether this is correct 🙏


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] cmake:bugfix generate config.h contain ; characters will be handled incorrectly [nuttx]

Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao commented on PR #12237:
URL: https://github.com/apache/nuttx/pull/12237#issuecomment-2079579844

   Is there any other way? This implementation seems complex and ugly,have you tried this config in zephyr build system?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] cmake:bugfix generate config.h contain ; characters will be handled incorrectly [nuttx]

Posted by "xuxin930 (via GitHub)" <gi...@apache.org>.
xuxin930 commented on code in PR #12237:
URL: https://github.com/apache/nuttx/pull/12237#discussion_r1582896606


##########
cmake/nuttx_mkconfig.cmake:
##########
@@ -91,13 +91,21 @@ file(APPEND ${CONFIG_H}
      "/* General Definitions ***********************************/\n")
 file(APPEND ${CONFIG_H} "#define CONFIG_BASE_DEFCONFIG \"${BASE_DEFCONFIG}\"\n")
 
-file(STRINGS ${CMAKE_BINARY_DIR}/.config ConfigContents)
-foreach(NameAndValue ${ConfigContents})
+function(process_individual_rows)
+  set(NameAndValue ${ARGN})
+  list(LENGTH NameAndValue LENGTH_RESULT)

Review Comment:
   > let's keep the naming style consistent (NameAndValue, LENGTH_RESULT, configFileContent).
   
   I changed the implementation, please review 🙏
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] cmake:bugfix generate config.h contain ; characters will be handled incorrectly [nuttx]

Posted by "xuxin930 (via GitHub)" <gi...@apache.org>.
xuxin930 commented on PR #12237:
URL: https://github.com/apache/nuttx/pull/12237#issuecomment-2082478592

   > @xuxin930 nice description of a problem and its solution! Kudos!!!
   
   @acassis thank you very much for your encouragement, I will continue to be as clear as possible when dealing with issues
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] cmake:bugfix generate config.h contain ; characters will be handled incorrectly [nuttx]

Posted by "XuNeo (via GitHub)" <gi...@apache.org>.
XuNeo commented on PR #12237:
URL: https://github.com/apache/nuttx/pull/12237#issuecomment-2079509046

   I have tested with lvgl v9 and it works!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] cmake:bugfix generate config.h contain ; characters will be handled incorrectly [nuttx]

Posted by "xuxin930 (via GitHub)" <gi...@apache.org>.
xuxin930 commented on PR #12237:
URL: https://github.com/apache/nuttx/pull/12237#issuecomment-2082467198

   > This issue not caused by `';'` character, which should be `foreach()` treated close bracket `']'` as a regular expression: https://stackoverflow.com/questions/26057678/escape-characters-in-a-semicolon-separated-list-in-cmake https://cmake.org/pipermail/cmake/2016-March/063030.html
   > 
   > @xuxin930 try this patch to check if there is any improvement.
   > 
   
   Yes! 👍
   I changed the solution and modified other methods of reading config to ensure consistency.
   Unfortunately🙁, CMake does NOT provide calls like **proxy functions** or **wrapper function**s. 
   I can only use marco to replace them.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org