Skip to content

Commit

Permalink
Clean up extract logic a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
dwoz committed Sep 2, 2024
1 parent 85e1126 commit 4b4a446
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/ppbt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"""
Portable Python Build Toolchains.
"""
from .common import environ
from .common import environ, extract

ALL = ("environ",)
ALL = ("environ", "extract")
17 changes: 14 additions & 3 deletions src/ppbt/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
log = logging.getLogger(__name__)


def environ():
def extract(overwrite=False):
"""
Toolchain build environment.
Extract the toolchain tarball.
"""
if toolchain.exists():
if toolchain.exists() and not overwrite:
log.debug("Toolchain directory exists")
else:
log.info("Extract archive")
Expand All @@ -46,6 +46,17 @@ def environ():
writer = csv.writer(fp)
for row in records:
writer.writerow(row)


def environ(auto_extract=False):
"""
Toolchain build environment.
"""
if not toolchain.exists():
if auto_extract:
extract()
else:
raise RuntimeError("Toolchain not extracted")
basebin = toolchain / "bin" / triplet
return {
"TOOLCHAIN_PATH": f"{toolchain}",
Expand Down

0 comments on commit 4b4a446

Please sign in to comment.