|
8 | 8 | import configparser |
9 | 9 | import platform |
10 | 10 |
|
11 | | -from pico_project import GenerateCMake |
| 11 | +from pico_project import GenerateCMake, copyExampleConfigs |
12 | 12 |
|
13 | 13 | # This script is designed to be run on Linux |
14 | 14 | assert platform.system() == "Linux" |
|
164 | 164 | os.system( |
165 | 165 | f"git -c advice.detachedHead=false clone https://github.com/raspberrypi/pico-examples.git --depth=1 --branch {EXAMPLES_BRANCH}" |
166 | 166 | ) |
167 | | -os.environ["PICO_SDK_PATH"] = f"~/.pico-sdk/sdk/{SDK_VERSION}" |
168 | | -os.environ["WIFI_SSID"] = "Your Wi-Fi SSID" |
169 | | -os.environ["WIFI_PASSWORD"] = "Your Wi-Fi Password" |
170 | | -os.environ["TEST_TCP_SERVER_IP"] = ( |
171 | | - "192.168.1.100" # This isn't read from environment variables, so also needs to be passed to cmake |
172 | | -) |
173 | | -os.environ["MQTT_SERVER"] = "myMQTTserver" |
| 167 | + |
| 168 | +PICO_SDK_PATH = f"~/.pico-sdk/sdk/{SDK_VERSION}" |
| 169 | +configure_env = { |
| 170 | + "PICO_SDK_PATH": PICO_SDK_PATH, |
| 171 | + "WIFI_SSID": "Your Wi-Fi SSID", |
| 172 | + "WIFI_PASSWORD": "Your Wi-Fi Password", |
| 173 | + "TEST_TCP_SERVER_IP": "192.168.1.100", # This isn't read from environment variables, so also needs to be passed to cmake |
| 174 | + "MQTT_SERVER": "myMQTTserver", |
| 175 | +} |
| 176 | + |
174 | 177 | os.environ["CFLAGS"] = "-Werror=cpp" |
175 | 178 | os.environ["CXXFLAGS"] = "-Werror=cpp" |
176 | 179 |
|
|
187 | 190 | ) |
188 | 191 | toolchainPath = f"~/.pico-sdk/toolchain/{toolchainVersion}" |
189 | 192 | picotoolDir = f"~/.pico-sdk/picotool/{SDK_VERSION}/picotool" |
| 193 | + |
| 194 | + # Setup env to find targets |
| 195 | + for k, v in configure_env.items(): |
| 196 | + os.environ[k] = v |
| 197 | + |
190 | 198 | os.system( |
191 | 199 | f"cmake -S pico-examples -B build -DPICO_BOARD={board} -DPICO_PLATFORM={platform} -DPICO_TOOLCHAIN_PATH={toolchainPath} -Dpicotool_DIR={picotoolDir} -DTEST_TCP_SERVER_IP=$TEST_TCP_SERVER_IP" |
192 | 200 | ) |
193 | 201 |
|
194 | 202 | os.system("cmake --build build --target help > targets.txt") |
195 | 203 |
|
| 204 | + # Clear env for clean tests |
| 205 | + for k in configure_env.keys(): |
| 206 | + del os.environ[k] |
| 207 | + |
196 | 208 | targets = [] |
197 | 209 |
|
198 | 210 | with open("targets.txt", "r") as f: |
@@ -295,24 +307,12 @@ def test_build(target, v): |
295 | 307 | "exampleLibs": v["libs"], |
296 | 308 | } |
297 | 309 | GenerateCMake(dir, params) |
298 | | - if os.path.exists(f"{dir}/lwipopts.h"): |
299 | | - with open(f"{dir}/lwipopts.h", "r") as f: |
300 | | - if "lwipopts_examples_common.h" in f.read(): |
301 | | - # Write lwipopts for examples |
302 | | - shutil.copy( |
303 | | - f"{os.path.dirname(os.path.realpath(__file__))}/lwipopts.h", |
304 | | - f"{dir}/lwipopts_examples_common.h", |
305 | | - ) |
306 | | - |
307 | | - if os.path.exists(f"{dir}/mbedtls_config.h"): |
308 | | - with open(f"{dir}/mbedtls_config.h", "r") as f: |
309 | | - if "mbedtls_config_examples_common.h" in f.read(): |
310 | | - # Write mbedtls_config for examples |
311 | | - shutil.copy( |
312 | | - f"{os.path.dirname(os.path.realpath(__file__))}/mbedtls_config.h", |
313 | | - f"{dir}/mbedtls_config_examples_common.h", |
314 | | - ) |
315 | | - shutil.copy("pico-examples/pico_sdk_import.cmake", f"{dir}/") |
| 310 | + copyExampleConfigs(dir) |
| 311 | + |
| 312 | + shutil.copy( |
| 313 | + os.path.expanduser(f"{PICO_SDK_PATH}/external/pico_sdk_import.cmake"), |
| 314 | + f"{dir}/", |
| 315 | + ) |
316 | 316 |
|
317 | 317 | retcmake = os.system(f"cmake -S {dir} -B {dir}-build -GNinja") |
318 | 318 | retbuild = os.system(f"cmake --build {dir}-build") |
|
0 commit comments