Add Chromium-only Blender WebEngine parity work
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-FileCopyrightText: 2022 Blender Authors
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
# macOS utility to remove all `rpaths` and add a new one.
|
||||
|
||||
__all__ = (
|
||||
"main",
|
||||
)
|
||||
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
# Strip version numbers from dependencies macOS notarizatiom fails
|
||||
# with version symlinks.
|
||||
def strip_lib_version(name):
|
||||
name = re.sub(r'(\.[0-9]+)+.dylib', '.dylib', name)
|
||||
name = re.sub(r'(\.[0-9]+)+.so', '.so', name)
|
||||
name = re.sub(r'(\.[0-9]+)+.cpython', '.cpython', name)
|
||||
return name
|
||||
|
||||
|
||||
# Patch cmake config to match rename
|
||||
def update_cmake_config(oldfile, newfile):
|
||||
for cmakefile in oldfile.parent.glob("cmake/*/*.cmake"):
|
||||
text = cmakefile.read_text()
|
||||
text = text.replace(oldfile.name, newfile.name)
|
||||
cmakefile.write_text(text)
|
||||
|
||||
|
||||
def main():
|
||||
rpath = sys.argv[1]
|
||||
file = sys.argv[2]
|
||||
new_file = strip_lib_version(file)
|
||||
|
||||
file = pathlib.Path(file)
|
||||
new_file = pathlib.Path(new_file)
|
||||
|
||||
# Update CMake configuration files.
|
||||
update_cmake_config(file, new_file)
|
||||
|
||||
# Remove if symbolic-link.
|
||||
if file.is_symlink():
|
||||
os.remove(file)
|
||||
sys.exit(0)
|
||||
|
||||
# Find existing RPATHS and delete them one by one.
|
||||
p = subprocess.run(['otool', '-l', file], capture_output=True)
|
||||
tokens = p.stdout.split()
|
||||
|
||||
for i, token in enumerate(tokens):
|
||||
if token == b'LC_RPATH':
|
||||
old_rpath = tokens[i + 4]
|
||||
subprocess.run(['install_name_tool', '-delete_rpath', old_rpath, file])
|
||||
|
||||
subprocess.run(['install_name_tool', '-add_rpath', rpath, file])
|
||||
|
||||
# Strip version from dependencies.
|
||||
p = subprocess.run(['otool', '-L', file], capture_output=True)
|
||||
tokens = p.stdout.split()
|
||||
for i, token in enumerate(tokens):
|
||||
token = token.decode("utf-8")
|
||||
if token.startswith("@rpath"):
|
||||
new_token = strip_lib_version(token)
|
||||
subprocess.run(['install_name_tool', '-change', token, new_token, file])
|
||||
|
||||
# Strip version from library itself.
|
||||
new_id = '@rpath/' + new_file.name
|
||||
os.rename(file, new_file)
|
||||
subprocess.run(['install_name_tool', '-id', new_id, new_file])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
68
blender-5.2.0/build_files/build_environment/utils/strip_libraries.py
Executable file
68
blender-5.2.0/build_files/build_environment/utils/strip_libraries.py
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-FileCopyrightText: 2025 Blender Authors
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
"""
|
||||
Script which strips all libraries in the given library directory.
|
||||
This is so we don't keep any debug data or symbols that contains
|
||||
random hashes that are not reproducible between builds.
|
||||
|
||||
This will strip both static and shared libraries.
|
||||
|
||||
Usage:
|
||||
strip_libraries.py <path/to/library/directory>
|
||||
"""
|
||||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def print_strip_lib(strip_lib: Path, prev_print_len: int) -> int:
|
||||
print_str = f"Stripping: {strip_lib}"
|
||||
if prev_print_len > 0:
|
||||
print(f"\r{' ' * prev_print_len}\r", end="")
|
||||
print(print_str, end="", flush=True)
|
||||
return len(print_str)
|
||||
|
||||
|
||||
def strip_libs(strip_dir: Path) -> None:
|
||||
print(f"Stripping libraries in: {strip_dir}")
|
||||
prev_print_len = 0
|
||||
for shared_lib in strip_dir.rglob("*.so*"):
|
||||
if shared_lib.suffix == ".py":
|
||||
# Work around badly named `sycl` scripts.
|
||||
continue
|
||||
|
||||
if shared_lib.is_symlink():
|
||||
# Don't strip symbolic-links as we don't want to strip the same library multiple times.
|
||||
continue
|
||||
|
||||
prev_print_len = print_strip_lib(shared_lib, prev_print_len)
|
||||
subprocess.check_call(["strip", "-s", "--enable-deterministic-archives", shared_lib])
|
||||
for static_lib in strip_dir.rglob("*.a"):
|
||||
if static_lib.is_symlink():
|
||||
# Don't strip symbolic-links as we don't want to strip the same library multiple times.
|
||||
continue
|
||||
|
||||
prev_print_len = print_strip_lib(static_lib, prev_print_len)
|
||||
subprocess.check_call(["objcopy", "--enable-deterministic-archives", static_lib])
|
||||
|
||||
print("\nDone stripping libraries!")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(
|
||||
description=__doc__,
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
)
|
||||
parser.add_argument("directory", type=Path, help="Path to the library directory to strip")
|
||||
args = parser.parse_args()
|
||||
|
||||
if sys.platform == "linux":
|
||||
strip_libs(args.directory)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user