aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiyong Park2019-03-17 22:01:38 -0500
committerJiyong Park2019-03-20 18:05:50 -0500
commit52818fcde8265fd43ad5f331f57122ecdbe7a6be (patch)
tree9c0edd5e4f9dfcae48cb3f87ff0f10c11b3fa776 /scripts
parent5a3f31b28451717dd7e9d948bcaa5644de759b17 (diff)
downloadplatform-build-soong-52818fcde8265fd43ad5f331f57122ecdbe7a6be.tar.gz
platform-build-soong-52818fcde8265fd43ad5f331f57122ecdbe7a6be.tar.xz
platform-build-soong-52818fcde8265fd43ad5f331f57122ecdbe7a6be.zip
Notice support for APEX
Notice file for an APEX is created by merging notice files for the modules included in it (plus the notice file for the APEX itself if specified). Notice files having the same content are not duplicated; it is emitted only once. Bug: 128701495 Test: m (apex_test is amended) Test: m and inspect $(PRODUCT_OUT)/obj/NOTICE.txt to check there are license entries for /system/apex/*.apex files Change-Id: I169d91038291a6c71615de97cf5b03174afab5d4
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/mergenotice.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/scripts/mergenotice.py b/scripts/mergenotice.py
new file mode 100755
index 00000000..407ae8cc
--- /dev/null
+++ b/scripts/mergenotice.py
@@ -0,0 +1,49 @@
1#!/usr/bin/env python
2#
3# Copyright (C) 2019 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17"""
18Merges input notice files to the output file while ignoring duplicated files
19This script shouldn't be confused with build/make/tools/generate-notice-files.py
20which is responsible for creating the final notice file for all artifacts
21installed. This script has rather limited scope; it is meant to create a merged
22notice file for a set of modules that are packaged together, e.g. in an APEX.
23The merged notice file does not reveal the individual files in the package.
24"""
25
26import sys
27import argparse
28
29def get_args():
30 parser = argparse.ArgumentParser(description='Merge notice files.')
31 parser.add_argument('--output', help='output file path.')
32 parser.add_argument('inputs', metavar='INPUT', nargs='+',
33 help='input notice file')
34 return parser.parse_args()
35
36def main(argv):
37 args = get_args()
38
39 processed = set()
40 with open(args.output, 'w+') as output:
41 for input in args.inputs:
42 with open(input, 'r') as f:
43 data = f.read().strip()
44 if data not in processed:
45 processed.add(data)
46 output.write('%s\n\n' % data)
47
48if __name__ == '__main__':
49 main(sys.argv)