Skip to content

Instantly share code, notes, and snippets.

@ckerr
Created February 16, 2024 15:59

Revisions

  1. ckerr created this gist Feb 16, 2024.
    52 changes: 52 additions & 0 deletions electron-build.diff
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    diff --git a/scripts/patch.py b/scripts/patch.py
    index 62dd248b..e4b7da1f 100755
    --- a/scripts/patch.py
    +++ b/scripts/patch.py
    @@ -29,6 +29,10 @@ def parse_args():
    type=boolean_string, nargs='?',
    default=False, const=True,
    help="dry run")
    + parser.add_argument('--remove',
    + type=boolean_string, nargs='?',
    + default=True, const=True,
    + help="remove old files when exporting patches")

    parser.add_argument('-f', '--apply-ffmpeg-patches',
    type=boolean_string, nargs='?',
    @@ -144,7 +148,7 @@ def get_config_targets(config, patch_source_project_root=PROJECT_ROOT_DIR):
    return json.loads(config_data)


    -def export_patches(config, dry_run,
    +def export_patches(config, dry_run, remove_old_patches,
    patch_source_project_root=PROJECT_ROOT_DIR,
    patch_target_project_root=PROJECT_ROOT_DIR):
    for target in get_config_targets(
    @@ -164,6 +168,7 @@ def export_patches(config, dry_run,
    out_dir=out_dir,
    patch_range=None,
    dry_run=dry_run,
    + remove_old_patches=remove_old_patches,
    grep="Patch-Dir: {}".format(out_dir),
    ref="refs/{}/upstream-head".format(patch_dir))

    @@ -227,7 +232,7 @@ def get_target_repo_and_directory(repo_path, is_snapshot):
    # Let's exclude "src/" from a path,
    # e.g. "src/third_party/ffmpeg" -> "third_party/ffmpeg".
    directory, top_level_dir = exclude_top_level_dir(repo_path)
    - assert(top_level_dir == src_repo)
    + assert (top_level_dir == src_repo)

    return src_repo, directory

    @@ -250,7 +255,9 @@ def main():
    configs = get_configs_list(script_args.apply_ffmpeg_patches, is_snapshot)
    for config in configs:
    if script_args.export:
    - export_patches(config, dry_run=script_args.dry_run)
    + export_patches(config,
    + dry_run=script_args.dry_run,
    + remove_old_patches=script_args.remove),
    else:
    apply_patches(config, is_snapshot)

    28 changes: 28 additions & 0 deletions electron.diff
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    diff --git a/script/lib/git.py b/script/lib/git.py
    index 3153c6ad4..178d736df 100644
    --- a/script/lib/git.py
    +++ b/script/lib/git.py
    @@ -231,7 +231,8 @@ def remove_patch_location(patch):

    def export_patches(repo, out_dir,
    patch_range=None, ref=UPSTREAM_HEAD,
    - dry_run=False, grep=None):
    + dry_run=False, remove_old_patches=True,
    + grep=None):
    if not os.path.exists(repo):
    sys.stderr.write(
    "Skipping patches in {} because it does not exist.\n".format(repo)
    @@ -275,9 +276,10 @@ def export_patches(repo, out_dir,
    else:
    # Remove old patches so that deleted commits are correctly reflected in the
    # patch files (as a removed file)
    - for p in os.listdir(out_dir):
    - if p.endswith('.patch'):
    - os.remove(posixpath.join(out_dir, p))
    + if remove_old_patches:
    + for p in os.listdir(out_dir):
    + if p.endswith('.patch'):
    + os.remove(posixpath.join(out_dir, p))
    with io.open(
    posixpath.join(out_dir, '.patches'),
    'w',