build optimizations

This commit is contained in:
proddy
2019-11-04 19:16:15 +01:00
parent 9f146768b4
commit 6b1e0d496c
5 changed files with 66 additions and 46 deletions

View File

@@ -13,8 +13,7 @@ default_envs = debug
; -DFORCE_SERIAL ; -DFORCE_SERIAL
custom_flags = custom_flags =
;general_flags = -DNO_GLOBAL_EEPROM -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH -DBEARSSL_SSL_BASIC general_flags = -fno-exceptions -lstdc++ -DNO_GLOBAL_EEPROM -O2 -DBEARSSL_SSL_BASIC -DVTABLES_IN_FLASH -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH
general_flags = -DNO_GLOBAL_EEPROM
[env] [env]
framework = arduino framework = arduino
@@ -45,27 +44,32 @@ monitor_speed = 115200
[env:travis] [env:travis]
board = esp12e board = esp12e
build_flags = ${common.general_flags} build_flags = ${common.general_flags}
extra_scripts = scripts/main_script.py
[env:esp12e] [env:esp12e]
board = esp12e board = esp12e
build_flags = ${common.general_flags} build_flags = ${common.general_flags}
extra_scripts = scripts/main_script.py
[env:d1_mini] [env:d1_mini]
board = d1_mini board = d1_mini
build_flags = ${common.general_flags} build_flags = ${common.general_flags}
extra_scripts = scripts/main_script.py
[env:nodemcuv2] [env:nodemcuv2]
board = nodemcuv2 board = nodemcuv2
build_flags = ${common.general_flags} build_flags = ${common.general_flags}
extra_scripts = scripts/main_script.py
[env:nodemcu] [env:nodemcu]
board = nodemcu board = nodemcu
build_flags = ${common.general_flags} build_flags = ${common.general_flags}
extra_scripts = scripts/main_script.py
[env:debug] [env:debug]
board = d1_mini board = d1_mini
build_type = debug build_type = debug
build_flags = ${common.general_flags} ${common.custom_flags} build_flags = ${common.general_flags} ${common.custom_flags}
extra_scripts = extra_scripts =
pre:scripts/rename_fw.py pre:scripts/pre_script.py
pre:scripts/buildweb.py scripts/main_script.py

View File

@@ -1,3 +0,0 @@
Import("env")
env.Execute("node ./tools/webfilesbuilder/node_modules/gulp/bin/gulp.js --silent --cwd ./tools/webfilesbuilder")

View File

@@ -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
View 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()

View File

@@ -4,10 +4,25 @@ import os
import re import re
Import("env") Import("env")
def build_web(source, target, env): def build_web():
print("\n** Build web...") print("** Building web...")
call(["gulp", "-f", os.getcwd()+"/tools/webfilesbuilder/gulpfile.js"]) 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 = {} bag = {}
exprs = [ exprs = [
(re.compile(r'^#define APP_VERSION\s+"(\S+)"'), 'app_version'), (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_version = bag.get('app_version')
app_name = bag.get('app_name') app_name = bag.get('app_name')
app_hostname = bag.get('app_hostname') app_hostname = bag.get('app_hostname')
board = env['BOARD'] board = env['BOARD']
branch = env['PIOENV'] branch = env['PIOENV']
# build the web files
env.AddPreAction("buildprog", build_web)
# build filename, replacing . with _ for the version # build filename, replacing . with _ for the version
#env.Replace(PROGNAME="firmware_%s" % branch + "_" + app_version.replace(".", "_")) env.Replace(PROGNAME=app_name + "-" +
#env.Replace(PROGNAME=app_name + "-" + app_version.replace(".", "_") + "-" + board + "-" + branch) app_version.replace(".", "_") + "-" + board)
env.Replace(PROGNAME=app_name + "-" + app_version.replace(".", "_") + "-" + board)