# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. import argparse import datetime import os import shutil import stat import subprocess import sys import tarfile
# Files in this list are excluded. def get_excluded_files(): return [ ".clang-format", ".git-blame-ignore-revs", ".gitignore", "CODE_OF_CONDUCT.md", "ENG_REVIEW_OWNERS", "PRESUBMIT.py", "README.chromium", "WATCHLISTS", "codereview.settings", "license_template.txt", "native-api.md", "presubmit_test.py", "presubmit_test_mocks.py", "pylintrc",
]
# Directories in this list are excluded. Directories are handled # separately from files so that script 'filter_git_changes.py' can use # different regex handling for directory paths. def get_excluded_dirs(): return [ # Only the camera code under sdk/android/api/org/webrtc is used, so # we remove sdk/android and add back the specific files we want. "sdk/android",
]
def fetch(target, url):
print(f"Fetching commit from {url}")
req = requests.get(url) if req.status_code == 200: with open(target + ".tar.gz", "wb") as f:
f.write(req.content) else:
print(
f"Hit status code {req.status_code} fetching commit. Aborting.",
file=sys.stderr,
)
sys.exit(1) with open(os.path.join(LIBWEBRTC_DIR, "README.mozilla.last-vendor"), "w") as f: # write the the command line used
f.write(f"# ./mach python {' '.join(sys.argv[0:])}\n")
f.write(
f"{target} updated from commit {url} on {datetime.datetime.now(dateutil.tz.tzutc()).isoformat()}.\n"
)
with open(os.path.join(LIBWEBRTC_DIR, "README.mozilla.last-vendor"), "w") as f: # write the the command line used
f.write(f"# ./mach python {' '.join(sys.argv[0:])}\n")
f.write(
f"{target} updated from {path} commit {commit} on {datetime.datetime.now(dateutil.tz.tzutc()).isoformat()}.\n"
)
shutil.move(os.path.join(path, target_archive), target_archive)
if target == "libwebrtc": # use the top level directories from the tarfile and # delete those directories in LIBWEBRTC_DIR
libwebrtc_used_in_firefox = os.listdir(target_path) for path in libwebrtc_used_in_firefox: try:
shutil.rmtree(os.path.join(LIBWEBRTC_DIR, path)) except FileNotFoundError: pass except NotADirectoryError: pass
# adjust target_path if GitHub packaging is involved ifnot os.path.exists(os.path.join(target_path, libwebrtc_used_in_firefox[0])): # GitHub packs everything inside a separate directory
target_path = os.path.join(target_path, os.listdir(target_path)[0])
# remove any entries found in unused_libwebrtc_in_firefox from the # tarfile for path in unused_libwebrtc_in_firefox: if os.path.isdir(os.path.join(target_path, path)):
shutil.rmtree(os.path.join(target_path, path)) else:
os.remove(os.path.join(target_path, path))
# move remaining top level entries from the tarfile to LIBWEBRTC_DIR for path in os.listdir(target_path):
shutil.move(
os.path.join(target_path, path), os.path.join(LIBWEBRTC_DIR, path)
)
# An easy, but inefficient way to accomplish including specific # files from directories otherwise removed. Re-extract the tar # file, and only copy over the exact files requested.
shutil.rmtree(target_path) with tarfile.open(target_archive) as t:
safe_extract(t, path=target_path)
# Copy the force included files. Note: the instinctual action # is to do this prior to removing the excluded paths to avoid # reextracting the tar file. However, this causes errors due to # pre-existing paths when other directories are moved out of the # tar file in the "move all the top level entries from the # tarfile" phase above. for path in forced_used_in_firefox:
dest_path = os.path.join(LIBWEBRTC_DIR, path)
dir_path = os.path.dirname(dest_path) ifnot os.path.exists(dir_path):
os.makedirs(dir_path)
shutil.move(os.path.join(target_path, path), dest_path)
elif target == "build": # adjust target_path if GitHub packaging is involved ifnot os.path.exists(os.path.join(target_path, "linux")): # GitHub packs everything inside a separate directory
target_path = os.path.join(target_path, os.listdir(target_path)[0])
build_used_in_firefox = os.listdir(target_path) for path in build_used_in_firefox: try:
shutil.rmtree(os.path.join(LIBWEBRTC_DIR, path)) except FileNotFoundError: pass except NotADirectoryError: pass
for path in os.listdir(target_path):
shutil.move(
os.path.join(target_path, path),
os.path.join(LIBWEBRTC_DIR, path),
)
elif target == "third_party": # Only delete the THIRDPARTY_USED_IN_FIREFOX paths from # LIBWEBRTC_DIR/third_party to avoid deleting directories that # we use to trampoline to libraries already in mozilla's tree. for path in THIRDPARTY_USED_IN_FIREFOX: try:
shutil.rmtree(os.path.join(LIBWEBRTC_DIR, path)) except FileNotFoundError: pass except NotADirectoryError: pass
# adjust target_path if GitHub packaging is involved ifnot os.path.exists(os.path.join(target_path, THIRDPARTY_USED_IN_FIREFOX[0])): # GitHub packs everything inside a separate directory
target_path = os.path.join(target_path, os.listdir(target_path)[0])
for path in THIRDPARTY_USED_IN_FIREFOX:
shutil.move(
os.path.join(target_path, path),
os.path.join(LIBWEBRTC_DIR, path),
)
elif target == "abseil-cpp": # adjust target_path if GitHub packaging is involved ifnot os.path.exists(os.path.join(target_path, "abseil-cpp")): # GitHub packs everything inside a separate directory
target_path = os.path.join(target_path, os.listdir(target_path)[0])
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.