Skip to content

Commit

Permalink
change(launchpad): change launchpad program
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyunlong1234 committed Jul 26, 2024
1 parent 00fcb25 commit 15dd07e
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 15 deletions.
54 changes: 43 additions & 11 deletions tools/ci/launchpad/generateFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# SPDX-License-Identifier: Apache-2.0

from itertools import count
import re
import sys
import subprocess
Expand Down Expand Up @@ -34,6 +35,8 @@ def __init__(self, app):
self.app_version = ''
# App readme
self.readme = ''
# App description
self.description = ''

current_app = App(None)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -204,22 +222,36 @@ 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] = {}
toml_obj[support_app]['android_app_url'] = ''
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):
Expand All @@ -232,14 +264,14 @@ def create_config_toml(apps):

# This is a workaround to remove the quotes around the image.<string> 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.<string>"
pattern = r'"((image|readme)\.[\w-]+)"'
pattern = r'"((image|readme|developKits)\.[\w-]+)"'
# Use re.sub() to replace the matched pattern with image.<string>
result = re.sub(pattern, r'\1', text)
return result
Expand Down
39 changes: 35 additions & 4 deletions tools/ci/launchpad/upload_project_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,44 @@
# 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)
# <description>
# readme: // readme url must point a README.md link (optional)
# <URL>

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

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

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

Expand All @@ -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

0 comments on commit 15dd07e

Please sign in to comment.