diff --git a/extra_script.py b/extra_script.py index 1ec3bd1..0a4d68c 100644 --- a/extra_script.py +++ b/extra_script.py @@ -302,16 +302,6 @@ def getContentType(fn): return "text/css" return "application/octet-stream" -def addLibs(env,libs): - print("####Options:") - po=env.GetProjectOptions() - print("type po %s"%str(type(po))) - for k,v in po: - if k == 'lib_deps': - v+=libs - pprint.pprint(po) - - def getLibs(): base=os.path.join(basePath(),"lib") @@ -326,14 +316,15 @@ def getLibs(): rt.append(sd) return rt -def prebuild(env): - global userTaskDirs - print("#prebuild running") - if not checkDir(): - sys.exit(1) - allLibs=getLibs() +OWNLIBS=getLibs()+["FS","WiFi"] +GLOBAL_INCLUDES=[] + +def handleDeps(env): + #overwrite the GetProjectConfig + #to inject all our libs + oldGetProjectConfig=env.GetProjectConfig def GetProjectConfigX(env): - rt=ProjectConfig.get_instance(env["PROJECT_CONFIG"]) + rt=oldGetProjectConfig() cenv="env:"+env['PIOENV'] libs=[] for section,options in rt.as_tuple(): @@ -343,18 +334,50 @@ def prebuild(env): libs=values mustUpdate=False - for lib in allLibs: + for lib in OWNLIBS: if not lib in libs: libs.append(lib) mustUpdate=True if mustUpdate: update=[(cenv,[('lib_deps',libs)])] - print("##update libdeps") - #pprint.pprint(update) rt.update(update) return rt env.AddMethod(GetProjectConfigX,"GetProjectConfig") - addLibs(env,['appinfo']) + #store the list of all includes after we resolved + #the dependencies for our main project + #we will use them for all compilations afterwards + oldLibBuilder=env.ConfigureProjectLibBuilder + def ConfigureProjectLibBuilderX(env): + global GLOBAL_INCLUDES + project=oldLibBuilder() + #print("##ConfigureProjectLibBuilderX") + #pprint.pprint(project) + if project.depbuilders: + #print("##depbuilders %s"%",".join(map(lambda x: x.path,project.depbuilders))) + for db in project.depbuilders: + idirs=db.get_include_dirs() + for id in idirs: + if not id in GLOBAL_INCLUDES: + GLOBAL_INCLUDES.append(id) + return project + env.AddMethod(ConfigureProjectLibBuilderX,"ConfigureProjectLibBuilder") + def injectIncludes(env,node): + return env.Object( + node, + CPPPATH=env["CPPPATH"]+GLOBAL_INCLUDES + ) + env.AddBuildMiddleware(injectIncludes) + + +def prebuild(env): + global userTaskDirs + print("#prebuild running") + if not checkDir(): + sys.exit(1) + ldf_mode=env.GetProjectOption("lib_ldf_mode") + if ldf_mode == 'off': + print("##ldf off - own dependency handling") + handleDeps(env) userTaskDirs=getUserTaskDirs() mergedConfig=os.path.join(outPath(),os.path.basename(CFG_FILE)) generateMergedConfig(os.path.join(basePath(),CFG_FILE),mergedConfig,userTaskDirs) @@ -395,6 +418,7 @@ def cleangenerated(source, target, env): fn=os.path.join(od,f) os.unlink(f) + print("#prescript...") prebuild(env) board="PLATFORM_BOARD_%s"%env["BOARD"].replace("-","_").upper() diff --git a/platformio.ini b/platformio.ini index 99632cd..4283ed7 100644 --- a/platformio.ini +++ b/platformio.ini @@ -32,6 +32,8 @@ lib_deps = Preferences ESPmDNS WiFi + Update + Wire board_build.embed_files = lib/generated/index.html.gz lib/generated/index.js.gz @@ -44,6 +46,7 @@ extra_scripts = pre:extra_script.py post:post.py lib_ldf_mode = off +#lib_ldf_mode = chain+ monitor_speed = 115200 build_flags = -D PIO_ENV_BUILD=$PIOENV diff --git a/src/main.cpp b/src/main.cpp index 0d99b0c..aaeb10e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,7 +16,7 @@ //#define FALLBACK_SERIAL const unsigned long HEAP_REPORT_TIME=2000; //set to 0 to disable heap reporting #include -#include "FS.h" +#include "Preferences.h" #include "GwApi.h" #include "GwHardware.h"