webrtc/tools_webrtc/libs/generate_licenses.py
Mirko Bonadei 7e225cf6ab Roll chromium_revision 4231e93dbb..b86bc4feb4 (850549:852112)
Change log: 4231e93dbb..b86bc4feb4
Full diff: 4231e93dbb..b86bc4feb4

Changed dependencies
* src/base: 459d6e0ed6..632b766e09
* src/build: 923bed7ac7..44961f39c0
* src/ios: fe5fb848f5..4a8f8b624f
* src/testing: 967a8819da..dfd112748a
* src/third_party: 381d9c2c68..b80167f37a
* src/third_party/android_deps/libs/com_google_android_gms_play_services_base: version:17.1.0-cr0..version:17.5.0-cr0
* src/third_party/android_deps/libs/com_google_android_gms_play_services_basement: version:17.1.0-cr0..version:17.5.0-cr0
* src/third_party/android_deps/libs/com_google_android_gms_play_services_fido: version:18.1.0-cr0..version:19.0.0-beta-cr0
* src/third_party/android_deps/libs/com_google_android_gms_play_services_tasks: version:17.0.0-cr0..version:17.2.0-cr0
* src/third_party/androidx: zGdAyNdySwhTXOWTtAushFRKlDwCWGcYSWiaS2R5m8YC..W-1EHWPYZ8HdH_e2dRy2kb3kD-vOHJ1996OkW7qs9LIC
* src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/5c5a2976d5..cf4c59a332
* src/third_party/depot_tools: 680a6c37a0..79f916afab
* src/third_party/freetype/src: fd7f92b6f0..947e475283
* src/third_party/icu: 70dd9a65bf..12825ed8aa
* src/third_party/libaom/source/libaom: https://aomedia.googlesource.com/aom.git/+log/61c6fda0fd..648c6507f1
* src/third_party/perfetto: 7cb370fb0a..b05d9d92a0
* src/third_party/usrsctp/usrsctplib: 37a9dc3e18..a6647318b5
* src/tools: e1bc2e94ff..916b66ee11
Removed dependencies
* src/third_party/android_deps/libs/androidx_test_espresso_espresso_contrib
* src/third_party/android_deps/libs/androidx_test_runner
* src/third_party/android_deps/libs/androidx_print_print
* src/third_party/android_deps/libs/androidx_slice_slice_core
* src/third_party/android_deps/libs/androidx_test_ext_junit
* src/third_party/android_deps/libs/androidx_cardview_cardview
* src/third_party/android_deps/libs/androidx_test_monitor
* src/third_party/android_deps/libs/androidx_exifinterface_exifinterface
* src/third_party/android_deps/libs/androidx_legacy_legacy_support_core_ui
* src/third_party/android_deps/libs/androidx_media_media
* src/third_party/android_deps/libs/androidx_test_core
* src/third_party/android_deps/libs/androidx_customview_customview
* src/third_party/android_deps/libs/androidx_vectordrawable_vectordrawable
* src/third_party/android_deps/libs/androidx_test_espresso_espresso_idling_resource
* src/third_party/android_deps/libs/androidx_core_core
* src/third_party/android_deps/libs/androidx_annotation_annotation
* src/third_party/android_deps/libs/androidx_collection_collection
* src/third_party/android_deps/libs/androidx_lifecycle_lifecycle_livedata
* src/third_party/android_deps/libs/androidx_asynclayoutinflater_asynclayoutinflater
* src/third_party/android_deps/libs/androidx_test_espresso_espresso_web
* src/third_party/android_deps/libs/androidx_viewpager_viewpager
* src/third_party/android_deps/libs/androidx_vectordrawable_vectordrawable_animated
* src/third_party/android_deps/libs/androidx_multidex_multidex
* src/third_party/android_deps/libs/androidx_arch_core_core_common
* src/third_party/android_deps/libs/androidx_activity_activity
* src/third_party/android_deps/libs/androidx_lifecycle_lifecycle_viewmodel_savedstate
* src/third_party/android_deps/libs/androidx_gridlayout_gridlayout
* src/third_party/android_deps/libs/androidx_test_rules
* src/third_party/android_deps/libs/androidx_concurrent_concurrent_futures
* src/third_party/android_deps/libs/androidx_lifecycle_lifecycle_common_java8
* src/third_party/android_deps/libs/androidx_test_uiautomator_uiautomator
* src/third_party/android_deps/libs/androidx_transition_transition
* src/third_party/android_deps/libs/androidx_fragment_fragment
* src/third_party/android_deps/libs/androidx_slice_slice_builders
* src/third_party/android_deps/libs/androidx_localbroadcastmanager_localbroadcastmanager
* src/third_party/android_deps/libs/androidx_cursoradapter_cursoradapter
* src/third_party/android_deps/libs/androidx_core_core_animation
* src/third_party/android_deps/libs/androidx_annotation_annotation_experimental
* src/third_party/android_deps/libs/androidx_loader_loader
* src/third_party/android_deps/libs/androidx_appcompat_appcompat_resources
* src/third_party/android_deps/libs/androidx_lifecycle_lifecycle_common
* src/third_party/android_deps/libs/androidx_palette_palette
* src/third_party/android_deps/libs/androidx_lifecycle_lifecycle_viewmodel
* src/third_party/android_deps/libs/androidx_appcompat_appcompat
* src/third_party/android_deps/libs/androidx_remotecallback_remotecallback
* src/third_party/android_deps/libs/androidx_slidingpanelayout_slidingpanelayout
* src/third_party/android_deps/libs/androidx_arch_core_core_runtime
* src/third_party/android_deps/libs/androidx_swiperefreshlayout_swiperefreshlayout
* src/third_party/android_deps/libs/androidx_legacy_legacy_support_v4
* src/third_party/android_deps/libs/androidx_versionedparcelable_versionedparcelable
* src/third_party/android_deps/libs/androidx_viewpager2_viewpager2
* src/third_party/android_deps/libs/androidx_legacy_legacy_support_core_utils
* src/third_party/android_deps/libs/androidx_test_espresso_espresso_intents
* src/third_party/android_deps/libs/androidx_recyclerview_recyclerview
* src/third_party/android_deps/libs/androidx_savedstate_savedstate
* src/third_party/android_deps/libs/androidx_test_espresso_espresso_core
* src/third_party/android_deps/libs/androidx_leanback_leanback
* src/third_party/android_deps/libs/androidx_tracing_tracing
* src/third_party/android_deps/libs/androidx_interpolator_interpolator
* src/third_party/android_deps/libs/androidx_coordinatorlayout_coordinatorlayout
* src/third_party/android_deps/libs/androidx_documentfile_documentfile
* src/third_party/android_deps/libs/androidx_leanback_leanback_preference
* src/third_party/android_deps/libs/androidx_drawerlayout_drawerlayout
* src/third_party/android_deps/libs/androidx_tvprovider_tvprovider
* src/third_party/android_deps/libs/androidx_lifecycle_lifecycle_runtime
* src/third_party/android_deps/libs/androidx_mediarouter_mediarouter
* src/third_party/android_deps/libs/androidx_webkit_webkit
* src/third_party/android_deps/libs/androidx_lifecycle_lifecycle_livedata_core
* src/third_party/android_deps/libs/androidx_preference_preference
DEPS diff: 4231e93dbb..b86bc4feb4/DEPS

Clang version changed llvmorg-12-init-17251-g6de48655:llvmorg-13-init-794-g83e2710e
Details: 4231e93dbb..b86bc4feb4/tools/clang/scripts/update.py

TBR=chromium-webrtc-autoroll@webrtc-ci.iam.gserviceaccount.com,
BUG=None

Change-Id: I7e9dd36721b938e5980d04df62c46758270ffa04
No-Presubmit: True
No-Try: True
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/206449
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Autoroller <chromium-webrtc-autoroll@webrtc-ci.iam.gserviceaccount.com>
Cr-Commit-Position: refs/heads/master@{#33200}
2021-02-09 10:34:08 +00:00

269 lines
10 KiB
Python
Executable file

#!/usr/bin/env python
# Copyright 2016 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
"""Generates license markdown for a prebuilt version of WebRTC.
Licenses are taken from dependent libraries which are determined by
GN desc command `gn desc` on all targets specified via `--target` argument.
One can see all dependencies by invoking this command:
$ gn.py desc --all --format=json <out_directory> <target> | python -m json.tool
(see "deps" subarray)
Libraries are mapped to licenses via LIB_TO_LICENSES_DICT dictionary.
"""
import sys
import argparse
import cgi
import json
import logging
import os
import re
import subprocess
# Third_party library to licences mapping. Keys are names of the libraries
# (right after the `third_party/` prefix)
LIB_TO_LICENSES_DICT = {
'abseil-cpp': ['third_party/abseil-cpp/LICENSE'],
'android_ndk': ['third_party/android_ndk/NOTICE'],
'android_sdk': ['third_party/android_sdk/LICENSE'],
'auto': [
'third_party/android_deps/libs/'
'com_google_auto_service_auto_service/LICENSE'
],
'bazel': ['third_party/bazel/LICENSE'],
'boringssl': ['third_party/boringssl/src/LICENSE'],
'errorprone': [
'third_party/android_deps/libs/'
'com_google_errorprone_error_prone_core/LICENSE'
],
'fiat': ['third_party/boringssl/src/third_party/fiat/LICENSE'],
'guava': ['third_party/android_deps/libs/com_google_guava_guava/LICENSE'],
'ijar': ['third_party/ijar/LICENSE'],
'jsoncpp': ['third_party/jsoncpp/LICENSE'],
'libaom': ['third_party/libaom/source/libaom/LICENSE'],
'libc++': ['buildtools/third_party/libc++/trunk/LICENSE.TXT'],
'libc++abi': ['buildtools/third_party/libc++abi/trunk/LICENSE.TXT'],
'libevent': ['base/third_party/libevent/LICENSE'],
'libjpeg_turbo': ['third_party/libjpeg_turbo/LICENSE.md'],
'libsrtp': ['third_party/libsrtp/LICENSE'],
'libvpx': ['third_party/libvpx/source/libvpx/LICENSE'],
'libyuv': ['third_party/libyuv/LICENSE'],
'nasm': ['third_party/nasm/LICENSE'],
'opus': ['third_party/opus/src/COPYING'],
'pffft': ['third_party/pffft/LICENSE'],
'protobuf': ['third_party/protobuf/LICENSE'],
'rnnoise': ['third_party/rnnoise/COPYING'],
'usrsctp': ['third_party/usrsctp/LICENSE'],
'webrtc': ['LICENSE'],
'zlib': ['third_party/zlib/LICENSE'],
'base64': ['rtc_base/third_party/base64/LICENSE'],
'sigslot': ['rtc_base/third_party/sigslot/LICENSE'],
'portaudio': ['modules/third_party/portaudio/LICENSE'],
'fft': ['modules/third_party/fft/LICENSE'],
'g711': ['modules/third_party/g711/LICENSE'],
'g722': ['modules/third_party/g722/LICENSE'],
'ooura': ['common_audio/third_party/ooura/LICENSE'],
'spl_sqrt_floor': ['common_audio/third_party/spl_sqrt_floor/LICENSE'],
# TODO(bugs.webrtc.org/1110): Remove this hack. This is not a lib.
# For some reason it is listed as so in _GetThirdPartyLibraries.
'android_deps': [],
# This is not a library but a collection of libraries.
'androidx': [],
# Compile time dependencies, no license needed:
'yasm': [],
'ow2_asm': [],
'jdk': [],
}
# Third_party library _regex_ to licences mapping. Keys are regular expression
# with names of the libraries (right after the `third_party/` prefix)
LIB_REGEX_TO_LICENSES_DICT = {
'android_deps:android_support_annotations.*': [
'third_party/android_deps/libs/' +
'com_android_support_support_annotations/LICENSE'
],
# Internal dependencies, licenses are already included by other dependencies
'android_deps:com_android_support_support_annotations.*': [],
}
def FindSrcDirPath():
"""Returns the abs path to the src/ dir of the project."""
src_dir = os.path.dirname(os.path.abspath(__file__))
while os.path.basename(src_dir) != 'src':
src_dir = os.path.normpath(os.path.join(src_dir, os.pardir))
return src_dir
SCRIPT_DIR = os.path.dirname(os.path.realpath(sys.argv[0]))
WEBRTC_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir))
SRC_DIR = FindSrcDirPath()
sys.path.append(os.path.join(SRC_DIR, 'build'))
import find_depot_tools
THIRD_PARTY_LIB_SIMPLE_NAME_REGEX = r'^.*/third_party/([\w\-+]+).*$'
THIRD_PARTY_LIB_REGEX_TEMPLATE = r'^.*/third_party/%s$'
class LicenseBuilder(object):
def __init__(self,
buildfile_dirs,
targets,
lib_to_licenses_dict=None,
lib_regex_to_licenses_dict=None):
if lib_to_licenses_dict is None:
lib_to_licenses_dict = LIB_TO_LICENSES_DICT
if lib_regex_to_licenses_dict is None:
lib_regex_to_licenses_dict = LIB_REGEX_TO_LICENSES_DICT
self.buildfile_dirs = buildfile_dirs
self.targets = targets
self.lib_to_licenses_dict = lib_to_licenses_dict
self.lib_regex_to_licenses_dict = lib_regex_to_licenses_dict
self.common_licenses_dict = self.lib_to_licenses_dict.copy()
self.common_licenses_dict.update(self.lib_regex_to_licenses_dict)
@staticmethod
def _ParseLibraryName(dep):
"""Returns library name after third_party
Input one of:
//a/b/third_party/libname:c
//a/b/third_party/libname:c(//d/e/f:g)
//a/b/third_party/libname/c:d(//e/f/g:h)
Outputs libname or None if this is not a third_party dependency.
"""
groups = re.match(THIRD_PARTY_LIB_SIMPLE_NAME_REGEX, dep)
return groups.group(1) if groups else None
def _ParseLibrary(self, dep):
"""Returns library simple or regex name that matches `dep` after third_party
This method matches `dep` dependency against simple names in
LIB_TO_LICENSES_DICT and regular expression names in
LIB_REGEX_TO_LICENSES_DICT keys
Outputs matched dict key or None if this is not a third_party dependency.
"""
libname = LicenseBuilder._ParseLibraryName(dep)
for lib_regex in self.lib_regex_to_licenses_dict:
if re.match(THIRD_PARTY_LIB_REGEX_TEMPLATE % lib_regex, dep):
return lib_regex
return libname
@staticmethod
def _RunGN(buildfile_dir, target):
cmd = [
sys.executable,
os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, 'gn.py'),
'desc',
'--all',
'--format=json',
os.path.abspath(buildfile_dir),
target,
]
logging.debug('Running: %r', cmd)
output_json = subprocess.check_output(cmd, cwd=WEBRTC_ROOT)
logging.debug('Output: %s', output_json)
return output_json
def _GetThirdPartyLibraries(self, buildfile_dir, target):
output = json.loads(LicenseBuilder._RunGN(buildfile_dir, target))
libraries = set()
for described_target in output.values():
third_party_libs = (self._ParseLibrary(dep)
for dep in described_target['deps'])
libraries |= set(lib for lib in third_party_libs if lib)
return libraries
def GenerateLicenseText(self, output_dir):
# Get a list of third_party libs from gn. For fat libraries we must consider
# all architectures, hence the multiple buildfile directories.
third_party_libs = set()
for buildfile in self.buildfile_dirs:
for target in self.targets:
third_party_libs |= self._GetThirdPartyLibraries(
buildfile, target)
assert len(third_party_libs) > 0
missing_licenses = third_party_libs - set(
self.common_licenses_dict.keys())
if missing_licenses:
error_msg = 'Missing licenses for following third_party targets: %s' % \
', '.join(missing_licenses)
logging.error(error_msg)
raise Exception(error_msg)
# Put webrtc at the front of the list.
license_libs = sorted(third_party_libs)
license_libs.insert(0, 'webrtc')
logging.info('List of licenses: %s', ', '.join(license_libs))
# Generate markdown.
output_license_file = open(os.path.join(output_dir, 'LICENSE.md'),
'w+')
for license_lib in license_libs:
if len(self.common_licenses_dict[license_lib]) == 0:
logging.info(
'Skipping compile time or internal dependency: %s',
license_lib)
continue # Compile time dependency
output_license_file.write('# %s\n' % license_lib)
output_license_file.write('```\n')
for path in self.common_licenses_dict[license_lib]:
license_path = os.path.join(WEBRTC_ROOT, path)
with open(license_path, 'r') as license_file:
license_text = cgi.escape(license_file.read(), quote=True)
output_license_file.write(license_text)
output_license_file.write('\n')
output_license_file.write('```\n\n')
output_license_file.close()
def main():
parser = argparse.ArgumentParser(description='Generate WebRTC LICENSE.md')
parser.add_argument('--verbose',
action='store_true',
default=False,
help='Debug logging.')
parser.add_argument('--target',
required=True,
action='append',
default=[],
help='Name of the GN target to generate a license for')
parser.add_argument('output_dir',
help='Directory to output LICENSE.md to.')
parser.add_argument('buildfile_dirs',
nargs='+',
help='Directories containing gn generated ninja files')
args = parser.parse_args()
logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO)
builder = LicenseBuilder(args.buildfile_dirs, args.target)
builder.GenerateLicenseText(args.output_dir)
if __name__ == '__main__':
sys.exit(main())