From 12c88f915f0fefc47d68deb8743306b2879a077d Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 6 Dec 2023 21:40:25 +0100 Subject: [PATCH] V5.1 git clone optimize --- build.sh | 19 ++++++------------ tools/archive-build.sh | 1 + tools/config.sh | 10 +++------ tools/install-arduino.sh | 37 +++++++++++++++++++++++++++------- tools/install-esp-idf.sh | 39 ++++++++++++++++++++++++++++++++---- tools/repository_dispatch.sh | 2 +- tools/update-components.sh | 35 +++++++++++--------------------- 7 files changed, 88 insertions(+), 55 deletions(-) diff --git a/build.sh b/build.sh index 2e1bb0a85..65b7b8a33 100755 --- a/build.sh +++ b/build.sh @@ -63,11 +63,11 @@ while getopts ":A:I:i:c:t:b:sde" opt; do ;; b ) b=$OPTARG - if [ "$b" != "build" ] && - [ "$b" != "menuconfig" ] && - [ "$b" != "reconfigure" ] && - [ "$b" != "idf_libs" ] && - [ "$b" != "copy_bootloader" ] && + if [ "$b" != "build" ] && + [ "$b" != "menuconfig" ] && + [ "$b" != "reconfigure" ] && + [ "$b" != "idf_libs" ] && + [ "$b" != "copy_bootloader" ] && [ "$b" != "mem_variant" ]; then print_help fi @@ -114,7 +114,7 @@ if [ "$BUILD_TYPE" != "all" ]; then print_help fi configs="configs/defconfig.common;configs/defconfig.$TARGET" - + # Target Features Configs for target_json in `jq -c '.targets[]' configs/builds.json`; do target=$(echo "$target_json" | jq -c '.target' | tr -d '"') @@ -146,13 +146,6 @@ IDF_Commit_short=$(git -C "$IDF_PATH" rev-parse --short HEAD || echo "") AR_Commit_short=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "") echo "Framework built from $IDF_REPO branch $IDF_BRANCH commit $IDF_Commit_short and $AR_REPO branch $AR_BRANCH commit $AR_Commit_short" >> release-info.txt -# Add release-info -rm -rf release-info.txt -IDF_Commit_short=$(git -C "$IDF_PATH" rev-parse --short HEAD || echo "") -AR_Commit_short=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "") -echo "Framework built from $IDF_REPO branch $IDF_BRANCH commit $IDF_Commit_short and $AR_REPO branch $AR_BRANCH commit $AR_Commit_short" >> release-info.txt - - #targets_count=`jq -c '.targets[] | length' configs/builds.json` for target_json in `jq -c '.targets[]' configs/builds.json`; do target=$(echo "$target_json" | jq -c '.target' | tr -d '"') diff --git a/tools/archive-build.sh b/tools/archive-build.sh index 08993d7a1..c0da6d709 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -26,6 +26,7 @@ cp -f ../components/arduino/pac* arduino-esp32 rm -rf arduino-esp32/idf_component_examples rm -rf arduino-esp32/docs rm -rf arduino-esp32/tests +rm -rf arduino-esp32/idf_component_examples rm -rf arduino-esp32/libraries/RainMaker rm -rf arduino-esp32/libraries/Insights rm -rf arduino-esp32/libraries/ESP_I2S diff --git a/tools/config.sh b/tools/config.sh index 4db94e1b2..fe8a65d4f 100755 --- a/tools/config.sh +++ b/tools/config.sh @@ -14,11 +14,6 @@ if [ -z $AR_BRANCH ]; then AR_BRANCH="main" fi -if [ -z $AR_PR_TARGET_BRANCH ]; then - # Temporary to get CI working. original is master - AR_PR_TARGET_BRANCH="esp-idf-v5.1-libs" -fi - if [ -z $IDF_TARGET ]; then if [ -f sdkconfig ]; then IDF_TARGET=`cat sdkconfig | grep CONFIG_IDF_TARGET= | cut -d'"' -f2` @@ -34,7 +29,7 @@ fi AR_USER="tasmota" # IDF commit to use -#IDF_COMMIT="ec31b4d09d3da05001648eaa58aa582c5cc923c8" +#IDF_COMMIT="" # Arduino commit to use #AR_COMMIT="" @@ -176,8 +171,9 @@ function git_create_pr(){ # git_create_pr local pr_branch="$1" local pr_title="$2" local pr_target="$3" - local pr_body="" + local pr_body="\`\`\`\r\n" while read -r line; do pr_body+=$line"\r\n"; done < "$AR_TOOLS/esp32-arduino-libs/versions.txt" + pr_body+="\`\`\`\r\n" local pr_data="{\"title\": \"$pr_title\", \"body\": \"$pr_body\", \"head\": \"$AR_USER:$pr_branch\", \"base\": \"$pr_target\"}" git_create_pr_res=`echo "$pr_data" | curl -k -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" --data @- "https://api.github.com/repos/$AR_REPO/pulls"` local done_pr=`echo "$git_create_pr_res" | jq -r '.title'` diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index 78668b7f3..93b53a6e2 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -5,9 +5,38 @@ source ./tools/config.sh # # CLONE/UPDATE ARDUINO # -echo "Updating ESP32 Arduino..." +if [ "$AR_BRANCH" ]; then + echo "Installing Arduino from branch '$AR_BRANCH'" + if [ ! -d "$AR_COMPS/arduino" ]; then + # for using a branch we need no full clone + git clone -b "$AR_BRANCH" --recursive --depth 1 --shallow-submodule $AR_REPO_URL "$AR_COMPS/arduino" + else + # update existing branch + cd "$AR_COMPS/arduino" + git pull + git reset --hard $AR_BRANCH + # -ff is for cleaning untracked files as well as submodules + git clean -ffdx + cd - + fi +fi + if [ ! -d "$AR_COMPS/arduino" ]; then + # we need a full clone since no branch was set + echo "Full cloning of ESP32 Arduino repo '$AR_REPO_URL'" git clone $AR_REPO_URL "$AR_COMPS/arduino" +else + if [ "$AR_BRANCH" ]; then + echo "ESP32 Arduino is up to date" + else + # update existing branch + echo "Updating ESP32 Arduino" + cd "$AR_COMPS/arduino" + git pull + # -ff is for cleaning untracked files as well as submodules + git clean -ffdx + cd - + fi fi if [ -z $AR_BRANCH ]; then @@ -39,12 +68,6 @@ if [ -z $AR_BRANCH ]; then fi fi -if [ "$AR_BRANCH" ]; then - echo "AR_BRANCH='$AR_BRANCH'" - git -C "$AR_COMPS/arduino" checkout "$AR_BRANCH" && \ - git -C "$AR_COMPS/arduino" fetch && \ - git -C "$AR_COMPS/arduino" pull --ff-only -fi if [ $? -ne 0 ]; then exit 1; fi # diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index 9175b83dc..e3433e9c1 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -10,11 +10,42 @@ fi # # CLONE ESP-IDF # +if [ "$IDF_TAG" ] || [ "$IDF_COMMIT" ]; then + if [ ! -d "$IDF_PATH" ]; then + # full clone needed to check out tag or commit + echo "ESP-IDF is not installed! Installing with full clone from $IDF_REPO_URL branch $IDF_BRANCH" + git clone $IDF_REPO_URL -b $IDF_BRANCH + idf_was_installed="1" + else + # update local clone + echo "ESP-IDF is installed, updating..." + cd $IDF_PATH + git pull + git reset --hard $IDF_BRANCH + git submodule update + # -ff is for cleaning untracked files as well as submodules + git clean -ffdx + cd - + idf_was_installed="1" + fi +fi if [ ! -d "$IDF_PATH" ]; then - echo "ESP-IDF is not installed! Installing from $IDF_REPO_URL branch $IDF_BRANCH" - git clone $IDF_REPO_URL -b $IDF_BRANCH - idf_was_installed="1" + # for using a branch we need no full clone + echo "ESP-IDF is not installed! Installing branch $IDF_BRANCH from $IDF_REPO_URL" + git clone -b $IDF_BRANCH --recursive --depth 1 --shallow-submodule $IDF_REPO_URL + idf_was_installed="1" +else + # update existing branch + echo "ESP-IDF is already installed, updating branch '$IDF_BRANCH'" + cd $IDF_PATH + git pull + git reset --hard $IDF_BRANCH + git submodule update --depth 1 + # -ff is for cleaning untracked files as well as submodules + git clean -ffdx + cd - + idf_was_installed="1" fi if [ "$IDF_TAG" ]; then @@ -30,7 +61,7 @@ fi # if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then - git -C $IDF_PATH submodule update --init --recursive + git submodule update --recursive $IDF_PATH/install.sh export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD) export IDF_BRANCH=$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD) diff --git a/tools/repository_dispatch.sh b/tools/repository_dispatch.sh index 15198e98e..ad23620a8 100755 --- a/tools/repository_dispatch.sh +++ b/tools/repository_dispatch.sh @@ -14,7 +14,7 @@ commit=`echo "$payload" | jq -r '.commit'` builder=`echo "$payload" | jq -r '.builder'` arduino=`echo "$payload" | jq -r '.arduino'` -echo "Action: $action, Branch: $branch, Tag: $tag, Commit: $commit, Builder: $builder, Arduino: $arduino, Actor: $GITHUB_ACTOR" +echo "Action: $action, IDF Branch: $branch, IDF Tag: $tag, IDF Commit: $commit, Builder Branch: $builder, Arduino Branch: $arduino, Actor: $GITHUB_ACTOR" if [ ! "$action" == "deploy" ] && [ ! "$action" == "build" ]; then echo "Bad Action $action" diff --git a/tools/update-components.sh b/tools/update-components.sh index d2d819fdd..9fdbb8ea6 100755 --- a/tools/update-components.sh +++ b/tools/update-components.sh @@ -3,7 +3,6 @@ source ./tools/config.sh CAMERA_REPO_URL="https://github.com/espressif/esp32-camera.git" -LITTLEFS_REPO_URL="https://github.com/joltwallet/esp_littlefs.git" TINYUSB_REPO_URL="https://github.com/hathach/tinyusb.git" TINYUSB_REPO_DIR="$AR_COMPS/arduino_tinyusb/tinyusb" @@ -12,10 +11,14 @@ TINYUSB_REPO_DIR="$AR_COMPS/arduino_tinyusb/tinyusb" # echo "Updating ESP32 Camera..." if [ ! -d "$AR_COMPS/esp32-camera" ]; then - git clone $CAMERA_REPO_URL "$AR_COMPS/esp32-camera" + git clone -b master --recursive --depth 1 --shallow-submodule $CAMERA_REPO_URL "$AR_COMPS/esp32-camera" else - git -C "$AR_COMPS/esp32-camera" fetch && \ - git -C "$AR_COMPS/esp32-camera" pull --ff-only + cd "$AR_COMPS/esp32-camera" + git pull + git submodule update --depth 1 + # -ff is for cleaning untracked files as well as submodules + git clean -ffdx + cd - fi if [ $? -ne 0 ]; then exit 1; fi @@ -24,30 +27,16 @@ if [ $? -ne 0 ]; then exit 1; fi # cp "$AR_COMPS/esp32-camera/driver/private_include/cam_hal.h" "$AR_COMPS/esp32-camera/driver/include/" -# -# CLONE/UPDATE ESP-LITTLEFS v1.10.0 commit 032f9... -# -#echo "Updating ESP-LITTLEFS..." -#if [ ! -d "$AR_COMPS/esp_littlefs" ]; then -# git clone $LITTLEFS_REPO_URL "$AR_COMPS/esp_littlefs" -# git -C "$AR_COMPS/esp_littlefs" checkout 032f9eb2e291e7c4df63c3e6a3cb3bc766ded495 -# git -C "$AR_COMPS/esp_littlefs" submodule update --init --recursive -#else -# git -C "$AR_COMPS/esp_littlefs" fetch -# git -C "$AR_COMPS/esp_littlefs" pull --ff-only -# git -C "$AR_COMPS/esp_littlefs" checkout 032f9eb2e291e7c4df63c3e6a3cb3bc766ded495 -# git -C "$AR_COMPS/esp_littlefs" submodule update --init --recursive -#fi -#if [ $? -ne 0 ]; then exit 1; fi - # # CLONE/UPDATE TINYUSB # echo "Updating TinyUSB..." if [ ! -d "$TINYUSB_REPO_DIR" ]; then - git clone "$TINYUSB_REPO_URL" "$TINYUSB_REPO_DIR" + git clone -b master --depth 1 "$TINYUSB_REPO_URL" "$TINYUSB_REPO_DIR" else - git -C "$TINYUSB_REPO_DIR" fetch && \ - git -C "$TINYUSB_REPO_DIR" pull --ff-only + cd $TINYUSB_REPO_DIR + git pull + # -ff is for cleaning untracked files as well as submodules + git clean -ffdx fi if [ $? -ne 0 ]; then exit 1; fi