More build system rework and moving stuff to patches

This commit is contained in:
maelstrom 2024-08-17 21:25:06 +02:00
parent f2ada0e2fe
commit 8a7b95beee
12 changed files with 47 additions and 35279 deletions

View file

@ -6,8 +6,6 @@ import os
import re
from math import floor
def parse_string(token: Token):
if token.type == 'STRING':
string = token.value[1:-1]
@ -39,22 +37,6 @@ def parse_location(location: Token):
raise RuntimeError("Cannot parse location")
def resolve_position(location, src: str):
if location["type"] == "char":
return location["index"]
elif location["type"] == "lncol":
j = 0
for i, x in enumerate(src.split('\n')):
if (i+1) == location["line"]:
if location["column"] > len(x):
print(f"Cannot insert at line {location['line']} column {location['column']}. The line is not that long.")
exit(-1)
return j + location["column"]
j += len(x) + 1
print(f"Cannot insert at line {location['line']}. The file is not long enough.")
exit(-1)
def parse_patch(branch: Branch[Token], mtime: float):
# First instruction is always file declaration
target_file = parse_string(branch.children[0].children[0]) # pyright: ignore[reportUnknownMemberType, reportArgumentType]

View file

@ -1,14 +1,28 @@
from .polly import parse_patch_file
from .polly import resolve_position
from .parser import parse_patch_file
from pathlib import Path
from ..task.util import *
from task.util import *
def resolve_position(location, src: str):
if location["type"] == "char":
return location["index"]
elif location["type"] == "lncol":
j = 0
for i, x in enumerate(src.split('\n')):
if (i+1) == location["line"]:
if location["column"] > len(x):
print(f"Cannot insert at line {location['line']} column {location['column']}. The line is not that long.")
exit(-1)
return j + location["column"]
j += len(x) + 1
print(f"Cannot insert at line {location['line']}. The file is not long enough.")
exit(-1)
def read_insertion(action, src):
position = resolve_position(action["at"], src)
return {"content": action["content"], "pos": position}
def process_patch_file(patch_file: str, check_date: bool = True):
patches = parse_patch_file(patch_file)
@ -45,4 +59,13 @@ def process_patch_file(patch_file: str, check_date: bool = True):
# Write the changed output
with open(target_dest, 'w') as f:
f.write(src)
f.write(src)
def process_all_patches(dir: Path | str, check_date: bool = True):
dir = Path(dir)
for (cd, _, files) in dir.walk():
for f in files:
if f.endswith(".patch"):
print("Processing patch {}".format((cd / f).relative_to(dir)))
process_patch_file(str(cd / f), check_date=check_date)

View file

@ -3,6 +3,8 @@ from . import fileutil
import shutil
from polly.patcher import process_all_patches
# Task dependencies
from .extract import extract
@ -23,4 +25,5 @@ def patch_resources():
else:
print("Skipped copying resources from src/resources")
# Patch other resources
process_all_patches(SRC_PATCHES_DIR, check_date=not first_time)

View file

@ -7,4 +7,5 @@ EXTRACTED_DIR = BUILD_DIR / "extracted"
PATCHED_RSC_DIR = BUILD_DIR / "patched_resources"
SRC_DIR = Path("src")
SRC_RESOURCES_DIR = SRC_DIR / "resources"
SRC_RESOURCES_DIR = SRC_DIR / "resources"
SRC_PATCHES_DIR = SRC_DIR / "patches"

File diff suppressed because it is too large Load diff

6
src/patches/yellow.patch Normal file
View file

@ -0,0 +1,6 @@
file 'res/layout/color_options_toolbar.xml'
insert ln8 << @end
<androidx.appcompat.widget.AppCompatImageButton android:id="@id/text_color_yellow" android:background="?selectableItemBackgroundBorderless" android:layout_width="48.0dip" android:layout_height="48.0dip" android:layout_marginLeft="2.0dip" android:layout_marginRight="2.0dip" android:layout_weight="0.5" app:srcCompat="@drawable/oval_yellow" />
@end

View file

@ -0,0 +1,6 @@
file 'res/layout/fragment_blog_settings.xml'
insert ln10 << @end
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/ykit_settings" tumblr:listItemDetail="Change settings for YKit" tumblr:listItemTitle="YKit Settings" style="@style/DetailedListItem" />
@end

View file

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<merge android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="48.0dip"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout android:gravity="center" android:orientation="horizontal" android:id="@id/color_editing_controls" android:background="?selectableItemBackgroundBorderless" android:layout_width="fill_parent" android:layout_height="48.0dip">
<androidx.appcompat.widget.AppCompatImageButton android:id="@id/text_color_default" android:background="?selectableItemBackgroundBorderless" android:layout_width="48.0dip" android:layout_height="48.0dip" android:layout_marginLeft="2.0dip" android:layout_marginRight="2.0dip" android:layout_weight="0.5" app:srcCompat="@drawable/oval_main_text_color" />
<androidx.appcompat.widget.AppCompatImageButton android:id="@id/text_color_red" android:background="?selectableItemBackgroundBorderless" android:layout_width="48.0dip" android:layout_height="48.0dip" android:layout_marginLeft="2.0dip" android:layout_marginRight="2.0dip" android:layout_weight="0.5" app:srcCompat="@drawable/oval_red" />
<androidx.appcompat.widget.AppCompatImageButton android:id="@id/text_color_orange" android:background="?selectableItemBackgroundBorderless" android:layout_width="48.0dip" android:layout_height="48.0dip" android:layout_marginLeft="2.0dip" android:layout_marginRight="2.0dip" android:layout_weight="0.5" app:srcCompat="@drawable/oval_orange" />
<androidx.appcompat.widget.AppCompatImageButton android:id="@id/text_color_yellow" android:background="?selectableItemBackgroundBorderless" android:layout_width="48.0dip" android:layout_height="48.0dip" android:layout_marginLeft="2.0dip" android:layout_marginRight="2.0dip" android:layout_weight="0.5" app:srcCompat="@drawable/oval_yellow" />
<androidx.appcompat.widget.AppCompatImageButton android:id="@id/text_color_green" android:background="?selectableItemBackgroundBorderless" android:layout_width="48.0dip" android:layout_height="48.0dip" android:layout_marginLeft="2.0dip" android:layout_marginRight="2.0dip" android:layout_weight="0.5" app:srcCompat="@drawable/oval_green" />
<androidx.appcompat.widget.AppCompatImageButton android:id="@id/text_color_blue" android:background="?selectableItemBackgroundBorderless" android:layout_width="48.0dip" android:layout_height="48.0dip" android:layout_marginLeft="2.0dip" android:layout_marginRight="2.0dip" android:layout_weight="0.5" app:srcCompat="@drawable/oval_blue" />
<androidx.appcompat.widget.AppCompatImageButton android:id="@id/text_color_purple" android:background="?selectableItemBackgroundBorderless" android:layout_width="48.0dip" android:layout_height="48.0dip" android:layout_marginLeft="2.0dip" android:layout_marginRight="2.0dip" android:layout_weight="0.5" app:srcCompat="@drawable/oval_purple" />
<androidx.appcompat.widget.AppCompatImageButton android:id="@id/text_color_pink" android:background="?selectableItemBackgroundBorderless" android:layout_width="48.0dip" android:layout_height="48.0dip" android:layout_marginLeft="2.0dip" android:layout_marginRight="2.0dip" android:layout_weight="0.5" app:srcCompat="@drawable/oval_pink" />
</LinearLayout>
</merge>

View file

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<com.tumblr.ui.widget.fab.ObservableScrollView android:id="@id/blog_settings_scroll_view" android:background="?themeHighlightedContentBackgroundColor" android:paddingTop="@dimen/action_bar_base_height" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tumblr="http://schemas.android.com/apk/res-auto">
<LinearLayout android:background="@null" style="@style/BlogSettingsContainer">
<LinearLayout android:id="@id/user_blog_default_options" style="@style/BlogSettingsUserBlogOptionsContainer">
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/account_settings" tumblr:listItemDetail="@string/global_settings_subtitle" tumblr:listItemTitle="@string/account_settings" style="@style/DetailedListItem" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/blog_ad_free_management" android:visibility="gone" tumblr:listItemDetail="@string/tumblr_premium_subtitle" tumblr:listItemTitle="@string/tumblr_premium" style="@style/DetailedListItem" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/blog_payment_and_purchases" tumblr:listItemDetail="@string/payment_and_purchases_desc" tumblr:listItemTitle="@string/payment_and_purchases" style="@style/DetailedListItem" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/blog_subscriptions_and_purchases" tumblr:listItemDetail="@string/subscriptions_and_purchases_desc" tumblr:listItemTitle="@string/subscriptions_and_purchases" style="@style/DetailedListItem" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/ykit_settings" tumblr:listItemDetail="Change settings for YKit" tumblr:listItemTitle="YKit Settings" style="@style/DetailedListItem" />
</LinearLayout>
<LinearLayout style="@style/BlogSettingsOptionsSection">
<TextView android:id="@id/blog_settings_header" android:background="?themeHighlightedContentBackgroundColor" style="@style/SettingsSectionHeader" />
<com.tumblr.ui.widget.UserBlogOptionsLayout android:id="@id/user_blog_options_container" style="@style/BlogSettingsUserBlogOptionsContainer">
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/blog_change_username_row" android:visibility="gone" tumblr:listItemTitle="@string/change_name_title" style="@style/BlogSettingsListItem" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/blog_pages_row" android:visibility="gone" tumblr:listItemDetail="@string/pages_description" tumblr:listItemTitle="@string/pages" style="@style/DetailedListItem.White" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/blog_featured_tags" android:visibility="gone" tumblr:listItemTitle="@string/featured_tags" style="@style/BlogSettingsListItem" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/blog_followers_row" tumblr:listItemTitle="@string/followers_title" style="@style/BlogSettingsListItem" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/blog_drafts_row" tumblr:listItemTitle="@string/drafts_title" style="@style/BlogSettingsListItem" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/blog_queue_row" tumblr:listItemTitle="@string/queue_title" style="@style/BlogSettingsListItem" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/blog_inbox_row" tumblr:listItemDetail="@string/inbox_detail_new" tumblr:listItemTitle="@string/inbox_title" style="@style/DetailedListItem" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/blog_community_label_row" android:visibility="gone" tumblr:listItemTitle="@string/blog_community_label_settings" style="@style/BlogSettingsListItem" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/blog_posts_review_row" android:visibility="gone" tumblr:listItemTitle="@string/posts_review_setting_label" style="@style/BlogSettingsListItem" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/blaze_info_page" android:visibility="gone" tumblr:listItemTitle="@string/tumblr_blaze" style="@style/BlogSettingsListItem" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/manage_gifts" android:visibility="gone" tumblr:listItemTitle="@string/gifts" style="@style/BlogSettingsListItem" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/blog_payouts" android:visibility="gone" tumblr:listItemTitle="@string/payouts_settings" style="@style/BlogSettingsListItem" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/blog_privacy_row" tumblr:listItemTitle="@string/setting_label_blog_privacy_title" style="@style/BlogSettingsListItem" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/blog_delete_row" tumblr:listItemTitle="@string/delete_blog" style="@style/BlogSettingsListItem" />
<com.tumblr.ui.widget.TMToggleWithWarningRow android:id="@id/blog_allow_tipping" android:paddingStart="6.0dip" tumblr:rowText="@string/allow_tipping" tumblr:toggleDefault="false" style="@style/SettingsToggleSettingRow" />
<com.tumblr.ui.widget.TMToggleWithWarningRow android:id="@id/blog_allow_blaze_by_others" android:paddingStart="6.0dip" tumblr:rowText="@string/allow_blaze_by_others_v2" tumblr:toggleDefault="false" style="@style/SettingsToggleSettingRow" />
<com.tumblr.ui.widget.TMToggleRow android:id="@id/blog_show_tip_button" android:paddingStart="6.0dip" tumblr:rowText="@string/tipping_tip_blog" tumblr:toggleDefault="false" style="@style/SettingsToggleSettingRow" />
<com.tumblr.ui.widget.TMToggleRow android:id="@id/blog_post_tipping_default" android:paddingStart="6.0dip" tumblr:rowText="@string/tipping_post_default" tumblr:toggleDefault="false" style="@style/SettingsToggleSettingRow" />
<com.tumblr.ui.widget.TMToggleRow android:id="@id/blog_allow_submissions" android:paddingStart="6.0dip" tumblr:rowText="@string/blog_allow_submissions" tumblr:toggleDefault="true" style="@style/SettingsToggleSettingRow" />
<com.tumblr.ui.widget.TMToggleRow android:id="@id/blog_allow_asks" android:paddingStart="6.0dip" tumblr:rowText="@string/blog_allow_asks" tumblr:toggleDefault="true" style="@style/SettingsToggleSettingRow" />
<com.tumblr.ui.widget.TMToggleRow android:id="@id/blog_ask_allow_anonymous" android:paddingStart="6.0dip" tumblr:rowText="@string/blog_ask_allow_anonymous" tumblr:toggleDefault="true" style="@style/SettingsToggleSettingRow" />
<com.tumblr.ui.widget.TMToggleRow android:id="@id/blog_ask_allow_media" android:paddingStart="6.0dip" tumblr:rowText="@string/blog_ask_allow_with_media" tumblr:toggleDefault="true" style="@style/SettingsToggleSettingRow" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/blog_ask_page_title" android:minHeight="0.0dip" tumblr:listItemTitle="@string/blog_ask_page_title" style="@style/BlogSettingsListItem" />
<com.tumblr.ui.widget.TMToggleRow android:id="@id/blog_show_top_posts" android:paddingStart="6.0dip" tumblr:rowText="@string/blog_show_top_posts" tumblr:toggleDefault="true" style="@style/SettingsToggleSettingRow" />
<com.tumblr.ui.widget.TMBlogSettingsTextRow android:id="@id/blog_blocked_tumblrs_row" tumblr:listItemTitle="@string/blocked_tumblrs_title" style="@style/BlogSettingsListItem" />
</com.tumblr.ui.widget.UserBlogOptionsLayout>
</LinearLayout>
</LinearLayout>
</com.tumblr.ui.widget.fab.ObservableScrollView>

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,3 @@
from buildtool.patcher.filepatcher import process_patch_file
from buildtool.polly.patcher import process_patch_file
process_patch_file('src/patches/public.patch', check_date=True)