Jen ulozeni kopie z githubu
This commit is contained in:
16
tools/archive-build.sh
Executable file
16
tools/archive-build.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD)
|
||||
IDF_BRANCH=$(git -C "$IDF_PATH" symbolic-ref --short HEAD)
|
||||
|
||||
idf_version_string=${IDF_BRANCH//\//_}"-$IDF_COMMIT"
|
||||
archive_path="dist/arduino-esp32-libs-$idf_version_string.tar.gz"
|
||||
build_archive_path="dist/arduino-esp32-build-$idf_version_string.tar.gz"
|
||||
|
||||
mkdir -p dist && rm -rf "$archive_path" "$build_archive_path"
|
||||
if [ -d "out" ]; then
|
||||
cd out && tar zcf "../$archive_path" * && cd ..
|
||||
fi
|
||||
if [ -d "build" ]; then
|
||||
cd build && tar zcf "../$build_archive_path" * && cd ..
|
||||
fi
|
118
tools/config.sh
Executable file
118
tools/config.sh
Executable file
@ -0,0 +1,118 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
if [ -z $IDF_PATH ]; then
|
||||
export IDF_PATH="$PWD/esp-idf"
|
||||
fi
|
||||
|
||||
if [ -z $IDF_BRANCH ]; then
|
||||
IDF_BRANCH="release/v4.4"
|
||||
fi
|
||||
|
||||
if [ -z $AR_PR_TARGET_BRANCH ]; then
|
||||
AR_PR_TARGET_BRANCH="master"
|
||||
fi
|
||||
|
||||
if [ -z $IDF_TARGET ]; then
|
||||
if [ -f sdkconfig ]; then
|
||||
IDF_TARGET=`cat sdkconfig | grep CONFIG_IDF_TARGET= | cut -d'"' -f2`
|
||||
if [ "$IDF_TARGET" = "" ]; then
|
||||
IDF_TARGET="esp32"
|
||||
fi
|
||||
else
|
||||
IDF_TARGET="esp32"
|
||||
fi
|
||||
fi
|
||||
|
||||
IDF_COMPS="$IDF_PATH/components"
|
||||
IDF_TOOLCHAIN="xtensa-$IDF_TARGET-elf"
|
||||
|
||||
# Owner of the target ESP32 Arduino repository
|
||||
AR_USER="espressif"
|
||||
|
||||
# The full name of the repository
|
||||
AR_REPO="$AR_USER/arduino-esp32"
|
||||
|
||||
AR_REPO_URL="https://github.com/$AR_REPO.git"
|
||||
if [ -n $GITHUB_TOKEN ]; then
|
||||
AR_REPO_URL="https://$GITHUB_TOKEN@github.com/$AR_REPO.git"
|
||||
fi
|
||||
|
||||
AR_ROOT="$PWD"
|
||||
AR_COMPS="$AR_ROOT/components"
|
||||
AR_OUT="$AR_ROOT/out"
|
||||
AR_TOOLS="$AR_OUT/tools"
|
||||
AR_PLATFORM_TXT="$AR_OUT/platform.txt"
|
||||
AR_ESPTOOL_PY="$AR_TOOLS/esptool.py"
|
||||
AR_GEN_PART_PY="$AR_TOOLS/gen_esp32part.py"
|
||||
AR_SDK="$AR_TOOLS/sdk/$IDF_TARGET"
|
||||
|
||||
function get_os(){
|
||||
OSBITS=`arch`
|
||||
if [[ "$OSTYPE" == "linux"* ]]; then
|
||||
if [[ "$OSBITS" == "i686" ]]; then
|
||||
echo "linux32"
|
||||
elif [[ "$OSBITS" == "x86_64" ]]; then
|
||||
echo "linux64"
|
||||
elif [[ "$OSBITS" == "armv7l" ]]; then
|
||||
echo "linux-armel"
|
||||
else
|
||||
echo "unknown"
|
||||
return 1
|
||||
fi
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
echo "macos"
|
||||
elif [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
|
||||
echo "win32"
|
||||
else
|
||||
echo "$OSTYPE"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
AR_OS=`get_os`
|
||||
|
||||
export SED="sed"
|
||||
export SSTAT="stat -c %s"
|
||||
|
||||
if [[ "$AR_OS" == "macos" ]]; then
|
||||
export SED="gsed"
|
||||
export SSTAT="stat -f %z"
|
||||
fi
|
||||
|
||||
function git_commit_exists(){ #git_commit_exists <repo-path> <commit-message>
|
||||
local repo_path="$1"
|
||||
local commit_message="$2"
|
||||
local commits_found=`git -C "$repo_path" log --all --grep="$commit_message" | grep commit`
|
||||
if [ -n "$commits_found" ]; then echo 1; else echo 0; fi
|
||||
}
|
||||
|
||||
function git_branch_exists(){ # git_branch_exists <repo-path> <branch-name>
|
||||
local repo_path="$1"
|
||||
local branch_name="$2"
|
||||
local branch_found=`git -C "$repo_path" ls-remote --heads origin "$branch_name"`
|
||||
if [ -n "$branch_found" ]; then echo 1; else echo 0; fi
|
||||
}
|
||||
|
||||
function git_pr_exists(){ # git_pr_exists <branch-name>
|
||||
local pr_num=`curl -s -k -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" "https://api.github.com/repos/$AR_REPO/pulls?head=$AR_USER:$1&state=open" | jq -r '.[].number'`
|
||||
if [ ! "$pr_num" == "" ] && [ ! "$pr_num" == "null" ]; then echo 1; else echo 0; fi
|
||||
}
|
||||
|
||||
function git_create_pr(){ # git_create_pr <branch> <title>
|
||||
local pr_branch="$1"
|
||||
local pr_title="$2"
|
||||
local pr_target="$3"
|
||||
local pr_body=""
|
||||
for component in `ls "$AR_COMPS"`; do
|
||||
if [ ! $component == "arduino" ] && [ -d "$AR_COMPS/$component/.git" ]; then
|
||||
pr_body+="$component: "$(git -C "$AR_COMPS/$component" symbolic-ref --short HEAD)" "$(git -C "$AR_COMPS/$component" rev-parse --short HEAD)"\r\n"
|
||||
fi
|
||||
done
|
||||
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'`
|
||||
if [ ! "$done_pr" == "" ] && [ ! "$done_pr" == "null" ]; then echo 1; else echo 0; fi
|
||||
}
|
||||
|
20
tools/copy-bootloader.sh
Executable file
20
tools/copy-bootloader.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
IDF_TARGET=$1
|
||||
FLASH_MODE="$2"
|
||||
FLASH_FREQ="$3"
|
||||
BOOTCONF=$FLASH_MODE"_$FLASH_FREQ"
|
||||
|
||||
source ./tools/config.sh
|
||||
|
||||
echo "Copying bootloader: $AR_SDK/bin/bootloader_$BOOTCONF.bin"
|
||||
|
||||
mkdir -p "$AR_SDK/bin"
|
||||
|
||||
# Workaround for getting the bootloaders to be flashable with esptool v4.x
|
||||
# It might still be needed for IDF5, but using the included esptool instead
|
||||
#cp "build/bootloader/bootloader.bin" "$AR_SDK/bin/bootloader_$BOOTCONF.bin"
|
||||
if [ ! -e "tools/esptool" ]; then
|
||||
git clone https://github.com/espressif/esptool tools/esptool
|
||||
fi
|
||||
./tools/esptool/esptool.py --chip "$IDF_TARGET" elf2image --dont-append-digest "build/bootloader/bootloader.elf" -o "$AR_SDK/bin/bootloader_$BOOTCONF.bin"
|
529
tools/copy-libs.sh
Executable file
529
tools/copy-libs.sh
Executable file
@ -0,0 +1,529 @@
|
||||
#!/bin/bash
|
||||
# config
|
||||
|
||||
IDF_TARGET=$1
|
||||
IS_XTENSA=$4
|
||||
OCT_FLASH="$2"
|
||||
OCT_PSRAM=
|
||||
|
||||
if [ "$3" = "y" ]; then
|
||||
OCT_PSRAM="opi"
|
||||
else
|
||||
OCT_PSRAM="qspi"
|
||||
fi
|
||||
MEMCONF=$OCT_FLASH"_$OCT_PSRAM"
|
||||
|
||||
source ./tools/config.sh
|
||||
|
||||
echo "IDF_TARGET: $IDF_TARGET, MEMCONF: $MEMCONF, PWD: $PWD, OUT: $AR_SDK"
|
||||
|
||||
# clean previous
|
||||
if [ -e "$AR_SDK/sdkconfig" ]; then
|
||||
rm -rf "$AR_SDK/sdkconfig"
|
||||
fi
|
||||
if [ -e "$AR_SDK/lib" ]; then
|
||||
rm -rf "$AR_SDK/lib"
|
||||
fi
|
||||
if [ -e "$AR_SDK/ld" ]; then
|
||||
rm -rf "$AR_SDK/ld"
|
||||
fi
|
||||
if [ -e "$AR_SDK/include" ]; then
|
||||
rm -rf "$AR_SDK/include"
|
||||
fi
|
||||
if [ -e "$AR_SDK/$MEMCONF" ]; then
|
||||
rm -rf "$AR_SDK/$MEMCONF"
|
||||
fi
|
||||
mkdir -p "$AR_SDK"
|
||||
|
||||
function get_actual_path(){
|
||||
p="$PWD"; cd "$1"; r="$PWD"; cd "$p"; echo "$r";
|
||||
}
|
||||
|
||||
#
|
||||
# START OF DATA EXTRACTION FROM CMAKE
|
||||
#
|
||||
|
||||
C_FLAGS=""
|
||||
CPP_FLAGS=""
|
||||
AS_FLAGS=""
|
||||
|
||||
INCLUDES=""
|
||||
DEFINES=""
|
||||
|
||||
LD_FLAGS=""
|
||||
LD_LIBS=""
|
||||
LD_LIB_FILES=""
|
||||
LD_LIBS_SEARCH=""
|
||||
LD_SCRIPTS=""
|
||||
LD_SCRIPT_DIRS=""
|
||||
|
||||
PIO_CC_FLAGS=""
|
||||
PIO_C_FLAGS=""
|
||||
PIO_CXX_FLAGS=""
|
||||
PIO_AS_FLAGS=""
|
||||
PIO_LD_FLAGS=""
|
||||
PIO_LD_FUNCS=""
|
||||
PIO_LD_SCRIPTS=""
|
||||
|
||||
#collect includes, defines and c-flags
|
||||
str=`cat build/compile_commands.json | grep arduino-lib-builder-gcc.c | grep command | cut -d':' -f2 | cut -d',' -f1`
|
||||
str="${str:2:${#str}-1}" #remove leading space and quotes
|
||||
str=`printf '%b' "$str"` #unescape the string
|
||||
set -- $str
|
||||
for item in "${@:2:${#@}-5}"; do
|
||||
prefix="${item:0:2}"
|
||||
if [ "$prefix" = "-I" ]; then
|
||||
item="${item:2}"
|
||||
if [ "${item:0:1}" = "/" ]; then
|
||||
item=`get_actual_path $item`
|
||||
INCLUDES+="$item "
|
||||
elif [ "${item:0:2}" = ".." ]; then
|
||||
if [[ "${item:0:14}" = "../components/" && "${item:0:22}" != "../components/arduino/" ]] || [[ "${item:0:11}" = "../esp-idf/" ]]; then
|
||||
item="$PWD${item:2}"
|
||||
item=`get_actual_path $item`
|
||||
INCLUDES+="$item "
|
||||
fi
|
||||
else
|
||||
item="$PWD/build/$item"
|
||||
item=`get_actual_path $item`
|
||||
INCLUDES+="$item "
|
||||
fi
|
||||
elif [ "$prefix" = "-D" ]; then
|
||||
if [[ "${item:2:7}" != "ARDUINO" ]] && [[ "$item" != "-DESP32" ]]; then #skip ARDUINO defines
|
||||
DEFINES+="$item "
|
||||
fi
|
||||
elif [[ "$item" != "-Wall" && "$item" != "-Werror=all" && "$item" != "-Wextra" ]]; then
|
||||
if [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" ]]; then
|
||||
C_FLAGS+="$item "
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
#collect asm-flags
|
||||
str=`cat build/compile_commands.json | grep arduino-lib-builder-as.S | grep command | cut -d':' -f2 | cut -d',' -f1`
|
||||
str="${str:2:${#str}-1}" #remove leading space and quotes
|
||||
str=`printf '%b' "$str"` #unescape the string
|
||||
set -- $str
|
||||
for item in "${@:2:${#@}-5}"; do
|
||||
prefix="${item:0:2}"
|
||||
if [[ "$prefix" != "-I" && "$prefix" != "-D" && "$item" != "-Wall" && "$item" != "-Werror=all" && "$item" != "-Wextra" ]]; then
|
||||
if [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" ]]; then
|
||||
AS_FLAGS+="$item "
|
||||
if [[ $C_FLAGS == *"$item"* ]]; then
|
||||
PIO_CC_FLAGS+="$item "
|
||||
else
|
||||
PIO_AS_FLAGS+="$item "
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
#collect cpp-flags
|
||||
str=`cat build/compile_commands.json | grep arduino-lib-builder-cpp.cpp | grep command | cut -d':' -f2 | cut -d',' -f1`
|
||||
str="${str:2:${#str}-1}" #remove leading space and quotes
|
||||
str=`printf '%b' "$str"` #unescape the string
|
||||
set -- $str
|
||||
for item in "${@:2:${#@}-5}"; do
|
||||
prefix="${item:0:2}"
|
||||
if [[ "$prefix" != "-I" && "$prefix" != "-D" && "$item" != "-Wall" && "$item" != "-Werror=all" && "$item" != "-Wextra" ]]; then
|
||||
if [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" ]]; then
|
||||
CPP_FLAGS+="$item "
|
||||
if [[ $PIO_CC_FLAGS != *"$item"* ]]; then
|
||||
PIO_CXX_FLAGS+="$item "
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
set -- $C_FLAGS
|
||||
for item; do
|
||||
if [[ $PIO_CC_FLAGS != *"$item"* ]]; then
|
||||
PIO_C_FLAGS+="$item "
|
||||
fi
|
||||
done
|
||||
|
||||
#parse link command to extract libs and flags
|
||||
add_next=0
|
||||
is_dir=0
|
||||
is_script=0
|
||||
if [ -f "build/CMakeFiles/arduino-lib-builder.elf.dir/link.txt" ]; then
|
||||
str=`cat build/CMakeFiles/arduino-lib-builder.elf.dir/link.txt`
|
||||
else
|
||||
libs=`cat build/build.ninja | grep LINK_LIBRARIES`
|
||||
libs="${libs:19:${#libs}-1}"
|
||||
flags=`cat build/build.ninja | grep LINK_FLAGS`
|
||||
flags="${flags:15:${#flags}-1}"
|
||||
if [ "$IDF_TARGET" = "esp32" ]; then
|
||||
flags="-Wno-frame-address $flags"
|
||||
fi
|
||||
if [ "$IDF_TARGET" != "esp32c3" ]; then
|
||||
flags="-mlongcalls $flags"
|
||||
fi
|
||||
str="$flags $libs"
|
||||
fi
|
||||
if [ "$IDF_TARGET" = "esp32" ]; then
|
||||
LD_SCRIPTS+="-T esp32.rom.redefined.ld "
|
||||
PIO_LD_SCRIPTS+="esp32.rom.redefined.ld "
|
||||
fi
|
||||
set -- $str
|
||||
for item; do
|
||||
prefix="${item:0:1}"
|
||||
if [ "$prefix" = "-" ]; then
|
||||
if [ "${item:0:10}" != "-Wl,--Map=" ]; then
|
||||
if [ "$item" = "-L" ]; then # -L /path
|
||||
add_next=1
|
||||
is_dir=1
|
||||
elif [ "${item:0:2}" = "-L" ]; then # -L/path
|
||||
LD_SCRIPT_DIRS+="${item:2} "
|
||||
elif [ "$item" = "-T" ]; then # -T script.ld
|
||||
add_next=1
|
||||
is_script=1
|
||||
LD_SCRIPTS+="$item "
|
||||
elif [ "$item" = "-u" ]; then # -u function_name
|
||||
add_next=1
|
||||
LD_FLAGS+="$item "
|
||||
elif [ "${item:0:2}" = "-l" ]; then # -l[lib_name]
|
||||
LD_LIBS+="$item "
|
||||
exclude_libs=";m;c;gcc;stdc++;"
|
||||
short_name="${item:2}"
|
||||
if [[ $exclude_libs != *";$short_name;"* && $LD_LIBS_SEARCH != *"lib$short_name.a"* ]]; then
|
||||
LD_LIBS_SEARCH+="lib$short_name.a "
|
||||
#echo "lib add: $item"
|
||||
fi
|
||||
elif [ "$item" = "-o" ]; then
|
||||
add_next=0
|
||||
is_script=0
|
||||
is_dir=0
|
||||
elif [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:17}" != "-Wl,--start-group" && "${item:0:15}" != "-Wl,--end-group" ]]; then
|
||||
LD_FLAGS+="$item "
|
||||
PIO_LD_FLAGS+="$item "
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [ "$add_next" = "1" ]; then
|
||||
add_next=0
|
||||
if [ "$is_dir" = "1" ]; then
|
||||
is_dir=0
|
||||
LD_SCRIPT_DIRS+="$item "
|
||||
elif [ "$is_script" = "1" ]; then
|
||||
is_script=0
|
||||
LD_SCRIPTS+="$item "
|
||||
PIO_LD_SCRIPTS+="$item "
|
||||
else
|
||||
LD_FLAGS+="$item "
|
||||
PIO_LD_FUNCS+="$item "
|
||||
fi
|
||||
else
|
||||
if [ "${item:${#item}-2:2}" = ".a" ]; then
|
||||
if [ "${item:0:1}" != "/" ]; then
|
||||
item="$PWD/build/$item"
|
||||
fi
|
||||
lname=$(basename $item)
|
||||
lname="${lname:3:${#lname}-5}"
|
||||
if [[ "$lname" != "main" && "$lname" != "arduino" ]]; then
|
||||
lsize=$($SSTAT "$item")
|
||||
if (( lsize > 8 )); then
|
||||
# do we already have this file?
|
||||
if [[ $LD_LIB_FILES != *"$item"* ]]; then
|
||||
# do we already have lib with the same name?
|
||||
if [[ $LD_LIBS != *"-l$lname"* ]]; then
|
||||
# echo "collecting lib '$lname' and file: $item"
|
||||
LD_LIB_FILES+="$item "
|
||||
LD_LIBS+="-l$lname "
|
||||
else
|
||||
# echo "!!! need to rename: '$lname'"
|
||||
for i in {2..9}; do
|
||||
n_item="${item:0:${#item}-2}_$i.a"
|
||||
n_name=$lname"_$i"
|
||||
if [ -f "$n_item" ]; then
|
||||
# echo "renamed add: -l$n_name"
|
||||
LD_LIBS+="-l$n_name "
|
||||
break
|
||||
elif [[ $LD_LIB_FILES != *"$n_item"* && $LD_LIBS != *"-l$n_name"* ]]; then
|
||||
echo "Renaming '$lname' to '$n_name': $item"
|
||||
cp -f "$item" "$n_item"
|
||||
LD_LIB_FILES+="$n_item "
|
||||
LD_LIBS+="-l$n_name "
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
else
|
||||
# echo "just add: -l$lname"
|
||||
LD_LIBS+="-l$lname "
|
||||
fi
|
||||
else
|
||||
echo "*** Skipping $(basename $item): size too small $lsize"
|
||||
fi
|
||||
fi
|
||||
elif [[ "${item:${#item}-4:4}" = ".obj" || "${item:${#item}-4:4}" = ".elf" || "${item:${#item}-4:4}" = "-g++" ]]; then
|
||||
item="$item"
|
||||
else
|
||||
echo "*** BAD LD ITEM: $item ${item:${#item}-2:2}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
#
|
||||
# END OF DATA EXTRACTION FROM CMAKE
|
||||
#
|
||||
|
||||
AR_PLATFORMIO_PY="$AR_TOOLS/platformio-build-$IDF_TARGET.py"
|
||||
|
||||
# start generation of platformio-build.py
|
||||
awk "/ASFLAGS=\[/{n++}{print>n\"pio_start.txt\"}" $AR_COMPS/arduino/tools/platformio-build-$IDF_TARGET.py
|
||||
awk "/\"ARDUINO_ARCH_ESP32\"/{n++}{print>n\"pio_end.txt\"}" 1pio_start.txt
|
||||
cat pio_start.txt > "$AR_PLATFORMIO_PY"
|
||||
rm pio_end.txt 1pio_start.txt pio_start.txt
|
||||
|
||||
echo " ASFLAGS=[" >> "$AR_PLATFORMIO_PY"
|
||||
if [ "$IS_XTENSA" = "y" ]; then
|
||||
echo " \"-mlongcalls\"" >> "$AR_PLATFORMIO_PY"
|
||||
else
|
||||
echo " \"-march=rv32imc\"" >> "$AR_PLATFORMIO_PY"
|
||||
fi
|
||||
echo " ]," >> "$AR_PLATFORMIO_PY"
|
||||
echo "" >> "$AR_PLATFORMIO_PY"
|
||||
|
||||
echo " ASPPFLAGS=[" >> "$AR_PLATFORMIO_PY"
|
||||
set -- $PIO_AS_FLAGS
|
||||
for item; do
|
||||
echo " \"$item\"," >> "$AR_PLATFORMIO_PY"
|
||||
done
|
||||
echo " \"-x\", \"assembler-with-cpp\"" >> "$AR_PLATFORMIO_PY"
|
||||
echo " ]," >> "$AR_PLATFORMIO_PY"
|
||||
echo "" >> "$AR_PLATFORMIO_PY"
|
||||
|
||||
echo " CFLAGS=[" >> "$AR_PLATFORMIO_PY"
|
||||
set -- $PIO_C_FLAGS
|
||||
last_item="${@: -1}"
|
||||
for item in "${@:0:${#@}}"; do
|
||||
if [ "${item:0:1}" != "/" ]; then
|
||||
echo " \"$item\"," >> "$AR_PLATFORMIO_PY"
|
||||
fi
|
||||
done
|
||||
echo " \"$last_item\"" >> "$AR_PLATFORMIO_PY"
|
||||
echo " ]," >> "$AR_PLATFORMIO_PY"
|
||||
echo "" >> "$AR_PLATFORMIO_PY"
|
||||
|
||||
echo " CXXFLAGS=[" >> "$AR_PLATFORMIO_PY"
|
||||
set -- $PIO_CXX_FLAGS
|
||||
last_item="${@: -1}"
|
||||
for item in "${@:0:${#@}}"; do
|
||||
if [ "${item:0:1}" != "/" ]; then
|
||||
echo " \"$item\"," >> "$AR_PLATFORMIO_PY"
|
||||
fi
|
||||
done
|
||||
echo " \"$last_item\"" >> "$AR_PLATFORMIO_PY"
|
||||
echo " ]," >> "$AR_PLATFORMIO_PY"
|
||||
echo "" >> "$AR_PLATFORMIO_PY"
|
||||
|
||||
echo " CCFLAGS=[" >> "$AR_PLATFORMIO_PY"
|
||||
set -- $PIO_CC_FLAGS
|
||||
for item; do
|
||||
echo " \"$item\"," >> "$AR_PLATFORMIO_PY"
|
||||
done
|
||||
echo " \"-MMD\"" >> "$AR_PLATFORMIO_PY"
|
||||
echo " ]," >> "$AR_PLATFORMIO_PY"
|
||||
echo "" >> "$AR_PLATFORMIO_PY"
|
||||
|
||||
echo " LINKFLAGS=[" >> "$AR_PLATFORMIO_PY"
|
||||
set -- $PIO_LD_FLAGS
|
||||
for item; do
|
||||
echo " \"$item\"," >> "$AR_PLATFORMIO_PY"
|
||||
done
|
||||
set -- $PIO_LD_SCRIPTS
|
||||
for item; do
|
||||
echo " \"-T\", \"$item\"," >> "$AR_PLATFORMIO_PY"
|
||||
done
|
||||
set -- $PIO_LD_FUNCS
|
||||
for item; do
|
||||
echo " \"-u\", \"$item\"," >> "$AR_PLATFORMIO_PY"
|
||||
done
|
||||
echo " '-Wl,-Map=\"%s\"' % join(\"\${BUILD_DIR}\", \"\${PROGNAME}.map\")" >> "$AR_PLATFORMIO_PY"
|
||||
|
||||
echo " ]," >> "$AR_PLATFORMIO_PY"
|
||||
echo "" >> "$AR_PLATFORMIO_PY"
|
||||
|
||||
# # include dirs
|
||||
AR_INC=""
|
||||
echo " CPPPATH=[" >> "$AR_PLATFORMIO_PY"
|
||||
|
||||
set -- $INCLUDES
|
||||
|
||||
for item; do
|
||||
if [[ "$item" != $PWD ]]; then
|
||||
ipath="$item"
|
||||
fname=`basename "$ipath"`
|
||||
dname=`basename $(dirname "$ipath")`
|
||||
if [[ "$fname" == "main" && "$dname" == "esp32-arduino-lib-builder" ]]; then
|
||||
continue
|
||||
fi
|
||||
while [[ "$dname" != "components" && "$dname" != "build" ]]; do
|
||||
ipath=`dirname "$ipath"`
|
||||
fname=`basename "$ipath"`
|
||||
dname=`basename $(dirname "$ipath")`
|
||||
done
|
||||
if [[ "$fname" == "arduino" ]]; then
|
||||
continue
|
||||
fi
|
||||
if [[ "$fname" == "config" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
out_sub="${item#*$ipath}"
|
||||
out_cpath="$AR_SDK/include/$fname$out_sub"
|
||||
AR_INC+=" \"-I{compiler.sdk.path}/include/$fname$out_sub\""
|
||||
if [ "$out_sub" = "" ]; then
|
||||
echo " join(FRAMEWORK_DIR, \"tools\", \"sdk\", \"$IDF_TARGET\", \"include\", \"$fname\")," >> "$AR_PLATFORMIO_PY"
|
||||
else
|
||||
pio_sub="${out_sub:1}"
|
||||
pio_sub=`echo $pio_sub | sed 's/\//\\", \\"/g'`
|
||||
echo " join(FRAMEWORK_DIR, \"tools\", \"sdk\", \"$IDF_TARGET\", \"include\", \"$fname\", \"$pio_sub\")," >> "$AR_PLATFORMIO_PY"
|
||||
fi
|
||||
for f in `find "$item" -name '*.h'`; do
|
||||
rel_f=${f#*$item}
|
||||
rel_p=${rel_f%/*}
|
||||
mkdir -p "$out_cpath$rel_p"
|
||||
cp -n $f "$out_cpath$rel_p/"
|
||||
done
|
||||
for f in `find "$item" -name '*.hpp'`; do
|
||||
rel_f=${f#*$item}
|
||||
rel_p=${rel_f%/*}
|
||||
mkdir -p "$out_cpath$rel_p"
|
||||
cp -n $f "$out_cpath$rel_p/"
|
||||
done
|
||||
fi
|
||||
done
|
||||
echo " join(FRAMEWORK_DIR, \"tools\", \"sdk\", \"$IDF_TARGET\", env.BoardConfig().get(\"build.arduino.memory_type\", \"$MEMCONF\"), \"include\")," >> "$AR_PLATFORMIO_PY"
|
||||
echo " join(FRAMEWORK_DIR, \"cores\", env.BoardConfig().get(\"build.core\"))" >> "$AR_PLATFORMIO_PY"
|
||||
echo " ]," >> "$AR_PLATFORMIO_PY"
|
||||
echo "" >> "$AR_PLATFORMIO_PY"
|
||||
|
||||
mkdir -p "$AR_SDK/lib"
|
||||
|
||||
AR_LIBS="$LD_LIBS"
|
||||
PIO_LIBS=""
|
||||
set -- $LD_LIBS
|
||||
for item; do
|
||||
if [ "$PIO_LIBS" != "" ]; then
|
||||
PIO_LIBS+=", "
|
||||
fi
|
||||
PIO_LIBS+="\"$item\""
|
||||
done
|
||||
|
||||
set -- $LD_LIB_FILES
|
||||
for item; do
|
||||
cp "$item" "$AR_SDK/lib/"
|
||||
done
|
||||
|
||||
echo " LIBPATH=[" >> "$AR_PLATFORMIO_PY"
|
||||
echo " join(FRAMEWORK_DIR, \"tools\", \"sdk\", \"$IDF_TARGET\", \"lib\")," >> "$AR_PLATFORMIO_PY"
|
||||
echo " join(FRAMEWORK_DIR, \"tools\", \"sdk\", \"$IDF_TARGET\", \"ld\")," >> "$AR_PLATFORMIO_PY"
|
||||
echo " join(FRAMEWORK_DIR, \"tools\", \"sdk\", \"$IDF_TARGET\", env.BoardConfig().get(\"build.arduino.memory_type\", \"$MEMCONF\"))" >> "$AR_PLATFORMIO_PY"
|
||||
echo " ]," >> "$AR_PLATFORMIO_PY"
|
||||
echo "" >> "$AR_PLATFORMIO_PY"
|
||||
|
||||
echo " LIBS=[" >> "$AR_PLATFORMIO_PY"
|
||||
echo " $PIO_LIBS" >> "$AR_PLATFORMIO_PY"
|
||||
echo " ]," >> "$AR_PLATFORMIO_PY"
|
||||
echo "" >> "$AR_PLATFORMIO_PY"
|
||||
|
||||
echo " CPPDEFINES=[" >> "$AR_PLATFORMIO_PY"
|
||||
set -- $DEFINES
|
||||
for item; do
|
||||
item="${item:2}" #remove -D
|
||||
if [[ $item == *"="* ]]; then
|
||||
item=(${item//=/ })
|
||||
re='^[+-]?[0-9]+([.][0-9]+)?$'
|
||||
if [[ ${item[1]} =~ $re ]]; then
|
||||
echo " (\"${item[0]}\", ${item[1]})," >> "$AR_PLATFORMIO_PY"
|
||||
else
|
||||
echo " (\"${item[0]}\", '${item[1]}')," >> "$AR_PLATFORMIO_PY"
|
||||
fi
|
||||
else
|
||||
echo " \"$item\"," >> "$AR_PLATFORMIO_PY"
|
||||
fi
|
||||
done
|
||||
|
||||
# remove backslashes for Arduino
|
||||
DEFINES=`echo "$DEFINES" | tr -d '\\'`
|
||||
|
||||
|
||||
# end generation of platformio-build.py
|
||||
cat 1pio_end.txt >> "$AR_PLATFORMIO_PY"
|
||||
rm 1pio_end.txt
|
||||
|
||||
# arduino platform.txt
|
||||
platform_file="$AR_COMPS/arduino/platform.txt"
|
||||
if [ -f "$AR_PLATFORM_TXT" ]; then
|
||||
# use the file we have already compiled for other chips
|
||||
platform_file="$AR_PLATFORM_TXT"
|
||||
fi
|
||||
awk "/compiler.cpreprocessor.flags.$IDF_TARGET=/{n++}{print>n\"platform_start.txt\"}" "$platform_file"
|
||||
$SED -i "/compiler.cpreprocessor.flags.$IDF_TARGET\=/d" 1platform_start.txt
|
||||
awk "/compiler.ar.flags.$IDF_TARGET=/{n++}{print>n\"platform_mid.txt\"}" 1platform_start.txt
|
||||
rm -rf 1platform_start.txt
|
||||
|
||||
cat platform_start.txt > "$AR_PLATFORM_TXT"
|
||||
echo "compiler.cpreprocessor.flags.$IDF_TARGET=$DEFINES $AR_INC" >> "$AR_PLATFORM_TXT"
|
||||
echo "compiler.c.elf.libs.$IDF_TARGET=$AR_LIBS" >> "$AR_PLATFORM_TXT"
|
||||
echo "compiler.c.flags.$IDF_TARGET=$C_FLAGS -MMD -c" >> "$AR_PLATFORM_TXT"
|
||||
echo "compiler.cpp.flags.$IDF_TARGET=$CPP_FLAGS -MMD -c" >> "$AR_PLATFORM_TXT"
|
||||
echo "compiler.S.flags.$IDF_TARGET=$AS_FLAGS -x assembler-with-cpp -MMD -c" >> "$AR_PLATFORM_TXT"
|
||||
echo "compiler.c.elf.flags.$IDF_TARGET=$LD_SCRIPTS $LD_FLAGS" >> "$AR_PLATFORM_TXT"
|
||||
cat 1platform_mid.txt >> "$AR_PLATFORM_TXT"
|
||||
rm -rf platform_start.txt platform_mid.txt 1platform_mid.txt
|
||||
|
||||
# sdkconfig
|
||||
cp -f "sdkconfig" "$AR_SDK/sdkconfig"
|
||||
|
||||
# esptool.py
|
||||
cp "$IDF_COMPS/esptool_py/esptool/esptool.py" "$AR_ESPTOOL_PY"
|
||||
|
||||
# gen_esp32part.py
|
||||
cp "$IDF_COMPS/partition_table/gen_esp32part.py" "$AR_GEN_PART_PY"
|
||||
|
||||
# copy precompiled libs (if we need them)
|
||||
function copy_precompiled_lib(){
|
||||
lib_file="$1"
|
||||
lib_name="$(basename $lib_file)"
|
||||
if [[ $LD_LIBS_SEARCH == *"$lib_name"* ]]; then
|
||||
cp "$lib_file" "$AR_SDK/ld/"
|
||||
fi
|
||||
}
|
||||
|
||||
# idf ld scripts
|
||||
mkdir -p "$AR_SDK/ld"
|
||||
set -- $LD_SCRIPT_DIRS
|
||||
for item; do
|
||||
item="${item%\"}"
|
||||
item="${item#\"}"
|
||||
find "$item" -name '*.ld' -exec cp -f {} "$AR_SDK/ld/" \;
|
||||
for lib in `find "$item" -name '*.a'`; do
|
||||
copy_precompiled_lib "$lib"
|
||||
done
|
||||
done
|
||||
|
||||
# Handle Mem Variants
|
||||
mkdir -p "$AR_SDK/$MEMCONF/include"
|
||||
mv "$PWD/build/config/sdkconfig.h" "$AR_SDK/$MEMCONF/include/sdkconfig.h"
|
||||
for mem_variant in `jq -c '.mem_variants_files[]' configs/builds.json`; do
|
||||
skip_file=1
|
||||
for file_target in $(echo "$mem_variant" | jq -c '.targets[]' | tr -d '"'); do
|
||||
if [ "$file_target" == "$IDF_TARGET" ]; then
|
||||
skip_file=0
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ $skip_file -eq 0 ]; then
|
||||
file=$(echo "$mem_variant" | jq -c '.file' | tr -d '"')
|
||||
out=$(echo "$mem_variant" | jq -c '.out' | tr -d '"')
|
||||
mv "$AR_SDK/$out" "$AR_SDK/$MEMCONF/$file"
|
||||
fi
|
||||
done;
|
||||
|
||||
# Add IDF versions to sdkconfig
|
||||
echo "#define CONFIG_ARDUINO_IDF_COMMIT \"$IDF_COMMIT\"" >> "$AR_SDK/$MEMCONF/include/sdkconfig.h"
|
||||
echo "#define CONFIG_ARDUINO_IDF_BRANCH \"$IDF_BRANCH\"" >> "$AR_SDK/$MEMCONF/include/sdkconfig.h"
|
39
tools/copy-mem-variant.sh
Executable file
39
tools/copy-mem-variant.sh
Executable file
@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
IDF_TARGET=$1
|
||||
OCT_FLASH="$2"
|
||||
OCT_PSRAM=
|
||||
|
||||
if [ "$3" = "y" ]; then
|
||||
OCT_PSRAM="opi"
|
||||
else
|
||||
OCT_PSRAM="qspi"
|
||||
fi
|
||||
|
||||
MEMCONF=$OCT_FLASH"_$OCT_PSRAM"
|
||||
|
||||
source ./tools/config.sh
|
||||
|
||||
echo "IDF_TARGET: $IDF_TARGET, MEMCONF: $MEMCONF"
|
||||
|
||||
# Add IDF versions to sdkconfig
|
||||
echo "#define CONFIG_ARDUINO_IDF_COMMIT \"$IDF_COMMIT\"" >> "build/config/sdkconfig.h"
|
||||
echo "#define CONFIG_ARDUINO_IDF_BRANCH \"$IDF_BRANCH\"" >> "build/config/sdkconfig.h"
|
||||
|
||||
# Handle Mem Variants
|
||||
rm -rf "$AR_SDK/$MEMCONF"
|
||||
mkdir -p "$AR_SDK/$MEMCONF/include"
|
||||
mv "build/config/sdkconfig.h" "$AR_SDK/$MEMCONF/include/sdkconfig.h"
|
||||
for mem_variant in `jq -c '.mem_variants_files[]' configs/builds.json`; do
|
||||
skip_file=1
|
||||
for file_target in $(echo "$mem_variant" | jq -c '.targets[]' | tr -d '"'); do
|
||||
if [ "$file_target" == "$IDF_TARGET" ]; then
|
||||
skip_file=0
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ $skip_file -eq 0 ]; then
|
||||
file=$(echo "$mem_variant" | jq -c '.file' | tr -d '"')
|
||||
src=$(echo "$mem_variant" | jq -c '.src' | tr -d '"')
|
||||
cp "$src" "$AR_SDK/$MEMCONF/$file"
|
||||
fi
|
||||
done;
|
25
tools/copy-to-arduino.sh
Executable file
25
tools/copy-to-arduino.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
source ./tools/config.sh
|
||||
|
||||
if [ -z $ESP32_ARDUINO ]; then
|
||||
if [[ "$AR_OS" == "macos" ]]; then
|
||||
ESP32_ARDUINO="$HOME/Documents/Arduino/hardware/espressif/esp32"
|
||||
else
|
||||
ESP32_ARDUINO="$HOME/Arduino/hardware/espressif/esp32"
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! [ -d "$ESP32_ARDUINO" ]; then
|
||||
echo "ERROR: Target arduino folder does not exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Installing new libraries to $ESP32_ARDUINO"
|
||||
|
||||
rm -rf $ESP32_ARDUINO/tools/sdk $ESP32_ARDUINO/tools/esptool.py $ESP32_ARDUINO/tools/gen_esp32part.py $ESP32_ARDUINO/tools/platformio-build-*.py $ESP32_ARDUINO/platform.txt
|
||||
|
||||
cp -f $AR_OUT/platform.txt $ESP32_ARDUINO/
|
||||
cp -Rf $AR_TOOLS/sdk $ESP32_ARDUINO/tools/
|
||||
cp -f $AR_TOOLS/esptool.py $ESP32_ARDUINO/tools/
|
||||
cp -f $AR_TOOLS/gen_esp32part.py $ESP32_ARDUINO/tools/
|
||||
cp -f $AR_TOOLS/platformio-build-*.py $ESP32_ARDUINO/tools/
|
10
tools/cron.sh
Normal file
10
tools/cron.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! "$GITHUB_EVENT_NAME" == "schedule" ]; then
|
||||
echo "Wrong event '$GITHUB_EVENT_NAME'!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git checkout "$IDF_BRANCH" #local branches should match what the matrix wants to build
|
||||
source ./build.sh
|
||||
bash ./tools/push-to-arduino.sh
|
2
tools/current_commit.sh
Executable file
2
tools/current_commit.sh
Executable file
@ -0,0 +1,2 @@
|
||||
IDF_COMMIT=$(wget -q -O- "https://github.com/espressif/arduino-esp32/search?q=update+idf&type=Commits" | grep -i "update idf" | grep -e "to [0-9a-f]*" | sed "s/^.*to \([0-9a-f]*\).*/\1/" | head -1)
|
||||
echo Current commit is $IDF_COMMIT
|
102
tools/install-esp-idf.sh
Executable file
102
tools/install-esp-idf.sh
Executable file
@ -0,0 +1,102 @@
|
||||
#/bin/bash
|
||||
|
||||
source ./tools/config.sh
|
||||
|
||||
if ! [ -x "$(command -v $SED)" ]; then
|
||||
echo "ERROR: $SED is not installed! Please install $SED first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#
|
||||
# CLONE ESP-IDF
|
||||
#
|
||||
|
||||
IDF_REPO_URL="https://github.com/espressif/esp-idf.git"
|
||||
if [ ! -d "$IDF_PATH" ]; then
|
||||
echo "ESP-IDF is not installed! Installing local copy"
|
||||
git clone $IDF_REPO_URL -b $IDF_BRANCH
|
||||
idf_was_installed="1"
|
||||
fi
|
||||
|
||||
if [ "$IDF_COMMIT" ]; then
|
||||
git -C "$IDF_PATH" checkout "$IDF_COMMIT"
|
||||
commit_predefined="1"
|
||||
fi
|
||||
|
||||
#
|
||||
# UPDATE ESP-IDF TOOLS AND MODULES
|
||||
#
|
||||
|
||||
if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then
|
||||
git -C $IDF_PATH submodule update --init --recursive
|
||||
$IDF_PATH/install.sh
|
||||
fi
|
||||
|
||||
#
|
||||
# SETUP ESP-IDF ENV
|
||||
#
|
||||
|
||||
source $IDF_PATH/export.sh
|
||||
export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD)
|
||||
export IDF_BRANCH=$(git -C "$IDF_PATH" symbolic-ref --short HEAD)
|
||||
|
||||
#
|
||||
# SETUP ARDUINO DEPLOY
|
||||
#
|
||||
|
||||
if [ "$GITHUB_EVENT_NAME" == "schedule" ] || [ "$GITHUB_EVENT_NAME" == "repository_dispatch" -a "$GITHUB_EVENT_ACTION" == "deploy" ]; then
|
||||
# format new branch name and pr title
|
||||
if [ -x $commit_predefined ]; then #commit was not specified at build time
|
||||
AR_NEW_BRANCH_NAME="idf-$IDF_BRANCH"
|
||||
AR_NEW_COMMIT_MESSAGE="IDF $IDF_BRANCH $IDF_COMMIT"
|
||||
AR_NEW_PR_TITLE="IDF $IDF_BRANCH"
|
||||
else
|
||||
AR_NEW_BRANCH_NAME="idf-$IDF_COMMIT"
|
||||
AR_NEW_COMMIT_MESSAGE="IDF $IDF_COMMIT"
|
||||
AR_NEW_PR_TITLE="$AR_NEW_COMMIT_MESSAGE"
|
||||
fi
|
||||
|
||||
AR_HAS_COMMIT=`git_commit_exists "$AR_COMPS/arduino" "$AR_NEW_COMMIT_MESSAGE"`
|
||||
AR_HAS_BRANCH=`git_branch_exists "$AR_COMPS/arduino" "$AR_NEW_BRANCH_NAME"`
|
||||
AR_HAS_PR=`git_pr_exists "$AR_NEW_BRANCH_NAME"`
|
||||
|
||||
if [ "$AR_HAS_COMMIT" == "1" ]; then
|
||||
echo "Commit '$AR_NEW_COMMIT_MESSAGE' Already Exists"
|
||||
mkdir -p dist && echo "Commit '$AR_NEW_COMMIT_MESSAGE' Already Exists" > dist/log.txt
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$AR_HAS_BRANCH" == "1" ]; then
|
||||
echo "Branch '$AR_NEW_BRANCH_NAME' Already Exists"
|
||||
fi
|
||||
|
||||
if [ "$AR_HAS_PR" == "1" ]; then
|
||||
echo "PR '$AR_NEW_PR_TITLE' Already Exists"
|
||||
fi
|
||||
|
||||
# setup git for pushing
|
||||
git config --global github.user "$GITHUB_ACTOR"
|
||||
git config --global user.name "$GITHUB_ACTOR"
|
||||
git config --global user.email "$GITHUB_ACTOR@github.com"
|
||||
|
||||
# create or checkout the branch
|
||||
if [ ! $AR_HAS_BRANCH == "0" ]; then
|
||||
echo "Switching to arduino branch '$AR_NEW_BRANCH_NAME'..."
|
||||
git -C "$AR_COMPS/arduino" checkout $AR_NEW_BRANCH_NAME
|
||||
else
|
||||
echo "Creating arduino branch '$AR_NEW_BRANCH_NAME'..."
|
||||
git -C "$AR_COMPS/arduino" checkout -b $AR_NEW_BRANCH_NAME
|
||||
fi
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: Checkout of branch '$AR_NEW_BRANCH_NAME' failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export AR_NEW_BRANCH_NAME
|
||||
export AR_NEW_COMMIT_MESSAGE
|
||||
export AR_NEW_PR_TITLE
|
||||
|
||||
export AR_HAS_COMMIT
|
||||
export AR_HAS_BRANCH
|
||||
export AR_HAS_PR
|
||||
fi
|
5
tools/prepare-ci.sh
Executable file
5
tools/prepare-ci.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
sudo apt-get install -y git wget curl libssl-dev libncurses-dev flex bison gperf python3 cmake ninja-build ccache
|
||||
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3 get-pip.py && \
|
||||
pip3 install setuptools pyserial click future wheel cryptography pyparsing pyelftools
|
54
tools/push-to-arduino.sh
Executable file
54
tools/push-to-arduino.sh
Executable file
@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
source ./tools/config.sh
|
||||
|
||||
if [ -x $GITHUB_TOKEN ]; then
|
||||
echo "ERROR: GITHUB_TOKEN was not defined"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [ -d "$AR_COMPS/arduino" ]; then
|
||||
echo "ERROR: Target arduino folder does not exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#
|
||||
# UPDATE FILES
|
||||
#
|
||||
|
||||
if [ $AR_HAS_COMMIT == "0" ]; then
|
||||
# make changes to the files
|
||||
echo "Patching files in branch '$AR_NEW_BRANCH_NAME'..."
|
||||
ESP32_ARDUINO="$AR_COMPS/arduino" ./tools/copy-to-arduino.sh
|
||||
|
||||
cd $AR_COMPS/arduino
|
||||
|
||||
# did any of the files change?
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo "Pushing changes to branch '$AR_NEW_BRANCH_NAME'..."
|
||||
git add . && git commit --message "$AR_NEW_COMMIT_MESSAGE" && git push -u origin $AR_NEW_BRANCH_NAME
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: Pushing to branch '$AR_NEW_BRANCH_NAME' failed"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "No changes in branch '$AR_NEW_BRANCH_NAME'"
|
||||
if [ $AR_HAS_BRANCH == "0" ]; then
|
||||
echo "Delete created branch '$AR_NEW_BRANCH_NAME'"
|
||||
git branch -d $AR_NEW_BRANCH_NAME
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# CREATE PULL REQUEST
|
||||
#
|
||||
|
||||
if [ "$AR_HAS_PR" == "0" ]; then
|
||||
pr_created=`git_create_pr "$AR_NEW_BRANCH_NAME" "$AR_NEW_PR_TITLE" "$AR_PR_TARGET_BRANCH"`
|
||||
if [ $pr_created == "0" ]; then
|
||||
echo "ERROR: Failed to create PR '$AR_NEW_PR_TITLE': "`echo "$git_create_pr_res" | jq -r '.message'`": "`echo "$git_create_pr_res" | jq -r '.errors[].message'`
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
exit 0
|
46
tools/repository_dispatch.sh
Normal file
46
tools/repository_dispatch.sh
Normal file
@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! "$GITHUB_EVENT_NAME" == "repository_dispatch" ]; then
|
||||
echo "Wrong event '$GITHUB_EVENT_NAME'!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
EVENT_JSON=`cat "$GITHUB_EVENT_PATH"`
|
||||
action=`echo "$EVENT_JSON" | jq -r '.action'`
|
||||
payload=`echo "$EVENT_JSON" | jq -r '.client_payload'`
|
||||
branch=`echo "$payload" | jq -r '.branch'`
|
||||
commit=`echo "$payload" | jq -r '.commit'`
|
||||
builder=`echo "$payload" | jq -r '.builder'`
|
||||
arduino=`echo "$payload" | jq -r '.arduino'`
|
||||
|
||||
echo "Action: $action, Branch: $branch, Commit: $commit, Builder: $builder"
|
||||
|
||||
if [ ! "$action" == "deploy" ] && [ ! "$action" == "build" ]; then
|
||||
echo "Bad Action $action"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export GITHUB_EVENT_ACTION="$action"
|
||||
|
||||
if [ ! "$commit" == "" ] && [ ! "$commit" == "null" ]; then
|
||||
export IDF_COMMIT="$commit"
|
||||
else
|
||||
commit=""
|
||||
if [ ! "$branch" == "" ] && [ ! "$branch" == "null" ]; then
|
||||
export IDF_BRANCH="$branch"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! "$builder" == "" ] && [ ! "$builder" == "null" ]; then
|
||||
git checkout "$builder"
|
||||
fi
|
||||
|
||||
if [ ! "$arduino" == "" ] && [ ! "$arduino" == "null" ]; then
|
||||
export AR_BRANCH="$arduino"
|
||||
fi
|
||||
|
||||
source ./build.sh
|
||||
|
||||
if [ "$action" == "deploy" ]; then
|
||||
bash ./tools/push-to-arduino.sh
|
||||
fi
|
146
tools/update-components.sh
Executable file
146
tools/update-components.sh
Executable file
@ -0,0 +1,146 @@
|
||||
#/bin/bash
|
||||
|
||||
source ./tools/config.sh
|
||||
|
||||
CAMERA_REPO_URL="https://github.com/espressif/esp32-camera.git"
|
||||
DL_REPO_URL="https://github.com/espressif/esp-dl.git"
|
||||
SR_REPO_URL="https://github.com/espressif/esp-sr.git"
|
||||
RMAKER_REPO_URL="https://github.com/espressif/esp-rainmaker.git"
|
||||
DSP_REPO_URL="https://github.com/espressif/esp-dsp.git"
|
||||
LITTLEFS_REPO_URL="https://github.com/joltwallet/esp_littlefs.git"
|
||||
TINYUSB_REPO_URL="https://github.com/hathach/tinyusb.git"
|
||||
|
||||
#
|
||||
# CLONE/UPDATE ARDUINO
|
||||
#
|
||||
|
||||
if [ ! -d "$AR_COMPS/arduino" ]; then
|
||||
git clone $AR_REPO_URL "$AR_COMPS/arduino"
|
||||
fi
|
||||
|
||||
if [ -z $AR_BRANCH ]; then
|
||||
if [ -z $GITHUB_HEAD_REF ]; then
|
||||
current_branch=`git branch --show-current`
|
||||
else
|
||||
current_branch="$GITHUB_HEAD_REF"
|
||||
fi
|
||||
echo "Current Branch: $current_branch"
|
||||
if [[ "$current_branch" != "master" && `git_branch_exists "$AR_COMPS/arduino" "$current_branch"` == "1" ]]; then
|
||||
export AR_BRANCH="$current_branch"
|
||||
else
|
||||
has_ar_branch=`git_branch_exists "$AR_COMPS/arduino" "idf-$IDF_BRANCH"`
|
||||
if [ "$has_ar_branch" == "1" ]; then
|
||||
export AR_BRANCH="idf-$IDF_BRANCH"
|
||||
else
|
||||
has_ar_branch=`git_branch_exists "$AR_COMPS/arduino" "$AR_PR_TARGET_BRANCH"`
|
||||
if [ "$has_ar_branch" == "1" ]; then
|
||||
export AR_BRANCH="$AR_PR_TARGET_BRANCH"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$AR_BRANCH" ]; then
|
||||
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
|
||||
|
||||
#
|
||||
# CLONE/UPDATE ESP32-CAMERA
|
||||
#
|
||||
|
||||
if [ ! -d "$AR_COMPS/esp32-camera" ]; then
|
||||
git clone $CAMERA_REPO_URL "$AR_COMPS/esp32-camera"
|
||||
else
|
||||
git -C "$AR_COMPS/esp32-camera" fetch && \
|
||||
git -C "$AR_COMPS/esp32-camera" pull --ff-only
|
||||
fi
|
||||
#this is a temp measure to fix build issue in recent IDF master
|
||||
if [ -f "$AR_COMPS/esp32-camera/idf_component.yml" ]; then
|
||||
rm -rf "$AR_COMPS/esp32-camera/idf_component.yml"
|
||||
fi
|
||||
if [ $? -ne 0 ]; then exit 1; fi
|
||||
|
||||
#
|
||||
# CLONE/UPDATE ESP-DL
|
||||
#
|
||||
|
||||
if [ ! -d "$AR_COMPS/esp-dl" ]; then
|
||||
git clone $DL_REPO_URL "$AR_COMPS/esp-dl"
|
||||
else
|
||||
git -C "$AR_COMPS/esp-dl" fetch && \
|
||||
git -C "$AR_COMPS/esp-dl" pull --ff-only
|
||||
fi
|
||||
if [ $? -ne 0 ]; then exit 1; fi
|
||||
|
||||
#
|
||||
# CLONE/UPDATE ESP-SR
|
||||
#
|
||||
|
||||
if [ ! -d "$AR_COMPS/esp-sr" ]; then
|
||||
git clone $SR_REPO_URL "$AR_COMPS/esp-sr"
|
||||
else
|
||||
git -C "$AR_COMPS/esp-sr" fetch && \
|
||||
git -C "$AR_COMPS/esp-sr" pull --ff-only
|
||||
fi
|
||||
if [ $? -ne 0 ]; then exit 1; fi
|
||||
|
||||
#
|
||||
# CLONE/UPDATE ESP-LITTLEFS
|
||||
#
|
||||
|
||||
if [ ! -d "$AR_COMPS/esp_littlefs" ]; then
|
||||
git clone $LITTLEFS_REPO_URL "$AR_COMPS/esp_littlefs" && \
|
||||
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" submodule update --init --recursive
|
||||
fi
|
||||
if [ $? -ne 0 ]; then exit 1; fi
|
||||
|
||||
#
|
||||
# CLONE/UPDATE ESP-RAINMAKER
|
||||
#
|
||||
|
||||
if [ ! -d "$AR_COMPS/esp-rainmaker" ]; then
|
||||
git clone $RMAKER_REPO_URL "$AR_COMPS/esp-rainmaker" && \
|
||||
git -C "$AR_COMPS/esp-rainmaker" submodule update --init --recursive
|
||||
# git -C "$AR_COMPS/esp-rainmaker" checkout f1b82c71c4536ab816d17df016d8afe106bd60e3
|
||||
else
|
||||
git -C "$AR_COMPS/esp-rainmaker" fetch && \
|
||||
git -C "$AR_COMPS/esp-rainmaker" pull --ff-only && \
|
||||
git -C "$AR_COMPS/esp-rainmaker" submodule update --init --recursive
|
||||
fi
|
||||
if [ $? -ne 0 ]; then exit 1; fi
|
||||
|
||||
#
|
||||
# CLONE/UPDATE ESP-DSP
|
||||
#
|
||||
|
||||
if [ ! -d "$AR_COMPS/esp-dsp" ]; then
|
||||
git clone $DSP_REPO_URL "$AR_COMPS/esp-dsp"
|
||||
# cml=`cat "$AR_COMPS/esp-dsp/CMakeLists.txt"`
|
||||
# echo "if(IDF_TARGET STREQUAL \"esp32\" OR IDF_TARGET STREQUAL \"esp32s2\" OR IDF_TARGET STREQUAL \"esp32s3\")" > "$AR_COMPS/esp-dsp/CMakeLists.txt"
|
||||
# echo "$cml" >> "$AR_COMPS/esp-dsp/CMakeLists.txt"
|
||||
# echo "endif()" >> "$AR_COMPS/esp-dsp/CMakeLists.txt"
|
||||
else
|
||||
git -C "$AR_COMPS/esp-dsp" fetch && \
|
||||
git -C "$AR_COMPS/esp-dsp" pull --ff-only
|
||||
fi
|
||||
if [ $? -ne 0 ]; then exit 1; fi
|
||||
|
||||
#
|
||||
# CLONE/UPDATE TINYUSB
|
||||
#
|
||||
|
||||
if [ ! -d "$AR_COMPS/arduino_tinyusb/tinyusb" ]; then
|
||||
git clone $TINYUSB_REPO_URL "$AR_COMPS/arduino_tinyusb/tinyusb"
|
||||
else
|
||||
git -C "$AR_COMPS/arduino_tinyusb/tinyusb" fetch && \
|
||||
git -C "$AR_COMPS/arduino_tinyusb/tinyusb" pull --ff-only
|
||||
fi
|
||||
if [ $? -ne 0 ]; then exit 1; fi
|
||||
|
Reference in New Issue
Block a user