Skip to content

Commit

Permalink
Switch to native Python subprocess calls for ULP build workflow
Browse files Browse the repository at this point in the history
This workaround allows a limit of 8192 symbols on Windows can be avoided
  • Loading branch information
valeros committed Mar 26, 2024
1 parent 312331d commit 6eb46dd
Showing 1 changed file with 38 additions and 29 deletions.
67 changes: 38 additions & 29 deletions builder/frameworks/ulp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from platformio import fs
from platformio.util import get_systype
from platformio.proc import where_is_program
from platformio.proc import where_is_program, exec_command

from SCons.Script import Import

Expand Down Expand Up @@ -77,41 +77,50 @@ def get_component_includes(target_config):


def generate_ulp_config(target_config):
riscv_ulp_enabled = sdk_config.get("ULP_COPROC_TYPE_RISCV", False)
def _generate_ulp_configuration_action(env, target, source):
riscv_ulp_enabled = sdk_config.get("ULP_COPROC_TYPE_RISCV", False)

cmd = (
os.path.join(platform.get_package_dir("tool-cmake"), "bin", "cmake"),
"-DCMAKE_GENERATOR=Ninja",
"-DCMAKE_TOOLCHAIN_FILE="
+ os.path.join(
FRAMEWORK_DIR,
"components",
"ulp",
"cmake",
"toolchain-%sulp%s.cmake"
% (
"" if riscv_ulp_enabled else idf_variant + "-",
"-riscv" if riscv_ulp_enabled else "",
),
),
"-DULP_S_SOURCES=%s" % ";".join([s.get_abspath() for s in source]),
"-DULP_APP_NAME=ulp_main",
"-DCOMPONENT_DIR=" + os.path.join(ulp_env.subst("$PROJECT_DIR"), "ulp"),
"-DCOMPONENT_INCLUDES=%s" % ";".join(get_component_includes(target_config)),
"-DIDF_TARGET=%s" % idf_variant,
"-DIDF_PATH=" + fs.to_unix_path(FRAMEWORK_DIR),
"-DSDKCONFIG_HEADER=" + os.path.join(BUILD_DIR, "config", "sdkconfig.h"),
"-DPYTHON=" + env.subst("$PYTHONEXE"),
"-DULP_COCPU_IS_RISCV=%s" % ("ON" if riscv_ulp_enabled else "OFF"),
"-GNinja",
"-B",
ULP_BUILD_DIR,
os.path.join(FRAMEWORK_DIR, "components", "ulp", "cmake"),
)

exec_command(cmd)

ulp_sources = collect_ulp_sources()
ulp_sources.sort()
cmd = (
os.path.join(platform.get_package_dir("tool-cmake"), "bin", "cmake"),
"-DCMAKE_GENERATOR=Ninja",
"-DCMAKE_TOOLCHAIN_FILE="
+ os.path.join(
FRAMEWORK_DIR,
"components",
"ulp",
"cmake",
"toolchain-%sulp%s.cmake"
% ("" if riscv_ulp_enabled else idf_variant + "-", "-riscv" if riscv_ulp_enabled else ""),
),
'-DULP_S_SOURCES="%s"' % ";".join(ulp_sources),
"-DULP_APP_NAME=ulp_main",
"-DCOMPONENT_DIR=" + os.path.join(ulp_env.subst("$PROJECT_DIR"), "ulp"),
'-DCOMPONENT_INCLUDES="%s"' % ";".join(get_component_includes(target_config)),
"-DIDF_TARGET=%s" % idf_variant,
"-DIDF_PATH=" + fs.to_unix_path(FRAMEWORK_DIR),
"-DSDKCONFIG_HEADER=" + os.path.join(BUILD_DIR, "config", "sdkconfig.h"),
"-DPYTHON=" + env.subst("$PYTHONEXE"),
"-DULP_COCPU_IS_RISCV=%s" % ("ON" if riscv_ulp_enabled else "OFF"),
"-GNinja",
"-B",
ULP_BUILD_DIR,
os.path.join(FRAMEWORK_DIR, "components", "ulp", "cmake"),
)

return ulp_env.Command(
os.path.join(ULP_BUILD_DIR, "build.ninja"),
ulp_sources,
ulp_env.VerboseAction(" ".join(cmd), "Generating ULP configuration"),
ulp_env.VerboseAction(
_generate_ulp_configuration_action, "Generating ULP configuration"
),
)


Expand Down

0 comments on commit 6eb46dd

Please sign in to comment.