Skip to content

Commit

Permalink
feat: update build
Browse files Browse the repository at this point in the history
  • Loading branch information
Lzw655 committed Feb 2, 2024
1 parent b45d231 commit dda10fd
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 40 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# ESP32 Arduino Lib Builder [![ESP32 Arduino Libs CI](https://github.com/espressif/esp32-arduino-lib-builder/actions/workflows/push.yml/badge.svg)](https://github.com/espressif/esp32-arduino-lib-builder/actions/workflows/push.yml)
# ESP32 Arduino Lib Builder

This repository contains the scripts that produce the libraries included with esp32-arduino.

Tested on Ubuntu (32 and 64 bit), Raspberry Pi and MacOS.

### Build on Ubuntu and Raspberry Pi
```bash
git clone -b release/v2.0.13 https://github.com/esp-arduino-libs/esp32-arduino-lib-builder.git
cd esp32-arduino-lib-builder

```bash
// Build all targets
./build.sh

Expand Down
34 changes: 15 additions & 19 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ TARGET="all"
BUILD_TYPE="all"
SKIP_ENV=0
COPY_OUT=0
ARCHIVE_OUT=0
if [ -z $DEPLOY_OUT ]; then
DEPLOY_OUT=0
fi
Expand All @@ -24,6 +25,7 @@ function print_help() {
echo " -A Set which branch of arduino-esp32 to be used for compilation"
echo " -I Set which branch of ESP-IDF to be used for compilation"
echo " -i Set which commit of ESP-IDF to be used for compilation"
echo " -e Archive the build to dist"
echo " -d Deploy the build to github arduino-esp32"
echo " -c Set the arduino-esp32 folder to copy the result to. ex. '$HOME/Arduino/hardware/espressif/esp32'"
echo " -t Set the build target(chip). ex. 'esp32s3'"
Expand All @@ -32,14 +34,17 @@ function print_help() {
exit 1
}

while getopts ":A:I:i:c:t:b:sd" opt; do
while getopts ":A:I:i:c:t:b:sde" opt; do
case ${opt} in
s )
SKIP_ENV=1
;;
d )
DEPLOY_OUT=1
;;
e )
ARCHIVE_OUT=1
;;
c )
export ESP32_ARDUINO="$OPTARG"
COPY_OUT=1
Expand All @@ -58,10 +63,10 @@ while getopts ":A:I:i:c:t:b:sd" opt; do
;;
b )
b=$OPTARG
if [ "$b" != "build" ] &&
[ "$b" != "menuconfig" ] &&
[ "$b" != "idf_libs" ] &&
[ "$b" != "copy_bootloader" ] &&
if [ "$b" != "build" ] &&
[ "$b" != "menuconfig" ] &&
[ "$b" != "idf_libs" ] &&
[ "$b" != "copy_bootloader" ] &&
[ "$b" != "mem_variant" ]; then
print_help
fi
Expand All @@ -80,6 +85,8 @@ done
shift $((OPTIND -1))
CONFIGS=$@

source ./tools/config.sh

if [ $SKIP_ENV -eq 0 ]; then
echo "* Installing/Updating ESP-IDF and all components..."
# update components from git
Expand All @@ -89,8 +96,6 @@ if [ $SKIP_ENV -eq 0 ]; then
# install esp-idf
source ./tools/install-esp-idf.sh
if [ $? -ne 0 ]; then exit 1; fi
else
source ./tools/config.sh
fi

if [ "$BUILD_TYPE" != "all" ]; then
Expand All @@ -99,7 +104,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 '"')
Expand Down Expand Up @@ -196,16 +201,7 @@ if [ "$BUILD_TYPE" = "all" ]; then
fi

# archive the build
if [ "$BUILD_TYPE" = "all" ]; then
./tools/archive-build.sh
if [ $ARCHIVE_OUT -eq 1 ]; then
./tools/archive-build.sh "$TARGET"
if [ $? -ne 0 ]; then exit 1; fi
fi

# copy everything to arduino-esp32 installation
if [ $COPY_OUT -eq 1 ] && [ -d "$ESP32_ARDUINO" ]; then
./tools/copy-to-arduino.sh
fi

if [ $DEPLOY_OUT -eq 1 ]; then
./tools/push-to-arduino.sh
fi
12 changes: 4 additions & 8 deletions tools/archive-build.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#!/bin/bash

IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD || echo "")
IDF_BRANCH=$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD || echo "")
source ./tools/config.sh

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"
archive_path="dist/arduino-esp32-libs-$1-$idf_version_string.tar.gz"

mkdir -p dist && rm -rf "$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
6 changes: 2 additions & 4 deletions tools/config.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#!/bin/bash

export IDF_BRANCH="release/v4.4"
export IDF_COMMIT="ac5d805d0e"

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="release/v2.x"
fi
Expand Down
3 changes: 2 additions & 1 deletion tools/current_commit.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
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)
source ./tools/config.sh

echo Current commit is $IDF_COMMIT
4 changes: 0 additions & 4 deletions tools/install-esp-idf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

source ./tools/config.sh

IDF_COMMIT="ac5d805d0e"

if ! [ -x "$(command -v $SED)" ]; then
echo "ERROR: $SED is not installed! Please install $SED first."
exit 1
Expand Down Expand Up @@ -39,8 +37,6 @@ fi
#

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 || git -C "$IDF_PATH" tag --points-at HEAD)

#
# SETUP ARDUINO DEPLOY
Expand Down

0 comments on commit dda10fd

Please sign in to comment.