From 15dd07e3ba6361043f71ecdfa9bf216c36dd990f Mon Sep 17 00:00:00 2001 From: zhaoyunlong1234 Date: Fri, 26 Jul 2024 14:41:57 +0800 Subject: [PATCH] change(launchpad): change launchpad program --- tools/ci/launchpad/generateFiles.py | 54 ++++++++++++++++---- tools/ci/launchpad/upload_project_config.yml | 39 ++++++++++++-- 2 files changed, 78 insertions(+), 15 deletions(-) diff --git a/tools/ci/launchpad/generateFiles.py b/tools/ci/launchpad/generateFiles.py index 90ab44b48..fcc142c5f 100644 --- a/tools/ci/launchpad/generateFiles.py +++ b/tools/ci/launchpad/generateFiles.py @@ -2,6 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 +from itertools import count import re import sys import subprocess @@ -34,6 +35,8 @@ def __init__(self, app): self.app_version = '' # App readme self.readme = '' + # App description + self.description = '' current_app = App(None) @@ -118,26 +121,38 @@ def remove_app_from_config(apps): new_apps = [] for app in apps: # remove './' in string - app_dir = app['app_dir'][2:] + if app['app_dir'].startswith('./'): + app_dir = app['app_dir'][2:] + else: + app_dir = app['app_dir'] + if app_dir not in config_apps: continue example = config_apps[app_dir] matched_build_info = [] + sdkcount = {} for build_info in app['build_info']: target = build_info.get('target') if ( example.get(target) and build_info.get('sdkconfig') in example.get(target, {}).get('sdkconfig', []) ): + if build_info.get('sdkconfig') == "defaults": + build_info['sdkconfig'] = target + '_generic' matched_build_info.append(build_info) + if not sdkcount.get(f'developKits.{target}'): + sdkcount[f'developKits.{target}'] = 1 + else: + sdkcount[f'developKits.{target}'] += 1 if matched_build_info: app['build_info'] = matched_build_info + app['sdkcount'] = sdkcount if config_apps[app_dir].get('readme'): - print(config_apps[app_dir]['readme']) app['readme'] = config_apps[app_dir]['readme'] + if config_apps[app_dir].get('description'): + app['description'] = config_apps[app_dir]['description'] new_apps.append(app) - return new_apps # Squash the json into a list of apps @@ -183,6 +198,9 @@ def merge_binaries(apps): build_dirs = build_info['build_dir'] idf_version = build_info['idf_version'] app_version = app['app_version'] + sdkcount = app['sdkcount'] + if sdkcount.get(f'developKits.{target}') == 1: + sdkconfig = '' bin_name = f'{app["name"]}-{target}' + (f'-{sdkconfig}' if sdkconfig else '') + (f'-{app_version}' if app_version else '') + (f'-{idf_version}' if idf_version else '') + '.bin' cmd = ['esptool.py', '--chip', target, 'merge_bin', '-o', bin_name, '@flash_args'] cwd = os.path.join(app.get('app_dir'), build_dirs) @@ -204,10 +222,14 @@ def merge_binaries(apps): def write_app(app): # If we are working with kits for build_info in app['build_info']: + target = build_info['target'] + sdkconfig = build_info['sdkconfig'] idf_version = build_info['idf_version'] app_version = app['app_version'] - sdkconfig = build_info['sdkconfig'] - bin_name = f'{app["name"]}-{build_info["target"]}' + (f'-{sdkconfig}' if sdkconfig else '') + (f'-{app_version}' if app_version else '') + (f'-{idf_version}' if idf_version else '') + '.bin' + sdkcount = app['sdkcount'] + if sdkcount.get(f'developKits.{target}') == 1: + sdkconfig = '' + bin_name = f'{app["name"]}-{target}' + (f'-{sdkconfig}' if sdkconfig else '') + (f'-{app_version}' if app_version else '') + (f'-{idf_version}' if idf_version else '') + '.bin' support_app = f'{app["name"]}' if not toml_obj.get(support_app): toml_obj[support_app] = {} @@ -215,11 +237,21 @@ def write_app(app): toml_obj[support_app]['ios_app_url'] = '' if app.get('readme'): toml_obj[support_app]['readme.text'] = app['readme'] + if app.get('description'): + toml_obj[support_app]['description'] = app['description'] if not toml_obj[support_app].get('chipsets'): - toml_obj[support_app]['chipsets'] = [f'{build_info["target"]}-{build_info["sdkconfig"]}'] + toml_obj[support_app]['chipsets'] = [f'{target}'] + elif f'{target}' not in toml_obj[support_app]['chipsets']: + toml_obj[support_app]['chipsets'].append(f'{target}') + if sdkcount.get(f'developKits.{target}') > 1: + if not toml_obj[support_app].get(f'developKits.{target}'): + toml_obj[support_app][f'developKits.{target}'] = [f'{sdkconfig}'] + else: + toml_obj[support_app][f'developKits.{target}'].append(f'{sdkconfig}') + if sdkcount.get(f'developKits.{target}') == 1: + toml_obj[support_app][f'image.{target}'] = bin_name else: - toml_obj[support_app]['chipsets'].append(f'{build_info["target"]}-{build_info["sdkconfig"]}') - toml_obj[support_app][f'image.{build_info["target"]}-{build_info["sdkconfig"]}'] = bin_name + toml_obj[support_app][f'image.{sdkconfig}'] = bin_name # Create the config.toml file def create_config_toml(apps): @@ -232,14 +264,14 @@ def create_config_toml(apps): # This is a workaround to remove the quotes around the image. in the config.toml file as dot is not allowed in the key by default with open('binaries/config.toml', 'r') as toml_file: - fixed = replace_image_and_readme_string(toml_file.read()) + fixed = unquote_config_keys(toml_file.read()) with open('binaries/config.toml', 'w') as toml_file: toml_file.write(fixed) -def replace_image_and_readme_string(text): +def unquote_config_keys(text): # Define the regular expression pattern to find "image." - pattern = r'"((image|readme)\.[\w-]+)"' + pattern = r'"((image|readme|developKits)\.[\w-]+)"' # Use re.sub() to replace the matched pattern with image. result = re.sub(pattern, r'\1', text) return result diff --git a/tools/ci/launchpad/upload_project_config.yml b/tools/ci/launchpad/upload_project_config.yml index c3c3600b4..0c68a4b4a 100644 --- a/tools/ci/launchpad/upload_project_config.yml +++ b/tools/ci/launchpad/upload_project_config.yml @@ -2,21 +2,26 @@ # target: esp32 // target name # sdkconfig: // sdkconfig name # - a // sdkconfig.ci.a -# - default // sdkconfig.default +# - default // sdkconfig.default (will be renamed to {target}_generic) # target: esp32s3 // target name # sdkconfig: // sdkconfig name -# - b // sdkconfig.ci.a -# - default // sdkconfig.default -# readme: // readme url must point a README.md link +# - b // sdkconfig.ci.b +# - default // sdkconfig.default (will be renamed to {target}_generic) +# description: // Description of the example (optional) +# +# readme: // readme url must point a README.md link (optional) # examples/usb/device/usb_dual_uvc_device: esp32s3: sdkconfig: - esp32s3_usb_otg + - defaults esp32p4: sdkconfig: - defaults + description: + This is the USB dual UVC device example readme: https://raw.githubusercontent.com/espressif/esp-iot-solution/master/examples/usb/device/usb_dual_uvc_device/README.md @@ -24,6 +29,8 @@ examples/usb/device/usb_webcam: esp32s3: sdkconfig: - esp32s3_eye + description: + This is the USB webcam example readme: https://raw.githubusercontent.com/espressif/esp-iot-solution/master/examples/usb/device/usb_webcam/README.md @@ -31,6 +38,8 @@ examples/usb/host/usb_camera_lcd_display: esp32s3: sdkconfig: - esp32s3_lcd_ev_board + description: + This is the USB camera LCD display example readme: https://raw.githubusercontent.com/espressif/esp-iot-solution/master/examples/usb/host/usb_camera_lcd_display/README.md @@ -39,5 +48,27 @@ examples/usb/host/usb_camera_mic_spk: sdkconfig: - esp32s3_usb_otg - defaults + description: + This is the USB camera microphone speaker example readme: https://raw.githubusercontent.com/espressif/esp-iot-solution/master/examples/usb/host/usb_camera_mic_spk/README.md + +examples/usb/host/usb_cdc_4g_module: + esp32s3: + sdkconfig: + - esp32s3_usb_otg + - defaults + description: + This is the USB CDC 4G module example + readme: + https://raw.githubusercontent.com/espressif/esp-iot-solution/master/examples/usb/host/usb_cdc_4g_module/README.md + +examples/usb/host/usb_cdc_basic: + esp32s3: + sdkconfig: + - esp32s3_usb_otg + description: + This is the USB CDC basic example + readme: + https://raw.githubusercontent.com/espressif/esp-iot-solution/master/examples/usb/host/sb_cdc_basic/README.md +