ESP3D/platformIO/extra_script.py
Luc bf460f87fa Fix Fat /Fat2 not compiling on esp8266
Add sanity check when doing get state for refresh
Fix help for [ESP202]
Add SDFAT2 description in configuration.h
2022-01-09 16:07:32 +08:00

41 lines
1.7 KiB
Python

from os.path import join, isfile
import re
Import("env")
# access to global construction environment
ROOT_DIR = env['PROJECT_DIR']
# configuration file
configuration_file = join(ROOT_DIR, "esp3d", "configuration.h")
if isfile(configuration_file):
fh = open(configuration_file, 'r')
for line in fh:
entry = re.search('^#define(\s)*SD_DEVICE(\s)*ESP_SDFAT', line)
entry2 = re.search('^#define(\s)*SD_DEVICE(\s)*ESP_SDFAT2', line)
if entry:
if (env["PIOPLATFORM"] == "espressif8266"):
lib_ignore = env.GetProjectOption("lib_ignore")
lib_ignore.append("SD(esp8266)")
lib_ignore.append("SD")
lib_ignore.append("SDFS")
print("Ignore libs:", lib_ignore)
env.GetProjectConfig().set(
"env:" + env["PIOENV"], "lib_ignore", lib_ignore)
if entry2:
print("Add ESP8266SDFat2 library to path")
env["LIBSOURCE_DIRS"].append(
"extra-libraries/ESP8266SDFat2")
else:
print("Add ESP8266SDFat library to path")
env["LIBSOURCE_DIRS"].append(
"extra-libraries/ESP8266SDFat")
else:
if entry2:
print("Add SDFat2 library to path")
env["LIBSOURCE_DIRS"].append("extra-libraries/SDFat2")
else:
print("Add SDFat library to path")
env["LIBSOURCE_DIRS"].append("extra-libraries/SDFat")
fh.close()
else:
print("No configuration.h file found")
print(env["LIBSOURCE_DIRS"])