Skip to content

Commit

Permalink
Merge branch 'bugfix/do-not-export-headers' into 'main'
Browse files Browse the repository at this point in the history
Improve the maintainability of the CI

See merge request espressif/esp-zigbee-sdk!144
  • Loading branch information
chshu committed Nov 7, 2024
2 parents 4bc9db7 + 451f843 commit e3c09f1
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 154 deletions.
16 changes: 1 addition & 15 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ before_script:
- cd ${ESP_ZBOSS_LIB_PATH}
- echo $(git branch --show-current)
- echo $(git log -1 --oneline)
- cp -r ${ESP_ZBOSS_LIB_PATH} ${IDF_PATH}/components/espressif__esp-zboss-lib

.update_zigbee_lib_script: &update_zigbee_lib_script
- *setup_idf
- *setup_esp_zboss_lib
- cp -r ${ESP_ZIGBEE_SDK_PATH}/components/esp-zigbee-lib ${IDF_PATH}/components/espressif__esp-zigbee-lib
- cd ${ESP_ZIGBEE_SDK_PATH}
- echo $(git branch --show-current)
- echo $(git log -1 --oneline)
- bash ./tools/ci/update_cmake_files.sh
- pip install -r tools/ci/requirements-build.txt

.build_rcp_gateway: &build_rcp_gateway
Expand Down Expand Up @@ -81,19 +80,6 @@ build_non_pytest_examples:
tags:
- build

build_non_pytest_host:
stage: build
image: ${CI_DOCKER_REGISTRY}/esp-env-v5.3:1
artifacts:
when: always
expire_in: 4 days
script:
- *setup_idf
- cd ${ESP_ZIGBEE_SDK_PATH}
- python tools/ci/build_apps.py ./examples --host
tags:
- build

build_pytest_examples:
stage: build
image: ${CI_DOCKER_REGISTRY}/esp-env-v5.3:1
Expand Down
102 changes: 1 addition & 101 deletions tools/ci/build_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@

GATEWAY_APPS = [{"target": "esp32h2", "name": "esp_zigbee_all_device_types_app"},]

HOST_APPS = [{"target": "esp32", "name": "esp_zigbee_host"},
{"target": "esp32s2", "name": "esp_zigbee_host"},
{"target": "esp32c3", "name": "esp_zigbee_host"},
{"target": "esp32s3", "name": "esp_zigbee_host"},
{"target": "esp32h2", "name": "esp_zigbee_host"},
{"target": "esp32c6", "name": "esp_zigbee_host"}, ]

IGNORE_WARNINGS = [
r"warning: 'init_spiffs' defined but not used",
Expand Down Expand Up @@ -84,109 +78,20 @@ def get_cmake_apps(
)
return apps


def update_component_yml_files():
os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_customized_devices', 'customized_client'))
os.remove('main/idf_component.yml')

os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_customized_devices', 'customized_server'))
os.remove('main/idf_component.yml')
os.system(f'cp {os.path.join(PROJECT_ROOT, "tools", "managed_component_yml", "light_idf_component.yml")} main'
f'/idf_component.yml')

os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_ota', 'ota_client'))
os.remove('main/idf_component.yml')
os.system(
f'cp {os.path.join(PROJECT_ROOT, "tools", "managed_component_yml", "ota_idf_component.yml")} main'
f'/idf_component.yml')

os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_ota', 'ota_server'))
os.remove('main/idf_component.yml')

os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_gateway'))
os.remove('main/idf_component.yml')
os.system(
f'cp {os.path.join(PROJECT_ROOT, "tools", "managed_component_yml", "gw_idf_component.yml")} main'
f'/idf_component.yml')

os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_HA_sample', 'HA_color_dimmable_light'))
os.remove('main/idf_component.yml')
os.system(f'cp {os.path.join(PROJECT_ROOT, "tools", "managed_component_yml", "light_idf_component.yml")} main'
f'/idf_component.yml')

os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_HA_sample', 'HA_color_dimmable_switch'))
os.remove('main/idf_component.yml')

os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_HA_sample', 'HA_on_off_switch'))
os.remove('main/idf_component.yml')

os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_HA_sample', 'HA_on_off_light'))
os.remove('main/idf_component.yml')
os.system(
f'cp {os.path.join(PROJECT_ROOT, "tools", "managed_component_yml", "light_idf_component.yml")} main'
f'/idf_component.yml')

os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_HA_sample', 'HA_temperature_sensor'))
os.remove('main/idf_component.yml')

os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_HA_sample', 'HA_thermostat'))
os.remove('main/idf_component.yml')

os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_touchlink', 'touchlink_light'))
os.remove('main/idf_component.yml')
os.system(
f'cp {os.path.join(PROJECT_ROOT, "tools", "managed_component_yml", "light_idf_component.yml")} main'
f'/idf_component.yml')

os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_touchlink', 'touchlink_switch'))
os.remove('main/idf_component.yml')

os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_sleep', 'deep_sleep'))
os.remove('main/idf_component.yml')

os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_sleep', 'light_sleep'))
os.remove('main/idf_component.yml')

os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_greenpower', 'esp_zigbee_gpc'))
os.remove('main/idf_component.yml')
os.system(
f'cp {os.path.join(PROJECT_ROOT, "tools", "managed_component_yml", "light_idf_component.yml")} main'
f'/idf_component.yml')

os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_greenpower', 'esp_zigbee_gpd'))
os.remove('main/idf_component.yml')

os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_ncp'))
os.remove('main/idf_component.yml')
os.system(
f'cp {os.path.join(PROJECT_ROOT, "tools", "managed_component_yml", "ncp_idf_component.yml")} main'
f'/idf_component.yml')

os.chdir(os.path.join(DEF_APP_PATH, 'esp_zigbee_all_device_types_app'))
os.remove('main/idf_component.yml')
os.system(
f'cp {os.path.join(PROJECT_ROOT, "tools", "managed_component_yml", "adt_idf_component.yml")} main'
f'/idf_component.yml')

def main(args: argparse.Namespace) -> None:
current_dir = os.getcwd()
# update_sdkconfig_files()
update_component_yml_files()
os.chdir(current_dir)
apps = get_cmake_apps(args.paths, args.target, args.config)

# no_pytest and only_pytest can not be both True
assert not (args.no_pytest and args.pytest)
if args.no_pytest:
apps_for_build = [app for app in apps if not (_is_pytest_app(app, PYTEST_APPS)
or _is_pytest_app(app, GATEWAY_APPS)
or _is_pytest_app(app, HOST_APPS))]
or _is_pytest_app(app, GATEWAY_APPS))]
elif args.pytest:
apps_for_build = [app for app in apps if _is_pytest_app(app, PYTEST_APPS)]
elif args.rcp_gateway:
apps_for_build = [app for app in apps if _is_pytest_app(app, GATEWAY_APPS)]
elif args.host:
apps_for_build = [app for app in apps if _is_pytest_app(app, HOST_APPS)]
else:
apps_for_build = apps[:]

Expand Down Expand Up @@ -264,11 +169,6 @@ def main(args: argparse.Namespace) -> None:
action="store_true",
help='Only build rcp_gateway pytest apps, defined in GATEWAY_APPS',
)
parser.add_argument(
'--host',
action="store_true",
help='Only build host apps, defined in HOST_APPS',
)

arguments = parser.parse_args()
if not arguments.paths:
Expand Down
40 changes: 40 additions & 0 deletions tools/ci/update_cmake_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
ESP_ZIGBEE_SDK="$(realpath ${SCRIPT_DIR}/../..)"

declare -A LIB_COMPONENTS=(
["espressif__esp-zigbee-lib"]="${ESP_ZIGBEE_SDK}/components/esp-zigbee-lib"
["espressif__esp-zboss-lib"]="${IDF_PATH}/../esp-zboss-lib"
)

set -ex
shopt -s globstar # Allow ** for recursive matches

update_dependency(){
# Remove the dependencies on managed LIB components.
# for examples in ESP-ZIGBEE-SDK
sed -i "/\besp-zboss-lib\b/d;/\besp-zigbee-lib\b/d" "${ESP_ZIGBEE_SDK}"/examples/**/main/idf_component.yml
# for components in ESP-ZIGBEE-SDK
sed -i "/\besp-zboss-lib\b/d;/\besp-zigbee-lib\b/d" "${ESP_ZIGBEE_SDK}"/components/*/idf_component.yml

# Link the local LIB components to the components directory of ESP-IDF
for component in "${!LIB_COMPONENTS[@]}"; do
local link_name="${IDF_PATH}/components/${component}"
local link_target="${LIB_COMPONENTS[${component}]}"
if [ ! -e "${link_name}" ]; then
ln -s "${link_target}" "${link_name}"
fi
echo "create link ${link_name} -> ${link_target}"
done
}

main() {
pushd "$(pwd)"

update_dependency

popd
}

main
9 changes: 0 additions & 9 deletions tools/managed_component_yml/adt_idf_component.yml

This file was deleted.

9 changes: 0 additions & 9 deletions tools/managed_component_yml/gw_idf_component.yml

This file was deleted.

6 changes: 0 additions & 6 deletions tools/managed_component_yml/light_idf_component.yml

This file was deleted.

8 changes: 0 additions & 8 deletions tools/managed_component_yml/ncp_idf_component.yml

This file was deleted.

6 changes: 0 additions & 6 deletions tools/managed_component_yml/ota_idf_component.yml

This file was deleted.

0 comments on commit e3c09f1

Please sign in to comment.