modify dependency handling to use mode off

This commit is contained in:
andreas 2023-10-27 19:06:06 +02:00
parent 80017af0b4
commit 553f6c0a23
3 changed files with 49 additions and 22 deletions

View File

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

View File

@ -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

View File

@ -16,7 +16,7 @@
//#define FALLBACK_SERIAL
const unsigned long HEAP_REPORT_TIME=2000; //set to 0 to disable heap reporting
#include <Arduino.h>
#include "FS.h"
#include "Preferences.h"
#include "GwApi.h"
#include "GwHardware.h"