|
16 | 16 |
|
17 | 17 | from platformio import fs
|
18 | 18 | from platformio.util import get_systype
|
19 |
| -from platformio.proc import where_is_program |
| 19 | +from platformio.proc import where_is_program, exec_command |
20 | 20 |
|
21 | 21 | from SCons.Script import Import
|
22 | 22 |
|
@@ -77,41 +77,50 @@ def get_component_includes(target_config):
|
77 | 77 |
|
78 | 78 |
|
79 | 79 | def generate_ulp_config(target_config):
|
80 |
| - riscv_ulp_enabled = sdk_config.get("ULP_COPROC_TYPE_RISCV", False) |
| 80 | + def _generate_ulp_configuration_action(env, target, source): |
| 81 | + riscv_ulp_enabled = sdk_config.get("ULP_COPROC_TYPE_RISCV", False) |
| 82 | + |
| 83 | + cmd = ( |
| 84 | + os.path.join(platform.get_package_dir("tool-cmake"), "bin", "cmake"), |
| 85 | + "-DCMAKE_GENERATOR=Ninja", |
| 86 | + "-DCMAKE_TOOLCHAIN_FILE=" |
| 87 | + + os.path.join( |
| 88 | + FRAMEWORK_DIR, |
| 89 | + "components", |
| 90 | + "ulp", |
| 91 | + "cmake", |
| 92 | + "toolchain-%sulp%s.cmake" |
| 93 | + % ( |
| 94 | + "" if riscv_ulp_enabled else idf_variant + "-", |
| 95 | + "-riscv" if riscv_ulp_enabled else "", |
| 96 | + ), |
| 97 | + ), |
| 98 | + "-DULP_S_SOURCES=%s" % ";".join([s.get_abspath() for s in source]), |
| 99 | + "-DULP_APP_NAME=ulp_main", |
| 100 | + "-DCOMPONENT_DIR=" + os.path.join(ulp_env.subst("$PROJECT_DIR"), "ulp"), |
| 101 | + "-DCOMPONENT_INCLUDES=%s" % ";".join(get_component_includes(target_config)), |
| 102 | + "-DIDF_TARGET=%s" % idf_variant, |
| 103 | + "-DIDF_PATH=" + fs.to_unix_path(FRAMEWORK_DIR), |
| 104 | + "-DSDKCONFIG_HEADER=" + os.path.join(BUILD_DIR, "config", "sdkconfig.h"), |
| 105 | + "-DPYTHON=" + env.subst("$PYTHONEXE"), |
| 106 | + "-DULP_COCPU_IS_RISCV=%s" % ("ON" if riscv_ulp_enabled else "OFF"), |
| 107 | + "-GNinja", |
| 108 | + "-B", |
| 109 | + ULP_BUILD_DIR, |
| 110 | + os.path.join(FRAMEWORK_DIR, "components", "ulp", "cmake"), |
| 111 | + ) |
| 112 | + |
| 113 | + exec_command(cmd) |
81 | 114 |
|
82 | 115 | ulp_sources = collect_ulp_sources()
|
83 | 116 | ulp_sources.sort()
|
84 |
| - cmd = ( |
85 |
| - os.path.join(platform.get_package_dir("tool-cmake"), "bin", "cmake"), |
86 |
| - "-DCMAKE_GENERATOR=Ninja", |
87 |
| - "-DCMAKE_TOOLCHAIN_FILE=" |
88 |
| - + os.path.join( |
89 |
| - FRAMEWORK_DIR, |
90 |
| - "components", |
91 |
| - "ulp", |
92 |
| - "cmake", |
93 |
| - "toolchain-%sulp%s.cmake" |
94 |
| - % ("" if riscv_ulp_enabled else idf_variant + "-", "-riscv" if riscv_ulp_enabled else ""), |
95 |
| - ), |
96 |
| - '-DULP_S_SOURCES="%s"' % ";".join(ulp_sources), |
97 |
| - "-DULP_APP_NAME=ulp_main", |
98 |
| - "-DCOMPONENT_DIR=" + os.path.join(ulp_env.subst("$PROJECT_DIR"), "ulp"), |
99 |
| - '-DCOMPONENT_INCLUDES="%s"' % ";".join(get_component_includes(target_config)), |
100 |
| - "-DIDF_TARGET=%s" % idf_variant, |
101 |
| - "-DIDF_PATH=" + fs.to_unix_path(FRAMEWORK_DIR), |
102 |
| - "-DSDKCONFIG_HEADER=" + os.path.join(BUILD_DIR, "config", "sdkconfig.h"), |
103 |
| - "-DPYTHON=" + env.subst("$PYTHONEXE"), |
104 |
| - "-DULP_COCPU_IS_RISCV=%s" % ("ON" if riscv_ulp_enabled else "OFF"), |
105 |
| - "-GNinja", |
106 |
| - "-B", |
107 |
| - ULP_BUILD_DIR, |
108 |
| - os.path.join(FRAMEWORK_DIR, "components", "ulp", "cmake"), |
109 |
| - ) |
110 | 117 |
|
111 | 118 | return ulp_env.Command(
|
112 | 119 | os.path.join(ULP_BUILD_DIR, "build.ninja"),
|
113 | 120 | ulp_sources,
|
114 |
| - ulp_env.VerboseAction(" ".join(cmd), "Generating ULP configuration"), |
| 121 | + ulp_env.VerboseAction( |
| 122 | + _generate_ulp_configuration_action, "Generating ULP configuration" |
| 123 | + ), |
115 | 124 | )
|
116 | 125 |
|
117 | 126 |
|
|
0 commit comments