mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-02-10 22:53:07 +01:00
Fix build for new gateway extra_script.py
This commit is contained in:
@@ -104,8 +104,7 @@ def writeFileIfChanged(fileName,data):
|
||||
return True
|
||||
|
||||
def mergeConfig(base,other):
|
||||
for bdir in other:
|
||||
cname=os.path.join(bdir,"config.json")
|
||||
for cname in other:
|
||||
if os.path.exists(cname):
|
||||
print("merge config %s"%cname)
|
||||
with open(cname,'rb') as ah:
|
||||
@@ -151,13 +150,25 @@ def expandConfig(config):
|
||||
rt.append(replaceTexts(c,replace))
|
||||
return rt
|
||||
|
||||
def generateMergedConfig(inFile,outFile,addDirs=[]):
|
||||
def createUserItemList(dirs,itemName,files):
|
||||
rt=[]
|
||||
for d in dirs:
|
||||
iname=os.path.join(d,itemName)
|
||||
if os.path.exists(iname):
|
||||
rt.append(iname)
|
||||
for f in files:
|
||||
if not os.path.exists(f):
|
||||
raise Exception("user item %s not found"%f)
|
||||
rt.append(f)
|
||||
return rt
|
||||
|
||||
def generateMergedConfig(inFile,outFile,addFiles=[]):
|
||||
if not os.path.exists(inFile):
|
||||
raise Exception("unable to read cfg file %s"%inFile)
|
||||
data=""
|
||||
with open(inFile,'rb') as ch:
|
||||
config=json.load(ch)
|
||||
config=mergeConfig(config,addDirs)
|
||||
config=mergeConfig(config,addFiles)
|
||||
config=expandConfig(config)
|
||||
data=json.dumps(config,indent=2)
|
||||
writeFileIfChanged(outFile,data)
|
||||
@@ -274,9 +285,9 @@ class Grove:
|
||||
def _ss(self,z=False):
|
||||
if z:
|
||||
return self.name
|
||||
return self.name if self.name is not 'Z' else ''
|
||||
return self.name if self.name != 'Z' else ''
|
||||
def _suffix(self):
|
||||
return '_'+self.name if self.name is not 'Z' else ''
|
||||
return '_'+self.name if self.name != 'Z' else ''
|
||||
def replace(self,line):
|
||||
if line is None:
|
||||
return line
|
||||
@@ -377,12 +388,7 @@ def getLibs():
|
||||
|
||||
|
||||
|
||||
def joinFiles(target,pattern,dirlist):
|
||||
flist=[]
|
||||
for dir in dirlist:
|
||||
fn=os.path.join(dir,pattern)
|
||||
if os.path.exists(fn):
|
||||
flist.append(fn)
|
||||
def joinFiles(target,flist):
|
||||
current=False
|
||||
if os.path.exists(target):
|
||||
current=True
|
||||
@@ -453,7 +459,28 @@ def handleDeps(env):
|
||||
)
|
||||
env.AddBuildMiddleware(injectIncludes)
|
||||
|
||||
def getOption(env,name,toArray=True):
|
||||
try:
|
||||
opt=env.GetProjectOption(name)
|
||||
if toArray:
|
||||
if opt is None:
|
||||
return []
|
||||
if isinstance(opt,list):
|
||||
return opt
|
||||
return opt.split("\n" if "\n" in opt else ",")
|
||||
return opt
|
||||
except:
|
||||
pass
|
||||
if toArray:
|
||||
return []
|
||||
|
||||
def getFileList(files):
|
||||
base=basePath()
|
||||
rt=[]
|
||||
for f in files:
|
||||
if f is not None and f != "":
|
||||
rt.append(os.path.join(base,f))
|
||||
return rt
|
||||
def prebuild(env):
|
||||
global userTaskDirs
|
||||
print("#prebuild running")
|
||||
@@ -463,14 +490,18 @@ def prebuild(env):
|
||||
if ldf_mode == 'off':
|
||||
print("##ldf off - own dependency handling")
|
||||
handleDeps(env)
|
||||
extraConfigs=getOption(env,'custom_config',toArray=True)
|
||||
extraJs=getOption(env,'custom_js',toArray=True)
|
||||
extraCss=getOption(env,'custom_css',toArray=True)
|
||||
|
||||
userTaskDirs=getUserTaskDirs()
|
||||
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,createUserItemList(userTaskDirs,"config.json", getFileList(extraConfigs)))
|
||||
compressFile(mergedConfig,mergedConfig+".gz")
|
||||
generateCfg(mergedConfig,os.path.join(outPath(),CFG_INCLUDE),False)
|
||||
generateCfg(mergedConfig,os.path.join(outPath(),CFG_INCLUDE_IMPL),True)
|
||||
joinFiles(os.path.join(outPath(),INDEXJS+".gz"),INDEXJS,["web"]+userTaskDirs)
|
||||
joinFiles(os.path.join(outPath(),INDEXCSS+".gz"),INDEXCSS,["web"]+userTaskDirs)
|
||||
joinFiles(os.path.join(outPath(),INDEXJS+".gz"),createUserItemList(["web"]+userTaskDirs,INDEXJS,getFileList(extraJs)))
|
||||
joinFiles(os.path.join(outPath(),INDEXCSS+".gz"),createUserItemList(["web"]+userTaskDirs,INDEXCSS,getFileList(extraCss)))
|
||||
embedded=getEmbeddedFiles(env)
|
||||
filedefs=[]
|
||||
for ef in embedded:
|
||||
|
||||
@@ -16,6 +16,8 @@ board_build.variants_dir = variants
|
||||
board = obp60_s3_n16r8 #ESP32-S3 N16R8, 16MB flash, 8MB PSRAM, production series
|
||||
#board_build.partitions = default_8MB.csv #ESP32-S3 N8, 8MB flash
|
||||
board_build.partitions = default_16MB.csv #ESP32-S3 N16, 16MB flash
|
||||
custom_config = lib/obp60task/config_obp60.json
|
||||
custom_script = lib/obp60task/extra_task.py
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
${basedeps.lib_deps}
|
||||
@@ -68,7 +70,8 @@ platform = espressif32@6.8.1
|
||||
board_build.variants_dir = variants
|
||||
board = obp40_s3_n8r8 #ESP32-S3 N8R8, 8MB flash, 8MB PSRAM, OBP60 clone (CrowPanel 4.2)
|
||||
board_build.partitions = default_8MB.csv #ESP32-S3 N8, 8MB flash
|
||||
custom_config = config_obp40.json
|
||||
custom_config = lib/obp60task/config_obp40.json
|
||||
custom_script = lib/obp60task/extra_task.py
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
${basedeps.lib_deps}
|
||||
|
||||
Reference in New Issue
Block a user