mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-18 19:16:22 +00:00
* refactor 1: new typer based cli and browseros cli module * refactor 2: fixes to context.py * refactor 3: common/ and notify * new sign and package module * update .gitignore * refactor 5: dev.py and modules for each * refactor 6: clean-up old files * refactor 7: organise modules fruther * refactor 8: renaming nxtscape to browseros * refactor 9: dev.py remove cli load * fix: pyproject.toml * fix: typer pretty exception disable * refactor 10: cli/build.py set to primary * refactor 10: cli/build.py set to primary, move OS detection * refactor: context split, env and module dataclass * reactor: clean and git moved ot new module type * refactor: compile and configure * reactor: sign and package module update * refactor: new build.py cli * 'refactor: remove reducant OS checks * refactor: rename BuildContext to Context * refactor: rename BuildModule to CommandModule * refactor: dev.py to use the new modules * build.py: improve help output * remove old patching way * clean-up: remove old build.py stuff * refactor: move to proper yaml parsing * clean-up: remove legacy args gating * fix: patches issues * fix: clean-up build.py and ars resolver * minor: gitignore * fix: patches.py issue * support universal build * fix: ENV variable and YAMLs * fix: move compile to folder to avoid compflics * fixes: more env fixes * fix: build_type override in CLI fix * fix: universal clean all archs before starting * fix: universal build type constants * fix: linter, extract options * fix: linter * fix: remove chromium_src as a not a conflicting flag * fix: support chromium_src from cli in config mode * fix: notify with better messages * feat: new apply patch with --reset-to feature * feat: refactor apply and extract into separate sub modules * 142 patches working (#211) * updates to build.py apply/patch * removed all old patches * 142 build update * fix: get updated patches from main to 142 * fix: correct patches dir * fix: import path * add pyright * fix: setup pyright * fix: new updated patches from 137 rebased on 142 * feat: new extract_patch command * fix: add mising side_panel build patch * fix: extension uninstall for browseros * fix: prefs fix * fix: ota extension updater patch fix * fix: llm hub and chat * feat: unvisersal module also package individual archs * fix: add browseros-server binaries * fix: attach color for notify * fix: attachment for slack * fix: update chromium version to 142.0.7444.175 * feat: add new icons needed * fix: disable settings in menu * fix: uv add build-backend * minor: chromium version bump * clean-up: removed old files of extnesion and sidepanel * fix: product logo generate and assets.car and appicon.icns * feat: few chromium UI fixes * fix: update features.yaml * fix: features.yaml path in context * refactor: rename to get_patches_dir() * feat: show browserOS version in about page * fix: copy browseros_version on the build time and rename other to offset * bump offset * fix: update features.yaml * feat: load env from .env files too * fix: enable split view * clean-up: removed old prefs * fix: minor import issue * fix: linux flag update
106 lines
3.5 KiB
Python
Generated
106 lines
3.5 KiB
Python
Generated
#!/usr/bin/env python3
|
|
"""
|
|
Base module system for BrowserOS build pipeline
|
|
|
|
This module defines the base class for all build modules and the validation framework.
|
|
All build modules should inherit from BuildModule and implement validate() and execute().
|
|
"""
|
|
|
|
from typing import List
|
|
|
|
|
|
class ValidationError(Exception):
|
|
"""
|
|
Raised when module validation fails
|
|
|
|
This exception is raised by the validate() method when a module cannot execute
|
|
due to missing requirements, platform incompatibility, or invalid configuration.
|
|
The build pipeline stops immediately when ValidationError is raised.
|
|
"""
|
|
pass
|
|
|
|
|
|
class CommandModule:
|
|
"""
|
|
Base class for all build modules
|
|
|
|
Each module represents a discrete step in the build pipeline (e.g., clean, compile, sign).
|
|
Modules are self-contained and declare their requirements and outputs explicitly.
|
|
|
|
Class Attributes:
|
|
produces: List of artifact names this module creates (e.g., ["signed_app", "notarization_zip"])
|
|
requires: List of artifact names this module needs (e.g., ["built_app"])
|
|
description: Human-readable description for --list output
|
|
|
|
Methods:
|
|
validate(context): Check if module can run, raise ValidationError if not
|
|
execute(context): Execute the module's main task
|
|
|
|
Example:
|
|
class CleanModule(BuildModule):
|
|
produces = []
|
|
requires = []
|
|
description = "Clean build artifacts and reset git state"
|
|
|
|
def validate(self, context):
|
|
if not context.chromium_src.exists():
|
|
raise ValidationError(f"Chromium source not found: {context.chromium_src}")
|
|
|
|
def execute(self, context):
|
|
log_info("🧹 Cleaning build artifacts...")
|
|
# ... cleaning logic ...
|
|
log_success("Build artifacts cleaned")
|
|
"""
|
|
|
|
# Metadata as class attributes (override in subclasses)
|
|
produces: List[str] = []
|
|
requires: List[str] = []
|
|
description: str = "No description provided"
|
|
|
|
def validate(self, context) -> None:
|
|
"""
|
|
Validate that this module can run successfully
|
|
|
|
This method should check all preconditions:
|
|
- Platform requirements (e.g., macOS only)
|
|
- Required artifacts from previous modules
|
|
- Required environment variables
|
|
- Required files/directories exist
|
|
|
|
Args:
|
|
context: BuildContext object with all build state
|
|
|
|
Raises:
|
|
ValidationError: If any precondition is not met
|
|
|
|
Note:
|
|
This method is called before execute(). The pipeline stops
|
|
immediately if ValidationError is raised.
|
|
"""
|
|
raise NotImplementedError(
|
|
f"{self.__class__.__name__} must implement validate()"
|
|
)
|
|
|
|
def execute(self, context) -> None:
|
|
"""
|
|
Execute the module's main task
|
|
|
|
This method performs the actual work of the module. It should:
|
|
- Log its own progress using log_info(), log_success(), etc.
|
|
- Register any artifacts it produces using context.artifacts.add()
|
|
- Raise exceptions on failure (will stop the pipeline)
|
|
|
|
Args:
|
|
context: BuildContext object with all build state
|
|
|
|
Raises:
|
|
Exception: On any failure (stops the pipeline)
|
|
|
|
Note:
|
|
This method is only called after validate() succeeds.
|
|
Modules should be idempotent where possible.
|
|
"""
|
|
raise NotImplementedError(
|
|
f"{self.__class__.__name__} must implement execute()"
|
|
)
|