|
7 | 7 | import subprocess
|
8 | 8 | from collections import namedtuple
|
9 | 9 |
|
10 |
| -from idf_build_apps.constants import SUPPORTED_TARGETS |
| 10 | +from idf_build_apps.constants import PREVIEW_TARGETS, SUPPORTED_TARGETS |
11 | 11 | from pycparser import c_ast, c_parser, preprocess_file
|
12 | 12 |
|
13 | 13 | Param = namedtuple('Param', ['ptr', 'array', 'qual', 'type', 'name'])
|
@@ -161,45 +161,42 @@ def get_vars(parameters):
|
161 | 161 |
|
162 | 162 | def generate_kconfig_wifi_caps(idf_path, component_path):
|
163 | 163 | kconfig = os.path.join(component_path, 'Kconfig.soc_wifi_caps.in')
|
| 164 | + slave_select = os.path.join(component_path, 'Kconfig.slave_select.in') |
164 | 165 | sdkconfig_files = []
|
165 |
| - with open(kconfig, 'w') as out: |
166 |
| - out.write(f'# {AUTO_GENERATED}\n') |
167 |
| - for slave_target in SUPPORTED_TARGETS: |
168 |
| - out.write(f'\nif SLAVE_IDF_TARGET_{slave_target.upper()}\n\n') |
| 166 | + with open(kconfig, 'w') as slave_caps, open(slave_select, 'w') as slave: |
| 167 | + slave_caps.write(f'# {AUTO_GENERATED}\n') |
| 168 | + slave.write(f'# {AUTO_GENERATED}\n') |
| 169 | + slave.write(' choice SLAVE_IDF_TARGET\n') |
| 170 | + slave.write(' prompt "choose slave target"\n') |
| 171 | + slave.write(' default SLAVE_IDF_TARGET_ESP32\n') |
| 172 | + for slave_target in SUPPORTED_TARGETS + PREVIEW_TARGETS: |
| 173 | + add_slave = False |
| 174 | + kconfig_content = [] |
169 | 175 | soc_caps = os.path.join(idf_path, 'components', 'soc', slave_target, 'include', 'soc', 'Kconfig.soc_caps.in')
|
170 | 176 | with open(soc_caps, 'r') as f:
|
171 | 177 | for line in f:
|
172 | 178 | if line.strip().startswith('config SOC_WIFI_'):
|
173 | 179 | if 'config SOC_WIFI_SUPPORTED' in line:
|
174 |
| - # if WiFi supported for this target, test it as a slave |
| 180 | + # if WiFi supported for this target, add it to Kconfig slave options and test this slave |
| 181 | + add_slave = True |
175 | 182 | sdkconfig = os.path.join(component_path, 'test', 'smoke_test', f'sdkconfig.ci.slave_{slave_target}')
|
176 | 183 | open(sdkconfig, 'w').write(f'CONFIG_SLAVE_IDF_TARGET_{slave_target.upper()}=y\n')
|
177 | 184 | sdkconfig_files.append(sdkconfig)
|
178 |
| - replaced = re.compile(r'SOC_WIFI_').sub('SLAVE_SOC_WIFI_', line) |
179 |
| - out.write(f' {replaced}') |
180 |
| - line = f.readline() # type |
181 |
| - out.write(f' {line}') |
182 |
| - line = f.readline() # default |
183 |
| - out.write(f' {line}\n') |
184 |
| - out.write(f'endif # {slave_target.upper()}\n') |
185 |
| - return [kconfig] + sdkconfig_files |
186 |
| - |
187 |
| - |
188 |
| -def generate_test_kconfig(component_path): |
189 |
| - path = os.path.join(component_path, 'test','smoke_test','components','esp_hosted','Kconfig') |
190 |
| - with open(path, 'w') as f: |
191 |
| - f.write(f'# {AUTO_GENERATED}\n') |
192 |
| - f.write('menu "ESP Hosted Mock"\n') |
193 |
| - f.write(' choice SLAVE_IDF_TARGET\n') |
194 |
| - f.write(' prompt "choose slave target"\n') |
195 |
| - f.write(' default SLAVE_IDF_TARGET_ESP32\n') |
196 |
| - for slave_target in SUPPORTED_TARGETS: |
197 |
| - config = 'SLAVE_IDF_TARGET_' + slave_target.upper() |
198 |
| - f.write(f' config {config}\n') |
199 |
| - f.write(f' bool "{slave_target}"\n') |
200 |
| - f.write(' endchoice\n') |
201 |
| - f.write('endmenu\n') |
202 |
| - return [path] |
| 185 | + replaced = re.sub(r'SOC_WIFI_', 'SLAVE_SOC_WIFI_', line) |
| 186 | + kconfig_content.append(f' {replaced}') |
| 187 | + kconfig_content.append(f' {f.readline()}') # type |
| 188 | + kconfig_content.append(f' {f.readline()}\n') # default |
| 189 | + if add_slave: |
| 190 | + slave_caps.write(f'\nif SLAVE_IDF_TARGET_{slave_target.upper()}\n\n') |
| 191 | + slave_caps.writelines(kconfig_content) |
| 192 | + slave_caps.write(f'endif # {slave_target.upper()}\n') |
| 193 | + |
| 194 | + slave_config_name = 'SLAVE_IDF_TARGET_' + slave_target.upper() |
| 195 | + slave.write(f' config {slave_config_name}\n') |
| 196 | + slave.write(f' bool "{slave_target}"\n') |
| 197 | + |
| 198 | + slave.write(' endchoice\n') |
| 199 | + return [kconfig, slave_select] + sdkconfig_files |
203 | 200 |
|
204 | 201 |
|
205 | 202 | def generate_remote_wifi_api(function_prototypes, component_path):
|
@@ -311,6 +308,7 @@ def generate_kconfig(idf_path, component_path):
|
311 | 308 | f.write(' config ESP_WIFI_REMOTE_ENABLED\n')
|
312 | 309 | f.write(' bool\n')
|
313 | 310 | f.write(' default y\n\n')
|
| 311 | + f.write(' orsource "./Kconfig.slave_select.in"\n') |
314 | 312 | f.write(' orsource "./Kconfig.soc_wifi_caps.in"\n')
|
315 | 313 | f.write(' orsource "./Kconfig.rpc.in"\n')
|
316 | 314 | for line1 in lines:
|
@@ -377,8 +375,6 @@ def compare_files(base_dir, component_path, files_to_check):
|
377 | 375 |
|
378 | 376 | files_to_check = []
|
379 | 377 |
|
380 |
| - files_to_check += generate_test_kconfig(component_path) |
381 |
| - |
382 | 378 | files_to_check += generate_kconfig_wifi_caps(idf_path, component_path)
|
383 | 379 |
|
384 | 380 | files_to_check += generate_remote_wifi_api(function_prototypes, component_path)
|
|
0 commit comments