Skip to content

Commit b6a4a23

Browse files
committed
Build robotframework-browser-batteries
1 parent 0475e34 commit b6a4a23

File tree

1 file changed

+37
-23
lines changed

1 file changed

+37
-23
lines changed

tasks.py

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from xml.etree import ElementTree as ET
1515

1616
from invoke import Exit, task
17+
from invoke.context import Context
1718

1819
try:
1920
import bs4
@@ -239,6 +240,34 @@ def build(c):
239240
c.run("python -m Browser.gen_stub")
240241

241242

243+
def _os_platform() -> str:
244+
pl = platform.system().lower()
245+
if pl == "darwin":
246+
return "macos"
247+
elif pl == "windows":
248+
return "win"
249+
else:
250+
return "linux"
251+
252+
253+
def _build_nodejs(c: Context, architecture: str):
254+
"""Build NodeJS binary for GRPC server."""
255+
print(f"Build NodeJS binary to {NODE_BINARY_PATH}.")
256+
_copy_package_files()
257+
target = f"node22-{_os_platform()}-{architecture}"
258+
print(f"Target: {target}")
259+
index_js = WRAPPER_DIR.joinpath("index.js")
260+
c.run(
261+
f"pkg --public --targets {target} --output {NODE_BINARY_PATH.joinpath('grpc_server')} {index_js}"
262+
)
263+
264+
265+
@task(clean, build)
266+
def build_nodejs(c: Context, architecture: str):
267+
"""Build GRPC server binary from NodeJS side."""
268+
_build_nodejs(c, architecture)
269+
270+
242271
def _sources_changed(source_files: Iterable[Path], timestamp_file: Path):
243272
if timestamp_file.exists():
244273
last_built = timestamp_file.lstat().st_mtime
@@ -825,32 +854,17 @@ def create_package(c):
825854

826855

827856
@task(clean, build, docs, create_package)
828-
def package(c):
829-
"""Build python wheel for release."""
830-
831-
832-
def _os_platform():
833-
pl = platform.system().lower()
834-
if pl == "darwin":
835-
return "macos"
836-
elif pl == "windows":
837-
return "win"
838-
else:
839-
return "linux"
857+
def package(c: Context):
858+
"""Build python wheel for Browser release."""
840859

841860

842861
@task(clean, build)
843-
def package_nodejs(c, architecture):
844-
"""Build NodeJS binary for release."""
845-
print(f"Build NodeJS binary to {NODE_BINARY_PATH}.")
846-
847-
_copy_package_files()
848-
target = f"node22-{_os_platform()}-{architecture}"
849-
print(f"Target: {target}")
850-
index_js = WRAPPER_DIR.joinpath("index.js")
851-
c.run(
852-
f"pkg --public --targets {target} --output {NODE_BINARY_PATH.joinpath('grpc_server')} {index_js}"
853-
)
862+
def package_nodejs(c: Context, architecture: str):
863+
"""Build Python wheel from BrowserBattiers release."""
864+
_build_nodejs(c, architecture)
865+
with c.cd(BROWSER_BATTERIES_DIR):
866+
print(f"Building Browser Batteries package in {BROWSER_BATTERIES_DIR}")
867+
c.run("python -m build")
854868

855869

856870
@task

0 commit comments

Comments
 (0)