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 "text/css"
return "application/octet-stream" 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(): def getLibs():
base=os.path.join(basePath(),"lib") base=os.path.join(basePath(),"lib")
@ -326,14 +316,15 @@ def getLibs():
rt.append(sd) rt.append(sd)
return rt return rt
def prebuild(env): OWNLIBS=getLibs()+["FS","WiFi"]
global userTaskDirs GLOBAL_INCLUDES=[]
print("#prebuild running")
if not checkDir(): def handleDeps(env):
sys.exit(1) #overwrite the GetProjectConfig
allLibs=getLibs() #to inject all our libs
oldGetProjectConfig=env.GetProjectConfig
def GetProjectConfigX(env): def GetProjectConfigX(env):
rt=ProjectConfig.get_instance(env["PROJECT_CONFIG"]) rt=oldGetProjectConfig()
cenv="env:"+env['PIOENV'] cenv="env:"+env['PIOENV']
libs=[] libs=[]
for section,options in rt.as_tuple(): for section,options in rt.as_tuple():
@ -343,18 +334,50 @@ def prebuild(env):
libs=values libs=values
mustUpdate=False mustUpdate=False
for lib in allLibs: for lib in OWNLIBS:
if not lib in libs: if not lib in libs:
libs.append(lib) libs.append(lib)
mustUpdate=True mustUpdate=True
if mustUpdate: if mustUpdate:
update=[(cenv,[('lib_deps',libs)])] update=[(cenv,[('lib_deps',libs)])]
print("##update libdeps")
#pprint.pprint(update)
rt.update(update) rt.update(update)
return rt return rt
env.AddMethod(GetProjectConfigX,"GetProjectConfig") 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() userTaskDirs=getUserTaskDirs()
mergedConfig=os.path.join(outPath(),os.path.basename(CFG_FILE)) mergedConfig=os.path.join(outPath(),os.path.basename(CFG_FILE))
generateMergedConfig(os.path.join(basePath(),CFG_FILE),mergedConfig,userTaskDirs) generateMergedConfig(os.path.join(basePath(),CFG_FILE),mergedConfig,userTaskDirs)
@ -395,6 +418,7 @@ def cleangenerated(source, target, env):
fn=os.path.join(od,f) fn=os.path.join(od,f)
os.unlink(f) os.unlink(f)
print("#prescript...") print("#prescript...")
prebuild(env) prebuild(env)
board="PLATFORM_BOARD_%s"%env["BOARD"].replace("-","_").upper() board="PLATFORM_BOARD_%s"%env["BOARD"].replace("-","_").upper()

View File

@ -32,6 +32,8 @@ lib_deps =
Preferences Preferences
ESPmDNS ESPmDNS
WiFi WiFi
Update
Wire
board_build.embed_files = board_build.embed_files =
lib/generated/index.html.gz lib/generated/index.html.gz
lib/generated/index.js.gz lib/generated/index.js.gz
@ -44,6 +46,7 @@ extra_scripts =
pre:extra_script.py pre:extra_script.py
post:post.py post:post.py
lib_ldf_mode = off lib_ldf_mode = off
#lib_ldf_mode = chain+
monitor_speed = 115200 monitor_speed = 115200
build_flags = build_flags =
-D PIO_ENV_BUILD=$PIOENV -D PIO_ENV_BUILD=$PIOENV

View File

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