mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
1.9.4 - Merge remote-tracking branch 'origin/dev'
This commit is contained in:
35
scripts/build.sh
Normal file → Executable file
35
scripts/build.sh
Normal file → Executable file
@@ -11,16 +11,13 @@ is_git() {
|
||||
}
|
||||
|
||||
stat_bytes() {
|
||||
echo "size is:"
|
||||
case "$(uname -s)" in
|
||||
Darwin) stat -f %z "$1";;
|
||||
*) stat -c %s "$1";;
|
||||
esac
|
||||
filesize=`du -k "$1" | cut -f1;`
|
||||
echo 'size:' $filesize 'bytes'
|
||||
}
|
||||
|
||||
# Available environments
|
||||
list_envs() {
|
||||
grep env: ../platformio.ini | sed 's/\[env:\(.*\)\]/\1/g'
|
||||
grep env: platformio.ini | sed 's/\[env:\(.*\)\]/\1/g'
|
||||
}
|
||||
|
||||
print_available() {
|
||||
@@ -59,7 +56,7 @@ set_default_environments() {
|
||||
}
|
||||
|
||||
build_webui() {
|
||||
cd ../tools/webfilesbuilder
|
||||
cd ./tools/webfilesbuilder
|
||||
|
||||
# Build system uses gulpscript.js to build web interface
|
||||
if [ ! -e node_modules/gulp/bin/gulp.js ]; then
|
||||
@@ -73,26 +70,22 @@ build_webui() {
|
||||
echo "Building web interface..."
|
||||
node node_modules/gulp/bin/gulp.js || exit
|
||||
|
||||
# TODO: do something if webui files are different
|
||||
# for now, just print in travis log
|
||||
if ${TRAVIS:-false}; then
|
||||
git --no-pager diff --stat
|
||||
fi
|
||||
|
||||
cd ../..
|
||||
}
|
||||
|
||||
build_environments() {
|
||||
echo "--------------------------------------------------------------"
|
||||
echo "Building firmware images..."
|
||||
mkdir -p $destination/EMS-ESP-$version
|
||||
# don't move to firmware folder until Travis fixed (see https://github.com/travis-ci/dpl/issues/846#issuecomment-547157406)
|
||||
# mkdir -p $destination
|
||||
|
||||
for environment in $environments; do
|
||||
echo -n "* EMS-ESP-$version-$environment.bin --- "
|
||||
echo "* EMS-ESP-$version-$environment.bin"
|
||||
platformio run --silent --environment $environment || exit 1
|
||||
stat_bytes .pio/build/$environment/firmware.bin
|
||||
[[ "${TRAVIS_BUILD_STAGE_NAME}" = "Test" ]] || \
|
||||
mv .pio/build/$environment/firmware.bin $destination/EMS-ESP-$version/EMS-ESP-$version-$environment.bin
|
||||
# mv .pio/build/$environment/firmware.bin $destination/EMS-ESP-$version-$environment.bin
|
||||
# mv .pio/build/$environment/firmware.bin EMS-ESP-$version-$environment.bin
|
||||
mv .pio/build/$environment/firmware.bin EMS-ESP-dev-$environment.bin
|
||||
done
|
||||
echo "--------------------------------------------------------------"
|
||||
}
|
||||
@@ -101,7 +94,7 @@ build_environments() {
|
||||
####### MAIN
|
||||
|
||||
destination=firmware
|
||||
version_file=../src/version.h
|
||||
version_file=./src/version.h
|
||||
version=$(grep -E '^#define APP_VERSION' $version_file | awk '{print $3}' | sed 's/"//g')
|
||||
|
||||
if ${TRAVIS:-false}; then
|
||||
@@ -115,6 +108,8 @@ else
|
||||
git_tag=
|
||||
fi
|
||||
|
||||
echo $git_tag
|
||||
|
||||
if [[ -n $git_tag ]]; then
|
||||
new_version=${version/-*}
|
||||
sed -i -e "s@$version@$new_version@" $version_file
|
||||
@@ -139,7 +134,7 @@ fi
|
||||
travis=$(list_envs | grep travis | sort)
|
||||
|
||||
# get all taregts, excluding travis and debug
|
||||
available=$(list_envs | grep -Ev -- 'travis|debug' | sort)
|
||||
available=$(list_envs | grep -Ev -- 'travis|debug|release' | sort)
|
||||
|
||||
export PLATFORMIO_BUILD_FLAGS="${PLATFORMIO_BUILD_FLAGS}"
|
||||
|
||||
@@ -183,7 +178,7 @@ fi
|
||||
# for debugging
|
||||
echo "* git_revision = $git_revision"
|
||||
echo "* git_tag = $git_tag"
|
||||
echo "* TRAVIS_EVENT_TYPE = $TRAVIS_EVENT_TYPE"
|
||||
echo "* TRAVIS_COMMIT = $TRAVIS_COMMIT"
|
||||
echo "* TRAVIS_TAG = $TRAVIS_TAG"
|
||||
echo "* TRAVIS_BRANCH = $TRAVIS_BRANCH"
|
||||
echo "* TRAVIS_BUILD_STAGE_NAME = $TRAVIS_BUILD_STAGE_NAME"
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
Import("env")
|
||||
|
||||
env.Execute("node ./tools/webfilesbuilder/node_modules/gulp/bin/gulp.js --silent --cwd ./tools/webfilesbuilder")
|
||||
@@ -1,26 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
from subprocess import call
|
||||
import os
|
||||
Import("env")
|
||||
|
||||
def code_check(source, target, env):
|
||||
print("\n** Starting cppcheck...")
|
||||
call(["cppcheck", os.getcwd()+"/.", "--force", "--enable=all"])
|
||||
print("\n** Finished cppcheck...\n")
|
||||
print("\n** Starting cpplint...")
|
||||
call(["cpplint", "--extensions=ino,cpp,h", "--filter=-legal/copyright,-build/include,-whitespace",
|
||||
"--linelength=120", "--recursive", "src", "lib/myESP"])
|
||||
print("\n** Finished cpplint...")
|
||||
|
||||
#my_flags = env.ParseFlags(env['BUILD_FLAGS'])
|
||||
#defines = {k: v for (k, v) in my_flags.get("CPPDEFINES")}
|
||||
# print defines
|
||||
# print env.Dump()
|
||||
|
||||
# built in targets: (buildprog, size, upload, program, buildfs, uploadfs, uploadfsota)
|
||||
env.AddPreAction("buildprog", code_check)
|
||||
# env.AddPostAction(.....)
|
||||
|
||||
# see http://docs.platformio.org/en/latest/projectconf/advanced_scripting.html#before-pre-and-after-post-actions
|
||||
# env.Replace(PROGNAME="firmware_%s" % defines.get("VERSION"))
|
||||
# env.Replace(PROGNAME="firmware_%s" % env['BOARD'])
|
||||
37
scripts/main_script.py
Normal file
37
scripts/main_script.py
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python
|
||||
Import("env")
|
||||
|
||||
class Color(object):
|
||||
BLACK = '\x1b[1;30m'
|
||||
RED = '\x1b[1;31m'
|
||||
GREEN = '\x1b[1;32m'
|
||||
YELLOW = '\x1b[1;33m'
|
||||
BLUE = '\x1b[1;34m'
|
||||
MAGENTA = '\x1b[1;35m'
|
||||
CYAN = '\x1b[1;36m'
|
||||
WHITE = '\x1b[1;37m'
|
||||
LIGHT_GREY = '\x1b[0;30m'
|
||||
LIGHT_RED = '\x1b[0;31m'
|
||||
LIGHT_GREEN = '\x1b[0;32m'
|
||||
LIGHT_YELLOW = '\x1b[0;33m'
|
||||
LIGHT_BLUE = '\x1b[0;34m'
|
||||
LIGHT_MAGENTA = '\x1b[0;35m'
|
||||
LIGHT_CYAN = '\x1b[0;36m'
|
||||
LIGHT_WHITE = '\x1b[0;37m'
|
||||
|
||||
|
||||
def clr(color, text):
|
||||
return color + str(text) + '\x1b[0m'
|
||||
|
||||
def remove_float_support():
|
||||
flags = " ".join(env['LINKFLAGS'])
|
||||
print(clr(Color.BLUE, "** LINKFLAGS = %ss" % flags))
|
||||
flags = flags.replace("-u _printf_float", "")
|
||||
flags = flags.replace("-u _scanf_float", "")
|
||||
newflags = flags.split()
|
||||
|
||||
env.Replace(
|
||||
LINKFLAGS=newflags
|
||||
)
|
||||
|
||||
remove_float_support()
|
||||
@@ -4,10 +4,25 @@ import os
|
||||
import re
|
||||
Import("env")
|
||||
|
||||
def build_web(source, target, env):
|
||||
print("\n** Build web...")
|
||||
call(["gulp", "-f", os.getcwd()+"/tools/webfilesbuilder/gulpfile.js"])
|
||||
def build_web():
|
||||
print("** Building web...")
|
||||
env.Execute(
|
||||
"node ./tools/webfilesbuilder/node_modules/gulp/bin/gulp.js --cwd ./tools/webfilesbuilder")
|
||||
|
||||
def code_check(source, target, env):
|
||||
print("** Starting cppcheck...")
|
||||
call(["cppcheck", os.getcwd()+"/.", "--force", "--enable=all"])
|
||||
print("\n** Finished cppcheck...\n")
|
||||
print("\n** Starting cpplint...")
|
||||
call(["cpplint", "--extensions=ino,cpp,h", "--filter=-legal/copyright,-build/include,-whitespace",
|
||||
"--linelength=120", "--recursive", "src", "lib/myESP"])
|
||||
print("\n** Finished cpplint...")
|
||||
|
||||
|
||||
# build web files
|
||||
build_web()
|
||||
|
||||
# extract application details
|
||||
bag = {}
|
||||
exprs = [
|
||||
(re.compile(r'^#define APP_VERSION\s+"(\S+)"'), 'app_version'),
|
||||
@@ -31,16 +46,9 @@ with open('./src/ems-esp.cpp', 'r') as f:
|
||||
app_version = bag.get('app_version')
|
||||
app_name = bag.get('app_name')
|
||||
app_hostname = bag.get('app_hostname')
|
||||
|
||||
board = env['BOARD']
|
||||
branch = env['PIOENV']
|
||||
|
||||
# build the web files
|
||||
env.AddPreAction("buildprog", build_web)
|
||||
|
||||
# build filename, replacing . with _ for the version
|
||||
#env.Replace(PROGNAME="firmware_%s" % branch + "_" + app_version.replace(".", "_"))
|
||||
#env.Replace(PROGNAME=app_name + "-" + app_version.replace(".", "_") + "-" + board + "-" + branch)
|
||||
env.Replace(PROGNAME=app_name + "-" + app_version.replace(".", "_") + "-" + board)
|
||||
|
||||
|
||||
env.Replace(PROGNAME=app_name + "-" +
|
||||
app_version.replace(".", "_") + "-" + board)
|
||||
Reference in New Issue
Block a user