Skip to content

Commit 02d004d

Browse files
committed
Switch to native Python subprocess calls for ULP build workflow
This workaround allows to bypass a limit of 8192 symbols on Windows for external command
1 parent e2f552f commit 02d004d

File tree

1 file changed

+38
-29
lines changed

1 file changed

+38
-29
lines changed

builder/frameworks/ulp.py

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from platformio import fs
1818
from platformio.util import get_systype
19-
from platformio.proc import where_is_program
19+
from platformio.proc import where_is_program, exec_command
2020

2121
from SCons.Script import Import
2222

@@ -77,41 +77,50 @@ def get_component_includes(target_config):
7777

7878

7979
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)
81114

82115
ulp_sources = collect_ulp_sources()
83116
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-
)
110117

111118
return ulp_env.Command(
112119
os.path.join(ULP_BUILD_DIR, "build.ninja"),
113120
ulp_sources,
114-
ulp_env.VerboseAction(" ".join(cmd), "Generating ULP configuration"),
121+
ulp_env.VerboseAction(
122+
_generate_ulp_configuration_action, "Generating ULP configuration"
123+
),
115124
)
116125

117126

0 commit comments

Comments
 (0)