11import sys
22
3-
43def add_style (option , val ):
54 # colorize ON and OFF keywords
65 val = val .replace ('ON' , '<span style="color: #4CAF50;">ON</span>' )
@@ -22,25 +21,32 @@ def add_style(option, val):
2221
2322 return val
2423
25-
2624def add_row (option , description , value ):
25+ advanced = "YES" if option in advanced_options else "NO"
2726 if option in table_rows :
2827 # update value if option exists
2928 table_rows [option ][2 ] = value
29+ table_rows [option ][3 ] = advanced
3030 else :
3131 # add to table new option
32- table_rows [option ] = [option , description , value ]
32+ table_rows [option ] = [option , description , value , advanced ]
3333
34+ def update_advanced_status ():
35+ for option in table_rows :
36+ if option in advanced_options :
37+ table_rows [option ][3 ] = "YES" # Update advanced status to YES
3438
3539with open ('CMake/lrs_options.cmake' , 'r' ) as file :
3640 lines = file .readlines ()
3741
3842table_rows = {}
43+ advanced_options = set ()
3944in_cond = False
4045in_elseif = False
4146in_else = False
4247current_condition = None
4348current_comment = ""
49+ last_option = None # Track the last option processed
4450
4551for i , line in enumerate (lines ):
4652 if line .strip ().startswith (('option(' , 'set(' )):
@@ -71,6 +77,7 @@ def add_row(option, description, value):
7177
7278 value = add_style (option , value )
7379 add_row (option , description , value )
80+ last_option = option # Update the last option processed
7481 elif line .startswith ('if' ):
7582 parts = line .strip ().split ('(' , 1 )
7683 condition = parts [1 ][:- 1 ] # remove last ")" - part of the 'if'
@@ -94,19 +101,28 @@ def add_row(option, description, value):
94101 continue # ignore internal comments
95102 elif line .startswith ('#' ):
96103 current_comment += line .strip ('# \n ' )
104+ elif line .startswith ('mark_as_advanced' ):
105+ parts = line .strip ().split ('(' )
106+ option = parts [1 ].strip (')' ) # extract the option name
107+ advanced_options .add (option ) # add to advanced options set
108+ if last_option : # Check if last_option is set
109+ advanced_options .add (last_option ) # Mark the last option as advanced
97110 elif line .strip ():
98111 # if we reach a line that doesn't match the pattern, throw an error as it's not handled (shouldn't happen)
99112 raise Exception (f"{ i , line } not handled" )
100113
114+ # Update advanced status for all options after processing the file
115+ update_advanced_status ()
101116
102117def format_dict_values ():
103118 return '' .join (
104119 f'\n <tr>'
105120 f'\n \t <td>\n \t <b><code>{ option } </code></b>' f'\n \t </td>'
106121 f'\n \t <td>\n \t { description } \n \t </td>'
107122 f'\n \t <td>\n \t { value } \n \t </td>'
123+ f'\n \t <td>\n \t <span style="color: { "#4CAF50" if advanced == "YES" else "#E74C3C" } ;">{ advanced } </span>\n \t </td>'
108124 f'\n </tr>'
109- for option , description , value in table_rows .values ())
125+ for option , description , value , advanced in table_rows .values ())
110126
111127def get_sdk_version ():
112128 if len (sys .argv ) > 1 :
@@ -117,7 +133,6 @@ def get_sdk_version():
117133 # if no parameter provided - no version number will be included
118134 return ""
119135
120-
121136html = f'''<!DOCTYPE html>
122137<html>
123138<head>
@@ -131,9 +146,10 @@ def get_sdk_version():
131146 <h2>{ get_sdk_version ()} </h2>
132147 <table>
133148 <tr>
134- <th style="width: 30 %">Option</th>
135- <th style="width: 55 %">Description</th>
149+ <th style="width: 25 %">Option</th>
150+ <th style="width: 45 %">Description</th>
136151 <th style="width: 15%">Default</th>
152+ <th style="width: 15%">Advanced</th>
137153 </tr>{ format_dict_values ()}
138154 </table>
139155 </div>
@@ -143,4 +159,4 @@ def get_sdk_version():
143159
144160with open ('doc/build-flags.html' , 'w' ) as file :
145161 file .write (html )
146- print ("build-flags.html generated" )
162+ print ("build-flags.html generated" )
0 commit comments