""" Pre-build script for Kode Dot FTP Explorer. Resolves ESP32 Arduino Core 3.x framework library paths dynamically and compiles framework libraries that PlatformIO's LDF doesn't auto-discover (Network, FFat). Also adds include paths for all framework libraries needed by SimpleFTPServer. """ Import("env") import os framework_dir = env.PioPlatform().get_package_dir("framework-arduinoespressif32") libs_dir = os.path.join(framework_dir, "libraries") # Framework libraries whose include paths are needed by SimpleFTPServer # and our code (some may already be discovered by LDF — adding extras is harmless) INCLUDE_LIBS = [ "Network", "WiFi", "FS", "SD_MMC", "SD", "SPI", "FFat", "SPIFFS", "LittleFS", ] for lib_name in INCLUDE_LIBS: inc_dir = os.path.join(libs_dir, lib_name, "src") if os.path.isdir(inc_dir): env.Append(CPPPATH=[inc_dir]) # These libraries are NOT auto-discovered by PlatformIO's LDF # and must be explicitly compiled COMPILE_LIBS = ["Network", "FFat"] for lib_name in COMPILE_LIBS: src_dir = os.path.join(libs_dir, lib_name, "src") if os.path.isdir(src_dir): env.BuildSources( os.path.join("$BUILD_DIR", "Framework" + lib_name), src_dir, )