2022-07-06 21:37:19 +00:00
|
|
|
import os
|
2022-11-17 01:05:14 +00:00
|
|
|
from pathlib import Path
|
2023-01-04 23:45:20 +00:00
|
|
|
from typing import Any
|
2022-07-06 21:37:19 +00:00
|
|
|
|
|
|
|
from .. import common, pypabuild, pywasmcross
|
|
|
|
|
|
|
|
|
2023-01-04 23:45:20 +00:00
|
|
|
def run(exports: Any, args: list[str], outdir: Path | None = None) -> Path:
|
|
|
|
if outdir is None:
|
|
|
|
outdir = Path("./dist")
|
2022-07-06 21:37:19 +00:00
|
|
|
cflags = common.get_make_flag("SIDE_MODULE_CFLAGS")
|
|
|
|
cflags += f" {os.environ.get('CFLAGS', '')}"
|
|
|
|
cxxflags = common.get_make_flag("SIDE_MODULE_CXXFLAGS")
|
|
|
|
cxxflags += f" {os.environ.get('CXXFLAGS', '')}"
|
|
|
|
ldflags = common.get_make_flag("SIDE_MODULE_LDFLAGS")
|
|
|
|
ldflags += f" {os.environ.get('LDFLAGS', '')}"
|
2022-11-17 01:05:14 +00:00
|
|
|
|
2022-07-06 21:37:19 +00:00
|
|
|
build_env_ctx = pywasmcross.get_build_env(
|
|
|
|
env=os.environ.copy(),
|
|
|
|
pkgname="",
|
|
|
|
cflags=cflags,
|
|
|
|
cxxflags=cxxflags,
|
|
|
|
ldflags=ldflags,
|
|
|
|
target_install_dir="",
|
|
|
|
exports=exports,
|
|
|
|
)
|
|
|
|
|
|
|
|
with build_env_ctx as env:
|
2023-01-04 23:45:20 +00:00
|
|
|
built_wheel = pypabuild.build(env, " ".join(args), outdir=str(outdir))
|
|
|
|
return Path(built_wheel)
|