Files
BrowserOS/packages/browseros/build/modules/setup/clean.py
Nikhil 12228a9392 feat: chromium 146 upgrade (#393)
* feat: update to 146, fix clean

* fix: update all 16 failed patches for Chromium 146.0.7680.31

- Update BASE_COMMIT to 4d3225104176d (Chromium 146)
- Shift BrowserOS command IDs to avoid upstream 40300-40302 conflict
- Fix settings BUILD.gn and menu patches for upstream removals
- Shift syncable prefs IDs to 100379-100380 after upstream additions
- Migrate theme patch from theme_service_factory.cc to theme_service.cc
  (RegisterProfilePrefs moved upstream)
- Fix toolbar_actions_model.cc for upstream API changes
- Fix toolbar_pref_names.cc for upstream base::ListValue usage
- Fix ui_features.cc/.h for removed kPopupBrowserUseNewLayout
- Fix api_sources.gni for new upstream entries
- Shift infobar delegate ID to 132
- Shift extension histogram values by +4 (1961-1985)
- Shift api_permission_id kBrowserOS to 265
- Update histogram enums.xml to match shifted values
- Delete chromium_install_modes.cc patch (file removed in 146)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: enable vertical tabs

* feat: default browseros theme

* chore: bump PATCH and OFFSET

* fix: update extensions-manifestv2 series patch for Chromium 146

Regenerated the patch from a clean diff against 146.0.7680.31 to fix
line number offsets and context mismatches in extensions_ui.cc.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: update vertical_tab_strip_state_controller patch for Chromium 146

Upstream refactored includes and renamed NotifyStateChanged to
NotifyModeChanged. Regenerated patch with correct context.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: update default theme to neutral gray (136,136,136)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: rename base::Value::Dict/List to base::DictValue/ListValue for Chromium 146

Chromium 146 moved base::Value::Dict and base::Value::List to top-level
classes base::DictValue and base::ListValue. Updated all 23 patch files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: regenerate browseros_prefs.cc patch (fix corrupt trailing newline)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: update patches for Chromium 146 build API changes

- browseros_action_utils.h: remove nonexistent base/containers/contains.h include
- chrome_content_browser_client.cc: PrivateNetworkRequestPolicyOverride → LocalNetworkAccessRequestPolicyOverride
- extension_updater.cc: InstallStageTracker::Get → InstallStageTrackerFactory::GetForBrowserContext
- toolbar_actions_model.cc: base::Contains → std::ranges::contains

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 18:31:20 -08:00

67 lines
2.2 KiB
Python
Generated

#!/usr/bin/env python3
"""Clean module for BrowserOS build system"""
from ...common.module import CommandModule, ValidationError
from ...common.context import Context
from ...common.utils import run_command, log_info, log_success, safe_rmtree
class CleanModule(CommandModule):
produces = []
requires = []
description = "Clean build artifacts and reset git state"
def validate(self, ctx: Context) -> None:
if not ctx.chromium_src.exists():
raise ValidationError(f"Chromium source not found: {ctx.chromium_src}")
def execute(self, ctx: Context) -> None:
log_info("🧹 Cleaning build artifacts...")
out_path = ctx.chromium_src / ctx.out_dir
if out_path.exists():
safe_rmtree(out_path)
log_success("Cleaned build directory")
log_info("\n🔀 Resetting git branch and removing tracked files...")
self._git_reset(ctx)
log_info("\n🧹 Cleaning Sparkle build artifacts...")
self._clean_sparkle(ctx)
def _clean_sparkle(self, ctx: Context) -> None:
sparkle_dir = ctx.get_sparkle_dir()
if sparkle_dir.exists():
safe_rmtree(sparkle_dir)
log_success("Cleaned Sparkle build directory")
def _git_reset(self, ctx: Context) -> None:
run_command(["git", "reset", "--hard", "HEAD"], cwd=ctx.chromium_src)
# Reset all dirty submodules so gclient sync doesn't choke
log_info("🧹 Resetting dirty submodules...")
run_command(
["git", "submodule", "foreach", "--recursive",
"git checkout -- . && git clean -fd"],
cwd=ctx.chromium_src,
)
log_info("🧹 Running git clean with exclusions...")
run_command(
[
"git",
"clean",
"-fdx",
"chrome/",
"components/",
"third_party/",
"--exclude=build_tools/",
"--exclude=uc_staging/",
"--exclude=buildtools/",
"--exclude=tools/",
"--exclude=build/",
],
cwd=ctx.chromium_src,
)
log_success("Git reset and clean complete")