From 5493c9695cef9f2bb2db0ec0dc6ae828b907ba56 Mon Sep 17 00:00:00 2001 From: wellenvogel Date: Tue, 30 Sep 2025 15:27:50 +0200 Subject: [PATCH] add buildname to cibuild, use the firmware name for file names --- .github/workflows/release.yml | 2 +- lib/appinfo/GwAppInfo.h | 5 ++++- post.py | 8 ++++++-- src/main.cpp | 6 +++--- webinstall/build.yaml | 7 +++++++ webinstall/cibuild.js | 34 +++++++++++++++++++++++++++++++++- 6 files changed, 54 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2aeae17..ea089d5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -62,5 +62,5 @@ jobs: with: repo_token: ${{ secrets.GITHUB_TOKEN }} tag: ${{ steps.version.outputs.version}} - file: ./.pio/build/*/*-{all,update}.bin + file: ./.pio/build/*/*${{ steps.version.outputs.version }}*-{all,update}.bin file_glob: true diff --git a/lib/appinfo/GwAppInfo.h b/lib/appinfo/GwAppInfo.h index f7eb143..0ccf711 100644 --- a/lib/appinfo/GwAppInfo.h +++ b/lib/appinfo/GwAppInfo.h @@ -14,6 +14,9 @@ #define LOGLEVEL GwLog::DEBUG #endif #endif - +#ifdef GWBUILD_NAME +#define FIRMWARE_TYPE GWSTRINGIFY(GWBUILD_NAME) +#else #define FIRMWARE_TYPE GWSTRINGIFY(PIO_ENV_BUILD) +#endif #define IDF_VERSION GWSTRINGIFY(ESP_IDF_VERSION_MAJOR) "." GWSTRINGIFY(ESP_IDF_VERSION_MINOR) "." GWSTRINGIFY(ESP_IDF_VERSION_PATCH) \ No newline at end of file diff --git a/post.py b/post.py index 8fe2f27..a09635f 100644 --- a/post.py +++ b/post.py @@ -2,6 +2,7 @@ Import("env", "projenv") import os import glob import shutil +import re print("##post script running") HDROFFSET=288 @@ -39,6 +40,7 @@ def post(source,target,env): appoffset=env.subst("$ESP32_APP_OFFSET") firmware=env.subst("$BUILD_DIR/${PROGNAME}.bin") (fwname,version)=getFirmwareInfo(firmware) + fwname=re.sub(r"[^0-9A-Za-z_.-]*","",fwname) print("found fwname=%s, fwversion=%s"%(fwname,version)) python=env.subst("$PYTHONEXE") print("base=%s,esptool=%s,appoffset=%s,uploaderflags=%s"%(base,esptool,appoffset,uploaderflags)) @@ -70,10 +72,12 @@ def post(source,target,env): print("running %s"%" ".join(cmd)) env.Execute(" ".join(cmd),"#testpost") ofversion="-"+version - versionedFile=os.path.join(outdir,"%s%s-update.bin"%(base,ofversion)) + versionedFile=os.path.join(outdir,"%s%s-update.bin"%(fwname,ofversion)) shutil.copyfile(firmware,versionedFile) - versioneOutFile=os.path.join(outdir,"%s%s-all.bin"%(base,ofversion)) + print(f"wrote {versionedFile}") + versioneOutFile=os.path.join(outdir,"%s%s-all.bin"%(fwname,ofversion)) shutil.copyfile(outfile,versioneOutFile) + print(f"wrote {versioneOutFile}") env.AddPostAction( "$BUILD_DIR/${PROGNAME}.bin", post diff --git a/src/main.cpp b/src/main.cpp index de56930..44c715f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -72,9 +72,9 @@ const unsigned long HEAP_REPORT_TIME=2000; //set to 0 to disable heap reporting #define MAX_NMEA2000_MESSAGE_SEASMART_SIZE 500 #define MAX_NMEA0183_MESSAGE_SIZE MAX_NMEA2000_MESSAGE_SEASMART_SIZE //assert length of firmware name and version -CASSERT(strlen(FIRMWARE_TYPE) <= 32, "environment name (FIRMWARE_TYPE) must not exceed 32 chars"); -CASSERT(strlen(VERSION) <= 32, "VERSION must not exceed 32 chars"); -CASSERT(strlen(IDF_VERSION) <= 32,"IDF_VERSION must not exceed 32 chars"); +CASSERT(strlen(FIRMWARE_TYPE) <= 31, "environment name (FIRMWARE_TYPE) must not exceed 32 chars"); +CASSERT(strlen(VERSION) <= 31, "VERSION must not exceed 32 chars"); +CASSERT(strlen(IDF_VERSION) <= 31,"IDF_VERSION must not exceed 32 chars"); //https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/app_image_format.html //and removed the bugs in the doc... __attribute__((section(".rodata_custom_desc"))) esp_app_desc_t custom_app_desc = { diff --git a/webinstall/build.yaml b/webinstall/build.yaml index 3590c59..672c435 100644 --- a/webinstall/build.yaml +++ b/webinstall/build.yaml @@ -803,6 +803,13 @@ resources: config: children: + - type: string + label: 'Build Name' + key: buildname + target: "define:GWBUILD_NAME" + help: "Set a name to identify your build. Will also become the name for the generated files and the firmware type in the image. Max 31 characters." + max: 31 + allowed: "0-9A-Za-z_-" - type: select target: environment label: 'Board' diff --git a/webinstall/cibuild.js b/webinstall/cibuild.js index 690da1d..b64787c 100644 --- a/webinstall/cibuild.js +++ b/webinstall/cibuild.js @@ -234,7 +234,11 @@ class PipelineInfo{ } const downloadConfig=()=>{ let name=configName; - if (isModified) name=name.replace(/[0-9]*$/,'')+formatDate(undefined,true); + const buildname=config["root:buildname"] + if (buildname && name != buildname){ + name+="-"+buildname+"-"; + } + name=name.replace(/[0-9]*$/,'')+formatDate(undefined,true); name+=".json"; fileDownload(JSON.stringify(config),name); } @@ -521,6 +525,34 @@ class PipelineInfo{ addDescription(config,inputFrame); initialConfig=expandedValues[0]; } + if (config.type === 'string'){ + let ip=addEl('input','t'+config.type,inputFrame); + addDescription(config,inputFrame); + ip.value=current?current:""; + ip.addEventListener('change',(ev)=>{ + let value=ev.target.value; + let modified=false; + if (config.max){ + if (value && value.length > config.max){ + modified=true; + value=value.substring(0,config.max); + } + } + if (config.allowed){ + let check=new RegExp("[^"+config.allowed+"]","g"); + let nv=value.replace(check,""); + if (nv != value){ + modified=true; + value=nv; + } + } + if (modified){ + ev.target.value=value; + } + callback(Object.assign({},config,{key: value,value:value}),false); + + }); + } let childFrame=addEl('div','childFrame',frame); if (initialConfig !== undefined){ callback(initialConfig,true,childFrame);