|
14 | 14 | from xml.etree import ElementTree as ET
|
15 | 15 |
|
16 | 16 | from invoke import Exit, task
|
| 17 | +from invoke.context import Context |
17 | 18 |
|
18 | 19 | try:
|
19 | 20 | import bs4
|
@@ -239,6 +240,34 @@ def build(c):
|
239 | 240 | c.run("python -m Browser.gen_stub")
|
240 | 241 |
|
241 | 242 |
|
| 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 | + |
242 | 271 | def _sources_changed(source_files: Iterable[Path], timestamp_file: Path):
|
243 | 272 | if timestamp_file.exists():
|
244 | 273 | last_built = timestamp_file.lstat().st_mtime
|
@@ -825,32 +854,17 @@ def create_package(c):
|
825 | 854 |
|
826 | 855 |
|
827 | 856 | @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.""" |
840 | 859 |
|
841 | 860 |
|
842 | 861 | @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") |
854 | 868 |
|
855 | 869 |
|
856 | 870 | @task
|
|
0 commit comments