|
36 | 36 | from platformio.package.manager.tool import ToolPackageManager
|
37 | 37 |
|
38 | 38 | env = DefaultEnvironment()
|
| 39 | +pm = ToolPackageManager() |
39 | 40 | platform = env.PioPlatform()
|
40 | 41 | config = env.GetProjectConfig()
|
41 | 42 | board = env.BoardConfig()
|
42 | 43 | mcu = board.get("build.mcu", "esp32")
|
43 | 44 | flag_custom_sdkconfig = config.has_option("env:"+env["PIOENV"], "custom_sdkconfig")
|
44 |
| -framework_reinstall = False |
45 |
| - |
46 |
| -extra_flags = ''.join([element.replace("-D", " ") for element in board.get("build.extra_flags", "")]) |
| 45 | +extra_flags = (''.join([element for element in board.get("build.extra_flags", "")])).replace("-D", " ") |
47 | 46 | build_flags = ''.join([element.replace("-D", " ") for element in env.GetProjectOption("build_flags")])
|
48 |
| -pm = ToolPackageManager() |
49 |
| - |
50 |
| -SConscript("_embed_files.py", exports="env") |
| 47 | +framework_reinstall = False |
| 48 | +flag_any_custom_sdkconfig = False |
51 | 49 |
|
52 |
| -if ("CORE32SOLO1" in extra_flags or "FRAMEWORK_ARDUINO_SOLO1" in build_flags) and ("arduino" in env.subst("$PIOFRAMEWORK")) and flag_custom_sdkconfig == False: |
| 50 | +if ("CORE32SOLO1" in extra_flags or "FRAMEWORK_ARDUINO_SOLO1" in build_flags) and ("arduino" in env.subst("$PIOFRAMEWORK")) and not flag_custom_sdkconfig: |
53 | 51 | FRAMEWORK_DIR = platform.get_package_dir("framework-arduino-solo1")
|
54 |
| -elif ("CORE32ITEAD" in extra_flags or "FRAMEWORK_ARDUINO_ITEAD" in build_flags) and ("arduino" in env.subst("$PIOFRAMEWORK")) and flag_custom_sdkconfig == False: |
| 52 | +elif ("CORE32ITEAD" in extra_flags or "FRAMEWORK_ARDUINO_ITEAD" in build_flags) and ("arduino" in env.subst("$PIOFRAMEWORK")) and not flag_custom_sdkconfig: |
55 | 53 | FRAMEWORK_DIR = platform.get_package_dir("framework-arduino-ITEAD")
|
56 | 54 | elif "arduino" in env.subst("$PIOFRAMEWORK") and "CORE32SOLO1" not in extra_flags and "FRAMEWORK_ARDUINO_SOLO1" not in build_flags and "CORE32ITEAD" not in extra_flags and "FRAMEWORK_ARDUINO_ITEAD" not in build_flags:
|
57 | 55 | FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")
|
58 |
| -elif "arduino" in env.subst("$PIOFRAMEWORK") and flag_custom_sdkconfig == True: |
| 56 | +elif "arduino" in env.subst("$PIOFRAMEWORK") and flag_custom_sdkconfig: |
59 | 57 | FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")
|
60 | 58 |
|
61 |
| -flag_any_custom_sdkconfig = os.path.exists(join(FRAMEWORK_DIR,"tools","esp32-arduino-libs","sdkconfig")) |
62 |
| - |
63 |
| -def get_MD5_hash(phrase): |
64 |
| - import hashlib |
65 |
| - return hashlib.md5((phrase).encode('utf-8')).hexdigest()[:16] |
66 |
| - |
67 |
| - |
68 |
| -def matching_custom_sdkconfig(): |
69 |
| - # check if current env is matching to existing sdkconfig |
70 |
| - cust_sdk_is_present = False |
71 |
| - matching_sdkconfig = False |
72 |
| - last_sdkconfig_path = join(env.subst("$PROJECT_DIR"),"sdkconfig.defaults") |
73 |
| - if flag_any_custom_sdkconfig == False: |
74 |
| - matching_sdkconfig = True |
75 |
| - return matching_sdkconfig, cust_sdk_is_present |
76 |
| - if os.path.exists(last_sdkconfig_path) == False: |
77 |
| - return matching_sdkconfig, cust_sdk_is_present |
78 |
| - if flag_custom_sdkconfig == False: |
79 |
| - matching_sdkconfig = False |
80 |
| - return matching_sdkconfig, cust_sdk_is_present |
81 |
| - with open(last_sdkconfig_path) as src: |
82 |
| - line = src.readline() |
83 |
| - if line.startswith("# TASMOTA__"): |
84 |
| - cust_sdk_is_present = True; |
85 |
| - costum_options = env.GetProjectOption("custom_sdkconfig") |
86 |
| - if (line.split("__")[1]).strip() == get_MD5_hash((costum_options).strip() + mcu): |
87 |
| - matching_sdkconfig = True |
88 |
| - |
89 |
| - return matching_sdkconfig, cust_sdk_is_present |
90 |
| - |
91 |
| -def check_reinstall_frwrk(): |
92 |
| - framework_reinstall = False |
93 |
| - cust_sdk_is_present = False |
94 |
| - matching_sdkconfig = False |
95 |
| - if flag_custom_sdkconfig: |
96 |
| - matching_sdkconfig, cust_sdk_is_present = matching_custom_sdkconfig() |
97 |
| - if flag_custom_sdkconfig == False and flag_any_custom_sdkconfig == True: |
98 |
| - # case custom sdkconfig exists and a env without "custom_sdkconfig" |
99 |
| - framework_reinstall = True |
100 |
| - if flag_custom_sdkconfig == True and matching_sdkconfig == False: |
101 |
| - # check if current custom sdkconfig is different from existing |
102 |
| - framework_reinstall = True |
103 |
| - return framework_reinstall |
104 |
| - |
105 |
| -def call_compile_libs(): |
106 |
| - print("*** Compile Arduino IDF libs for %s ***" % env["PIOENV"]) |
107 |
| - SConscript("espidf.py") |
108 |
| - |
109 |
| -if check_reinstall_frwrk() == True: |
110 |
| - print("*** Reinstall Arduino framework ***") |
111 |
| - shutil.rmtree(FRAMEWORK_DIR) |
112 |
| - ARDUINO_FRMWRK_URL = str(platform.get_package_spec("framework-arduinoespressif32")).split("uri=",1)[1][:-1] |
113 |
| - pm.install(ARDUINO_FRMWRK_URL) |
114 |
| - if flag_custom_sdkconfig == True: |
115 |
| - call_compile_libs() |
116 |
| - flag_custom_sdkconfig = False |
117 |
| - |
118 |
| -if flag_custom_sdkconfig == True and flag_any_custom_sdkconfig == False: |
119 |
| - call_compile_libs() |
| 59 | +SConscript("_embed_files.py", exports="env") |
120 | 60 |
|
| 61 | +if "framework-arduinoespressif32" in FRAMEWORK_DIR: |
| 62 | + flag_any_custom_sdkconfig = os.path.exists(join(platform.get_package_dir("framework-arduinoespressif32"),"tools","esp32-arduino-libs","sdkconfig")) |
| 63 | + |
| 64 | +# Esp32-solo1 libs needs adopted settings |
| 65 | +if flag_custom_sdkconfig and "CORE32SOLO1" in extra_flags and "CONFIG_FREERTOS_UNICORE=y" in env.GetProjectOption("custom_sdkconfig"): |
| 66 | + if len(str(env.GetProjectOption("build_flags"))) > 2: |
| 67 | + build_flags = " ".join(env['BUILD_FLAGS']) |
| 68 | + build_flags = build_flags + " -Tesp32.rom.newlib-funcs.ld" |
| 69 | + new_build_flags = build_flags.split() |
| 70 | + env.Replace( |
| 71 | + BUILD_FLAGS=new_build_flags |
| 72 | + ) |
| 73 | + if len(str(env.GetProjectOption("build_unflags"))) > 2: |
| 74 | + build_unflags = " ".join(env['BUILD_UNFLAGS']) |
| 75 | + build_unflags = build_unflags + " -mdisable-hardware-atomics -ustart_app_other_cores" |
| 76 | + new_build_unflags = build_unflags.split() |
| 77 | + env.Replace( |
| 78 | + BUILD_UNFLAGS=new_build_unflags |
| 79 | + ) |
121 | 80 |
|
122 | 81 | def install_python_deps():
|
123 | 82 | def _get_installed_pip_packages():
|
@@ -176,6 +135,65 @@ def _get_installed_pip_packages():
|
176 | 135 | )
|
177 | 136 | return
|
178 | 137 |
|
| 138 | +install_python_deps() |
| 139 | + |
| 140 | +def get_MD5_hash(phrase): |
| 141 | + import hashlib |
| 142 | + return hashlib.md5((phrase).encode('utf-8')).hexdigest()[:16] |
| 143 | + |
| 144 | + |
| 145 | +def matching_custom_sdkconfig(): |
| 146 | + # check if current env is matching to existing sdkconfig |
| 147 | + cust_sdk_is_present = False |
| 148 | + matching_sdkconfig = False |
| 149 | + last_sdkconfig_path = join(env.subst("$PROJECT_DIR"),"sdkconfig.defaults") |
| 150 | + if flag_any_custom_sdkconfig == False: |
| 151 | + matching_sdkconfig = True |
| 152 | + return matching_sdkconfig, cust_sdk_is_present |
| 153 | + if os.path.exists(last_sdkconfig_path) == False: |
| 154 | + return matching_sdkconfig, cust_sdk_is_present |
| 155 | + if flag_custom_sdkconfig == False: |
| 156 | + matching_sdkconfig = False |
| 157 | + return matching_sdkconfig, cust_sdk_is_present |
| 158 | + with open(last_sdkconfig_path) as src: |
| 159 | + line = src.readline() |
| 160 | + if line.startswith("# TASMOTA__"): |
| 161 | + cust_sdk_is_present = True; |
| 162 | + costum_options = env.GetProjectOption("custom_sdkconfig") |
| 163 | + if (line.split("__")[1]).strip() == get_MD5_hash((costum_options).strip() + mcu): |
| 164 | + matching_sdkconfig = True |
| 165 | + |
| 166 | + return matching_sdkconfig, cust_sdk_is_present |
| 167 | + |
| 168 | +def check_reinstall_frwrk(): |
| 169 | + framework_reinstall = False |
| 170 | + cust_sdk_is_present = False |
| 171 | + matching_sdkconfig = False |
| 172 | + if flag_custom_sdkconfig: |
| 173 | + matching_sdkconfig, cust_sdk_is_present = matching_custom_sdkconfig() |
| 174 | + if flag_custom_sdkconfig == False and flag_any_custom_sdkconfig == True: |
| 175 | + # case custom sdkconfig exists and a env without "custom_sdkconfig" |
| 176 | + framework_reinstall = True |
| 177 | + if flag_custom_sdkconfig == True and matching_sdkconfig == False: |
| 178 | + # check if current custom sdkconfig is different from existing |
| 179 | + framework_reinstall = True |
| 180 | + return framework_reinstall |
| 181 | + |
| 182 | +def call_compile_libs(): |
| 183 | + print("*** Compile Arduino IDF libs for %s ***" % env["PIOENV"]) |
| 184 | + SConscript("espidf.py") |
| 185 | + |
| 186 | +if check_reinstall_frwrk() == True: |
| 187 | + print("*** Reinstall Arduino framework ***") |
| 188 | + shutil.rmtree(platform.get_package_dir("framework-arduinoespressif32")) |
| 189 | + ARDUINO_FRMWRK_URL = str(platform.get_package_spec("framework-arduinoespressif32")).split("uri=",1)[1][:-1] |
| 190 | + pm.install(ARDUINO_FRMWRK_URL) |
| 191 | + if flag_custom_sdkconfig == True: |
| 192 | + call_compile_libs() |
| 193 | + flag_custom_sdkconfig = False |
| 194 | + |
| 195 | +if flag_custom_sdkconfig == True and flag_any_custom_sdkconfig == False: |
| 196 | + call_compile_libs() |
| 197 | + |
179 | 198 | if "arduino" in env.subst("$PIOFRAMEWORK") and "espidf" not in env.subst("$PIOFRAMEWORK") and env.subst("$ARDUINO_LIB_COMPILE_FLAG") in ("Inactive", "True"):
|
180 |
| - install_python_deps() |
181 | 199 | SConscript(join(FRAMEWORK_DIR, "tools", "platformio-build.py"))
|
0 commit comments