Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Side by Side Diff: webrtc/build/ios/generate_licenses.py

Issue 1922363002: Script to generate licenses for prebuilt WebRTC. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
2
3 # Copyright 2016 The WebRTC project authors. All Rights Reserved.
4 #
5 # Use of this source code is governed by a BSD-style license
6 # that can be found in the LICENSE file in the root of the source
7 # tree. An additional intellectual property rights grant can be found
8 # in the file PATENTS. All contributing project authors may
9 # be found in the AUTHORS file in the root of the source tree.
10
11 """Generates license HTML for a prebuilt version of WebRTC for iOS."""
12
13 import sys
kjellander_webrtc 2016/04/27 12:58:05 sort this among the other standard library modules
tkchin_webrtc 2016/04/27 21:43:28 linter told me to place this above
kjellander_webrtc 2016/04/28 07:38:24 hmm, that never happened to me, odd. I guess we'll
tkchin_webrtc 2016/04/28 22:38:10 using gpylint maybe that makes a difference
kjellander_webrtc 2016/04/29 05:27:59 I dunno, it seems this passed git cl presubmit (wh
14
15 import argparse
16 import cgi
17 import os
18 import re
19
20
21 WEBRTC_LIBS = [
kjellander_webrtc 2016/04/27 12:58:05 Ouch, you're signing up for painful maintenance he
tkchin_webrtc 2016/04/27 21:43:29 Yes, the goal was to cause breakage if license cha
kjellander_webrtc 2016/04/28 07:38:24 That sounds great. I guess you'll get test and too
tkchin_webrtc 2016/04/28 22:38:10 The tools won't actually be built since only depen
kjellander_webrtc 2016/04/29 05:27:59 Acknowledged.
22 'audio_coding_module',
23 'audio_conference_mixer',
24 'audio_decoder_interface',
25 'audio_device',
26 'audio_encoder_interface',
27 'audio_processing',
28 'audioproc_debug_proto',
29 'bitrate_controller',
30 'cng',
31 'common_audio',
32 'common_video',
33 'congestion_controller',
34 'field_trial_default',
35 'g711',
36 'g722',
37 'ilbc',
38 'isac',
39 'isac_common',
40 'jingle_peerconnection_objc',
41 'jingle_peerconnection',
42 'media_file',
43 'metrics_default',
44 'neteq',
45 'paced_sender',
46 'pcm16b',
47 'red',
48 'remote_bitrate_estimator',
49 'rent_a_codec',
50 'rtp_rtcp',
51 'system_wrappers',
52 'video_capture_module_internal_impl',
53 'video_capture_module',
54 'video_coding_utility',
55 'video_processing',
56 'video_render_module_internal_impl',
57 'video_render_module',
58 'voice_engine',
59 ]
60
61
62 LIB_TO_LICENSES_DICT = {
63 'boringssl': ['third_party/boringssl/NOTICE'],
64 'expat': ['third_party/expat/files/COPYING'],
65 'jsoncpp': ['third_party/jsoncpp/LICENSE'],
66 'opus': ['third_party/opus/src/COPYING'],
67 'protobuf_lite': ['third_party/protobuf/COPYING.txt'],
68 'srtp': ['third_party/libsrtp/srtp/LICENSE'],
69 'usrsctplib': ['third_party/usrsctp/LICENSE'],
70 'webrtc': ['webrtc/LICENSE', 'webrtc/LICENSE_THIRD_PARTY'],
71 'vpx': ['third_party/libvpx/source/libvpx/LICENSE'],
72 'yuv': ['third_party/libyuv/LICENSE'],
73 }
74
75
76 def IsWebRTCLib(lib):
77 if (lib in WEBRTC_LIBS or
78 re.search('rtc_.*', lib) is not None or
79 re.search('webrtc.*', lib) is not None):
80 return True
81 return False
82
83
84 def GetWebRTCPath():
85 # WebRTC path is script path down three directories.
86 path = os.path.dirname(os.path.realpath(sys.argv[0]))
kjellander_webrtc 2016/04/27 12:58:05 Define a constant like checkout_root instead (see
tkchin_webrtc 2016/04/27 21:43:29 Done.
87 i = 3
88 while i > 0:
89 path = os.path.dirname(path)
90 i -= 1
91 return path
92
93
94 def GenerateLicenseText(static_lib_dir, output_dir):
95 # Get a list of libs from the files without their prefix and extension.
96 static_libs = []
97 for static_lib in os.listdir(static_lib_dir):
98 # Skip non libraries.
99 if not (static_lib.endswith('.a') and static_lib.startswith('lib')):
100 continue
101 # Extract library name.
102 static_libs.append(static_lib[3:-2])
103
104 # Generate amalgamated list of libraries. Mostly this just collapses the
105 # various WebRTC libs names into just 'webrtc'. Will exit with error if a
106 # lib is unrecognized.
107 license_libs = set()
108 for static_lib in static_libs:
109 license_lib = 'webrtc' if IsWebRTCLib(static_lib) else static_lib
110 license_path = LIB_TO_LICENSES_DICT.get(license_lib)
111 if license_path is None:
112 print 'Missing license path for lib: %s' % license_lib
113 sys.exit(1)
114 license_libs.add(license_lib)
115
116 # Put webrtc at the front of the list.
117 assert 'webrtc' in license_libs
118 license_libs.remove('webrtc')
119 license_libs = sorted(license_libs)
120 license_libs.insert(0, 'webrtc')
121
122 # Generate HTML.
123 output_license_file = open(os.path.join(output_dir, 'LICENSE.html'), 'w+')
124 output_license_file.write('<!DOCTYPE html>\n')
125 output_license_file.write('<html><head>\n')
126 output_license_file.write(' <meta charset="UTF-8">\n')
127 style_tag = ''' <style>
kjellander_webrtc 2016/04/27 12:58:05 Use textwrap.dedent instead, like https://chromium
tkchin_webrtc 2016/04/27 21:43:29 Done.
128 body { margin: 0; font-family: sans-serif; }
129 pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; }
130 li { list-style: none; }
131 p { margin: 1em; white-space: nowrap; }
132 </style>'''
133 output_license_file.write(style_tag)
134 output_license_file.write('\n <title>Licenses</title>\n')
kjellander_webrtc 2016/04/27 12:58:05 Put this leading newline in the end of the style_t
tkchin_webrtc 2016/04/27 21:43:28 Done.
135 output_license_file.write('</head>\n')
136
137 for license_lib in license_libs:
138 output_license_file.write('<p>\n%s<br/></p>\n' % license_lib)
kjellander_webrtc 2016/04/27 12:58:05 newline in the beginning of the paragraph?
tkchin_webrtc 2016/04/27 21:43:29 Done.
kjellander_webrtc 2016/04/28 07:38:24 I meant I was surprised to see the newline at the
tkchin_webrtc 2016/04/28 22:38:10 Oh, nope, removed.
139 output_license_file.write('<pre>\n')
140 for path in LIB_TO_LICENSES_DICT[license_lib]:
141 license_path = os.path.join(GetWebRTCPath(), path)
142 with open(license_path, 'r') as license_file:
143 license_text = cgi.escape(license_file.read(), quote=True)
144 output_license_file.write(license_text)
145 output_license_file.write('\n')
146 output_license_file.write('</pre>\n')
147
148 output_license_file.write('</body>\n')
149 output_license_file.write('</html>')
150 output_license_file.close()
151
152
153 if __name__ == '__main__':
154 parser = argparse.ArgumentParser(description='Generate WebRTC LICENSE.html')
155 parser.add_argument('static_lib_dir',
156 help='Directory with built static libraries.')
157 parser.add_argument('output_dir',
158 help='Directory to output LICENSE.html to.')
159 args = parser.parse_args()
160 GenerateLicenseText(args.static_lib_dir, args.output_dir)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698