Implement GitHub repo extraction in build process
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com> # Conflicts: # platformio.ini # wled00/json.cpp # wled00/wled.h
This commit is contained in:
committed by
Will Tatam
parent
e6cca911d5
commit
747ca3d5aa
1916
compile_commands.json
Normal file
1916
compile_commands.json
Normal file
File diff suppressed because it is too large
Load Diff
43
pio-scripts/set_repo.py
Normal file
43
pio-scripts/set_repo.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
Import('env')
|
||||||
|
import subprocess
|
||||||
|
import re
|
||||||
|
|
||||||
|
def get_github_repo():
|
||||||
|
"""Extract GitHub repository name from git remote URL."""
|
||||||
|
try:
|
||||||
|
# Get the remote URL for origin
|
||||||
|
result = subprocess.run(['git', 'remote', 'get-url', 'origin'],
|
||||||
|
capture_output=True, text=True, check=True)
|
||||||
|
remote_url = result.stdout.strip()
|
||||||
|
|
||||||
|
# Check if it's a GitHub URL
|
||||||
|
if 'github.com' not in remote_url.lower():
|
||||||
|
return 'unknown'
|
||||||
|
|
||||||
|
# Parse GitHub URL patterns:
|
||||||
|
# https://github.com/owner/repo.git
|
||||||
|
# git@github.com:owner/repo.git
|
||||||
|
# https://github.com/owner/repo
|
||||||
|
|
||||||
|
# Remove .git suffix if present
|
||||||
|
if remote_url.endswith('.git'):
|
||||||
|
remote_url = remote_url[:-4]
|
||||||
|
|
||||||
|
# Handle HTTPS URLs
|
||||||
|
https_match = re.search(r'github\.com/([^/]+/[^/]+)', remote_url, re.IGNORECASE)
|
||||||
|
if https_match:
|
||||||
|
return https_match.group(1)
|
||||||
|
|
||||||
|
# Handle SSH URLs
|
||||||
|
ssh_match = re.search(r'github\.com:([^/]+/[^/]+)', remote_url, re.IGNORECASE)
|
||||||
|
if ssh_match:
|
||||||
|
return ssh_match.group(1)
|
||||||
|
|
||||||
|
return 'unknown'
|
||||||
|
|
||||||
|
except (subprocess.CalledProcessError, FileNotFoundError, Exception):
|
||||||
|
# Git command failed or git is not available
|
||||||
|
return 'unknown'
|
||||||
|
|
||||||
|
repo = get_github_repo()
|
||||||
|
env.Append(BUILD_FLAGS=[f'-DWLED_REPO="{repo}"'])
|
||||||
@@ -222,6 +222,7 @@ extra_scripts =
|
|||||||
pre:pio-scripts/set_version.py
|
pre:pio-scripts/set_version.py
|
||||||
pre:pio-scripts/build_ui.py
|
pre:pio-scripts/build_ui.py
|
||||||
pre:pio-scripts/conditional_usb_mode.py
|
pre:pio-scripts/conditional_usb_mode.py
|
||||||
|
pre:pio-scripts/set_repo.py
|
||||||
post:pio-scripts/output_bins.py
|
post:pio-scripts/output_bins.py
|
||||||
post:pio-scripts/strip-floats.py
|
post:pio-scripts/strip-floats.py
|
||||||
pre:pio-scripts/user_config_copy.py
|
pre:pio-scripts/user_config_copy.py
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
|
|||||||
esp32SemGive(segmentMux);
|
esp32SemGive(segmentMux);
|
||||||
} else {
|
} else {
|
||||||
USER_PRINTLN(F("deserializeSegment(): segment not added - failed to acquire segmentMux."));
|
USER_PRINTLN(F("deserializeSegment(): segment not added - failed to acquire segmentMux."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -452,7 +452,7 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
|
|||||||
|
|
||||||
bool stateResponse = root[F("v")] | false;
|
bool stateResponse = root[F("v")] | false;
|
||||||
|
|
||||||
//WLEDMM: store netDebug, also if not WLED_DEBUG
|
//WLEDMM: store netDebug, also if not WLED_DEBUG
|
||||||
#if defined(WLED_DEBUG_HOST)
|
#if defined(WLED_DEBUG_HOST)
|
||||||
bool oldValue = netDebugEnabled;
|
bool oldValue = netDebugEnabled;
|
||||||
netDebugEnabled = root[F("netDebug")] | netDebugEnabled;
|
netDebugEnabled = root[F("netDebug")] | netDebugEnabled;
|
||||||
@@ -566,7 +566,7 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
|
|||||||
realtimeLock(65000);
|
realtimeLock(65000);
|
||||||
#else
|
#else
|
||||||
// more meaningful timeout : use configurable timeout; *3 for some safety margin without staying "live" forever
|
// more meaningful timeout : use configurable timeout; *3 for some safety margin without staying "live" forever
|
||||||
realtimeLock(realtimeTimeoutMs *3); // Use configurable timeout like other protocols
|
realtimeLock(realtimeTimeoutMs *3); // Use configurable timeout like other protocols
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
exitRealtime();
|
exitRealtime();
|
||||||
@@ -764,7 +764,7 @@ void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segme
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!forPreset) {
|
if (!forPreset) {
|
||||||
//WLEDMM: store netDebug
|
//WLEDMM: store netDebug
|
||||||
#if defined(WLED_DEBUG_HOST)
|
#if defined(WLED_DEBUG_HOST)
|
||||||
root[F("netDebug")] = netDebugEnabled;
|
root[F("netDebug")] = netDebugEnabled;
|
||||||
// USER_PRINTF("serializeState %d\n", netDebugEnabled);
|
// USER_PRINTF("serializeState %d\n", netDebugEnabled);
|
||||||
@@ -876,7 +876,7 @@ String resetCode2Info(int reason) {
|
|||||||
// unknown reason code
|
// unknown reason code
|
||||||
case 0:
|
case 0:
|
||||||
return F(""); break;
|
return F(""); break;
|
||||||
default:
|
default:
|
||||||
return F("unknown"); break;
|
return F("unknown"); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -954,7 +954,7 @@ void serializeInfo(JsonObject root)
|
|||||||
//root[F("cn")] = F(WLED_CODENAME); //WLEDMM removed
|
//root[F("cn")] = F(WLED_CODENAME); //WLEDMM removed
|
||||||
root[F("release")] = FPSTR(releaseString);
|
root[F("release")] = FPSTR(releaseString);
|
||||||
root[F("rel")] = FPSTR(releaseString); //WLEDMM to add bin name
|
root[F("rel")] = FPSTR(releaseString); //WLEDMM to add bin name
|
||||||
//root[F("repo")] = repoString; // WLEDMM not availeable
|
root[F("repo")] = repoString;
|
||||||
root[F("deviceId")] = getDeviceId();
|
root[F("deviceId")] = getDeviceId();
|
||||||
|
|
||||||
JsonObject leds = root.createNestedObject("leds");
|
JsonObject leds = root.createNestedObject("leds");
|
||||||
@@ -1157,8 +1157,8 @@ void serializeInfo(JsonObject root)
|
|||||||
// use the full revision if we can
|
// use the full revision if we can
|
||||||
esp_chip_info_t chip_info;
|
esp_chip_info_t chip_info;
|
||||||
esp_chip_info(&chip_info);
|
esp_chip_info(&chip_info);
|
||||||
snprintf(msgbuf, sizeof(msgbuf)-1, "%s v%u.%u",
|
snprintf(msgbuf, sizeof(msgbuf)-1, "%s v%u.%u",
|
||||||
ESP.getChipModel(),
|
ESP.getChipModel(),
|
||||||
unsigned(chip_info.full_revision / 100), // full revision is in (major * 100 + minor) format
|
unsigned(chip_info.full_revision / 100), // full revision is in (major * 100 + minor) format
|
||||||
unsigned(chip_info.full_revision % 100));
|
unsigned(chip_info.full_revision % 100));
|
||||||
#else
|
#else
|
||||||
@@ -1406,7 +1406,7 @@ void serializePalettes(JsonObject root, AsyncWebServerRequest* request)
|
|||||||
// WLEDMM workaround for palettes index overflow at i=74 -> gGradientPalettes index=61 out of bounds.
|
// WLEDMM workaround for palettes index overflow at i=74 -> gGradientPalettes index=61 out of bounds.
|
||||||
int palIndex = i-13;
|
int palIndex = i-13;
|
||||||
constexpr int palMax = sizeof(gGradientPalettes)/sizeof(gGradientPalettes[0]) -1;
|
constexpr int palMax = sizeof(gGradientPalettes)/sizeof(gGradientPalettes[0]) -1;
|
||||||
if ((palIndex < 0) || (palIndex > palMax)) {
|
if ((palIndex < 0) || (palIndex > palMax)) {
|
||||||
DEBUG_PRINTF("WARNING gGradientPalettes[%d] is out of bounds! max=%d. (json.cpp)\n", palIndex, palMax);
|
DEBUG_PRINTF("WARNING gGradientPalettes[%d] is out of bounds! max=%d. (json.cpp)\n", palIndex, palMax);
|
||||||
palIndex = palMax; // use last valid array item
|
palIndex = palMax; // use last valid array item
|
||||||
}
|
}
|
||||||
@@ -1638,7 +1638,7 @@ bool serveLiveLeds(AsyncWebServerRequest* request, uint32_t wsClient)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DynamicBuffer buffer(9 + (9*MAX_LIVE_LEDS) + 7 + 5 + 6 + 5 + 6 + 5 + 2);
|
DynamicBuffer buffer(9 + (9*MAX_LIVE_LEDS) + 7 + 5 + 6 + 5 + 6 + 5 + 2);
|
||||||
char* buf = buffer.data(); // assign buffer for oappnd() functions
|
char* buf = buffer.data(); // assign buffer for oappnd() functions
|
||||||
strncpy_P(buffer.data(), PSTR("{\"leds\":["), buffer.size());
|
strncpy_P(buffer.data(), PSTR("{\"leds\":["), buffer.size());
|
||||||
buf += 9; // sizeof(PSTR()) from last line
|
buf += 9; // sizeof(PSTR()) from last line
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
// WLEDMM - you can check for this define in usermods, to only enabled WLEDMM specific code in the "right" fork. Its not defined in AC WLED.
|
// WLEDMM - you can check for this define in usermods, to only enabled WLEDMM specific code in the "right" fork. Its not defined in AC WLED.
|
||||||
#define _MoonModules_WLED_
|
#define _MoonModules_WLED_
|
||||||
|
|
||||||
//WLEDMM + Moustachauve/Wled-Native
|
//WLEDMM + Moustachauve/Wled-Native
|
||||||
// You can define custom product info from build flags.
|
// You can define custom product info from build flags.
|
||||||
// This is useful to allow API consumer to identify what type of WLED version
|
// This is useful to allow API consumer to identify what type of WLED version
|
||||||
// they are interacting with. Be aware that changing this might cause some third
|
// they are interacting with. Be aware that changing this might cause some third
|
||||||
@@ -50,8 +50,8 @@
|
|||||||
#ifndef WLED_DISABLE_MQTT
|
#ifndef WLED_DISABLE_MQTT
|
||||||
#define WLED_ENABLE_MQTT // saves 12kb
|
#define WLED_ENABLE_MQTT // saves 12kb
|
||||||
#endif
|
#endif
|
||||||
#ifndef WLED_DISABLE_ADALIGHT // can be used to disable reading commands from serial RX pin (see issue #3128).
|
#ifndef WLED_DISABLE_ADALIGHT // can be used to disable reading commands from serial RX pin (see issue #3128).
|
||||||
#define WLED_ENABLE_ADALIGHT // disable saves 5Kb (uses GPIO3 (RX) for serial). Related serial protocols: Adalight/TPM2, Improv, Serial JSON, Continuous Serial Streaming
|
#define WLED_ENABLE_ADALIGHT // disable saves 5Kb (uses GPIO3 (RX) for serial). Related serial protocols: Adalight/TPM2, Improv, Serial JSON, Continuous Serial Streaming
|
||||||
#else
|
#else
|
||||||
#undef WLED_ENABLE_ADALIGHT // disable has priority over enable
|
#undef WLED_ENABLE_ADALIGHT // disable has priority over enable
|
||||||
#endif
|
#endif
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
#define WLED_ENABLE_WEBSOCKETS
|
#define WLED_ENABLE_WEBSOCKETS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define WLED_DISABLE_ESPNOW // Removes dependence on esp now
|
//#define WLED_DISABLE_ESPNOW // Removes dependence on esp now
|
||||||
|
|
||||||
#define WLED_ENABLE_FS_EDITOR // enable /edit page for editing FS content. Will also be disabled with OTA lock
|
#define WLED_ENABLE_FS_EDITOR // enable /edit page for editing FS content. Will also be disabled with OTA lock
|
||||||
|
|
||||||
@@ -296,10 +296,14 @@ using PSRAMDynamicJsonDocument = BasicJsonDocument<PSRAM_Allocator>;
|
|||||||
#ifndef WLED_RELEASE_NAME
|
#ifndef WLED_RELEASE_NAME
|
||||||
#define WLED_RELEASE_NAME mdev_release
|
#define WLED_RELEASE_NAME mdev_release
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef WLED_REPO
|
||||||
|
#define WLED_REPO "unknown"
|
||||||
|
#endif
|
||||||
|
|
||||||
// Global Variable definitions
|
// Global Variable definitions
|
||||||
WLED_GLOBAL char versionString[] _INIT(TOSTRING(WLED_VERSION));
|
WLED_GLOBAL char versionString[] _INIT(TOSTRING(WLED_VERSION));
|
||||||
WLED_GLOBAL char releaseString[] _INIT_PROGMEM(TOSTRING(WLED_RELEASE_NAME)); //WLEDMM: to show on update page // somehow this will not work if using "const char releaseString[]
|
WLED_GLOBAL char releaseString[] _INIT_PROGMEM(TOSTRING(WLED_RELEASE_NAME)); //WLEDMM: to show on update page // somehow this will not work if using "const char releaseString[]
|
||||||
|
WLED_GLOBAL char repoString[] _INIT(WLED_REPO);
|
||||||
#define WLED_CODENAME "Hoshi"
|
#define WLED_CODENAME "Hoshi"
|
||||||
|
|
||||||
// AP and OTA default passwords (for maximum security change them!)
|
// AP and OTA default passwords (for maximum security change them!)
|
||||||
|
|||||||
Reference in New Issue
Block a user