diff --git a/platformio.ini b/platformio.ini index fa7611ba8..35c255e10 100644 --- a/platformio.ini +++ b/platformio.ini @@ -13,8 +13,7 @@ default_envs = debug ; -DFORCE_SERIAL custom_flags = -;general_flags = -DNO_GLOBAL_EEPROM -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH -DBEARSSL_SSL_BASIC -general_flags = -DNO_GLOBAL_EEPROM +general_flags = -fno-exceptions -lstdc++ -DNO_GLOBAL_EEPROM -O2 -DBEARSSL_SSL_BASIC -DVTABLES_IN_FLASH -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH [env] framework = arduino @@ -45,27 +44,32 @@ monitor_speed = 115200 [env:travis] board = esp12e build_flags = ${common.general_flags} +extra_scripts = scripts/main_script.py [env:esp12e] board = esp12e build_flags = ${common.general_flags} +extra_scripts = scripts/main_script.py [env:d1_mini] board = d1_mini build_flags = ${common.general_flags} +extra_scripts = scripts/main_script.py [env:nodemcuv2] board = nodemcuv2 build_flags = ${common.general_flags} +extra_scripts = scripts/main_script.py [env:nodemcu] board = nodemcu build_flags = ${common.general_flags} +extra_scripts = scripts/main_script.py [env:debug] board = d1_mini build_type = debug build_flags = ${common.general_flags} ${common.custom_flags} -extra_scripts = - pre:scripts/rename_fw.py - pre:scripts/buildweb.py +extra_scripts = + pre:scripts/pre_script.py + scripts/main_script.py diff --git a/scripts/buildweb.py b/scripts/buildweb.py deleted file mode 100644 index 96c41fa10..000000000 --- a/scripts/buildweb.py +++ /dev/null @@ -1,3 +0,0 @@ -Import("env") - -env.Execute("node ./tools/webfilesbuilder/node_modules/gulp/bin/gulp.js --silent --cwd ./tools/webfilesbuilder") diff --git a/scripts/checkcode.py b/scripts/checkcode.py deleted file mode 100644 index 53da63054..000000000 --- a/scripts/checkcode.py +++ /dev/null @@ -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']) diff --git a/scripts/main_script.py b/scripts/main_script.py new file mode 100644 index 000000000..61b873da9 --- /dev/null +++ b/scripts/main_script.py @@ -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() diff --git a/scripts/rename_fw.py b/scripts/pre_script.py similarity index 55% rename from scripts/rename_fw.py rename to scripts/pre_script.py index 594b6d4d4..ca9db79ba 100644 --- a/scripts/rename_fw.py +++ b/scripts/pre_script.py @@ -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)