diff --git a/scripts/platformio-pre.py b/scripts/platformio-pre.py index 8ea61039..fd4752ea 100644 --- a/scripts/platformio-pre.py +++ b/scripts/platformio-pre.py @@ -109,6 +109,34 @@ def update_library_build_metadata(library_json_path, desired_updates, descriptio print(f"[pio] pre: Trimmed {description} build metadata") +def create_library_build_metadata( + library_json_path, + manifest_defaults, + desired_updates, + description, +): + if os.path.exists(library_json_path): + update_library_build_metadata( + library_json_path, + desired_updates, + description, + ) + return + + library_dir = os.path.dirname(library_json_path) + if not os.path.isdir(library_dir): + print(f"[pio] pre: {description} metadata not found yet: {library_json_path}") + return + + library_json = dict(manifest_defaults) + library_json["build"] = dict(desired_updates) + with open(library_json_path, "w", encoding="utf-8", newline="\n") as fp: + json.dump(library_json, fp, indent=4) + fp.write("\n") + + print(f"[pio] pre: Created trimmed {description} build metadata") + + def iter_active_project_source_files(): source_roots = ("apps", "boards", "modules", "platform") source_extensions = (".c", ".cc", ".cpp", ".h", ".hpp", ".ino") @@ -251,10 +279,21 @@ def configure_esp8266audio_for_esp32(): audio_dir = os.path.join(project_dir, ".pio", "libdeps", pio_env, "ESP8266Audio") library_json_path = os.path.join(audio_dir, "library.json") - desired_src_filter = [ - "+<*>", - "-", - ] + # Pager has its own audio path. T-Deck only uses the I2S output and its + # logger definition; keep the full-library fallback for other ESP boards. + if pio_env in ("tlora_pager_sx1262", "tlora_pager_sx1262_debug"): + desired_src_filter = ["-<*>"] + elif pio_env in ("tdeck", "tdeck_debug"): + desired_src_filter = [ + "-<*>", + "+", + "+", + ] + else: + desired_src_filter = [ + "+<*>", + "-", + ] update_library_build_metadata( library_json_path, {"srcFilter": desired_src_filter}, @@ -262,6 +301,215 @@ def configure_esp8266audio_for_esp32(): ) +def configure_radiolib_for_sx1262_esp32(): + if not is_esp32_env or pio_env not in ( + "tlora_pager_sx1262", + "tlora_pager_sx1262_debug", + "tdeck", + "tdeck_debug", + ): + return + + radiolib_dir = os.path.join(project_dir, ".pio", "libdeps", pio_env, "RadioLib") + library_json_path = os.path.join(radiolib_dir, "library.json") + # These targets only instantiate SX1262. Avoid compiling every other + # transceiver and protocol implementation that RadioLib ships. + desired_src_filter = [ + "-<*>", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + ] + update_library_build_metadata( + library_json_path, + {"srcFilter": desired_src_filter}, + f"RadioLib for {pio_env}", + ) + + +def configure_lvgl_for_esp32_ui(): + if not is_esp32_env or pio_env not in ( + "tlora_pager_sx1262", + "tlora_pager_sx1262_debug", + "tdeck", + "tdeck_debug", + ): + return + + lvgl_dir = os.path.join(project_dir, ".pio", "libdeps", pio_env, "lvgl") + library_json_path = os.path.join(lvgl_dir, "library.json") + # Keep this list aligned with platform/esp/arduino_common/include/lv_conf.h. + # Disabled desktop drivers, render backends, and codecs otherwise still + # create hundreds of empty or unreachable compilation units. + desired_src_filter = [ + "-<*>", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + ] + update_library_build_metadata( + library_json_path, + {"srcFilter": desired_src_filter}, + f"LVGL for {pio_env}", + ) + + +def configure_crypto_for_sx1262_esp32(): + if not is_esp32_env or pio_env not in ( + "tlora_pager_sx1262", + "tlora_pager_sx1262_debug", + "tdeck", + "tdeck_debug", + ): + return + + crypto_dir = os.path.join(project_dir, ".pio", "libdeps", pio_env, "Crypto") + library_json_path = os.path.join(crypto_dir, "library.json") + # This is the linked object closure for AES-CTR, ChaCha-Poly1305, + # Curve25519, RNG, and SHA-256 used by the four supported protocols. + desired_src_filter = [ + "-<*>", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + ] + update_library_build_metadata( + library_json_path, + {"srcFilter": desired_src_filter}, + f"Crypto for {pio_env}", + ) + + +def configure_sensorlib_for_sx1262_esp32(): + if not is_esp32_env or pio_env not in ( + "tlora_pager_sx1262", + "tlora_pager_sx1262_debug", + "tdeck", + "tdeck_debug", + ): + return + + sensor_dir = os.path.join(project_dir, ".pio", "libdeps", pio_env, "SensorLib") + library_json_path = os.path.join(sensor_dir, "library.json") + # Both boards use BHI260AP. T-Deck additionally needs the GT911 base + # implementation; its concrete driver is header-only in SensorLib 0.3.3. + desired_src_filter = [ + "-<*>", + "+", + "+", + "+", + "+", + "+", + "+", + ] + if pio_env in ("tdeck", "tdeck_debug"): + desired_src_filter.append("+") + + update_library_build_metadata( + library_json_path, + {"srcFilter": desired_src_filter}, + f"SensorLib for {pio_env}", + ) + + +def configure_sdfat_for_sx1262_esp32(): + if not is_esp32_env or pio_env not in ( + "tlora_pager_sx1262", + "tlora_pager_sx1262_debug", + "tdeck", + "tdeck_debug", + ): + return + + sdfat_dir = os.path.join(project_dir, ".pio", "libdeps", pio_env, "SdFat") + library_json_path = os.path.join(sdfat_dir, "library.json") + # Preserve FAT32/exFAT and the generic Arduino SPI path while excluding + # formatters, streams, debug helpers, and other architectures' drivers. + desired_src_filter = [ + "-<*>", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + "+", + ] + create_library_build_metadata( + library_json_path, + { + "name": "SdFat", + "version": "2.3.1", + "frameworks": ["arduino"], + "platforms": ["*"], + }, + {"srcFilter": desired_src_filter}, + f"SdFat for {pio_env}", + ) + + def configure_nrf52_framework_libraries(): if not is_nrf52_node_env or not is_nrf52_env: return @@ -341,6 +589,11 @@ guard_no_arduino_sd_audio_paths() configure_radiolib_for_gat562() configure_crypto_for_gat562() configure_esp8266audio_for_esp32() +configure_radiolib_for_sx1262_esp32() +configure_lvgl_for_esp32_ui() +configure_crypto_for_sx1262_esp32() +configure_sensorlib_for_sx1262_esp32() +configure_sdfat_for_sx1262_esp32() configure_nrf52_framework_libraries() inject_project_version_define() diff --git a/third_party/codec2/library.json b/third_party/codec2/library.json index 1fae6a25..dfe6c4fd 100644 --- a/third_party/codec2/library.json +++ b/third_party/codec2/library.json @@ -10,75 +10,31 @@ "srcDir": "src", "srcFilter": [ "-<*>", - "+", - "+", - "+", - "+", - "+", - "+", - "+", - "+", - "+", - "+", - "+", - "+", "+", "+", "+", "+", - "+", - "+", - "+", "+", "+", "+", "+", "+", "+", - "+", - "+", - "+", - "+", - "+", - "+", - "+", - "+", - "+", - "+", - "+", - "+", - "+", - "+", - "+", - "+", - "+", - "+", "+", "+", "+", - "+", "+", - "+", "+", "+", "+", - "+", - "+", - "+", "+", "+", "+", - "+", - "+", - "+", "+", "+", - "+", "+", "+", - "+", - "+", - "+" + "+" ] } }