Skip to content

Commit

Permalink
Merge commit '33ffdf6fd07d15e647f1208be24ac644769c4425' into EOY_stubber
Browse files Browse the repository at this point in the history
Signed-off-by: Jos Verlinde <Jos.Verlinde@microsoft.com>
  • Loading branch information
Josverl committed Jan 1, 2025
2 parents 1debb45 + 33ffdf6 commit 995c05b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/stubber/freeze/freeze_manifest_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,20 @@ def make_path_vars(
raise ValueError("board path not found")

# VARS must be absolute paths
return {
vars = {
"MPY_DIR": mpy_path.absolute().as_posix(),
"MPY_LIB_DIR": mpy_lib_path.absolute().as_posix(),
"PORT_DIR": port_path.absolute().as_posix(),
"BOARD_DIR": board_path.absolute().as_posix(),
}

if board and "ARDUINO" in board:
log.warning(f"HACK- Adding [TOP]/lib/arduino-lib to paths: {board}")
# see micropython/ports/renesas-ra/boards/ARDUINO_PORTENTA_C33/mpconfigboard.mk
vars["ARDUINO_LIB_DIR"] = (mpy_path / "lib/arduino-lib").absolute().as_posix()

return vars


def freeze_one_manifest_2(
manifest: Path, frozen_stub_path: Path, mpy_path: Path, mpy_lib_path: Path, version: str
Expand Down
14 changes: 14 additions & 0 deletions src/stubber/freeze/get_frozen.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
# - 1.11 and older - include content of /port/modules folder if it exists
import os
import shutil # start moving from os & glob to pathlib
import subprocess

from pathlib import Path
from typing import List, Optional

Expand Down Expand Up @@ -59,6 +61,16 @@ def add_comment_to_path(path: Path, comment: str) -> None:
pass


def checkout_arduino_lib(mpy_path: Path):
"""
Checkout the arduino-lib repo if it is not already checked out
"""
# arduino_lib_path = mpy_path / "lib/arduino-lib"
cmd = ["git", "submodule", "update", "--init", "lib/arduino-lib"]
result = subprocess.run(cmd, cwd=mpy_path, check=True)
log.info(f"checkout arduino-lib: {result.returncode}")


def freeze_any(
stub_folder: Optional[Path] = None,
version: str = V_PREVIEW,
Expand All @@ -78,6 +90,8 @@ def freeze_any(
mpy_path = Path(mpy_path).absolute() if mpy_path else CONFIG.mpy_path.absolute()
mpy_lib_path = Path(mpy_lib_path).absolute() if mpy_lib_path else CONFIG.mpy_path.absolute()

if version > "v1.23.0" or version in SET_PREVIEW:
checkout_arduino_lib(mpy_path)
# if old version of micropython, use the old freeze method
if version not in SET_PREVIEW and Version(version) <= Version("1.11"):
frozen_stub_path = get_fsp(version, stub_folder)
Expand Down

0 comments on commit 995c05b

Please sign in to comment.