3 # Copyright (c) 2014 Intel Corporation. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
14 option_parser = optparse.OptionParser()
15 option_parser.add_option('-t', dest='target',
16 help='Product out target directory.')
17 options, _ = option_parser.parse_args()
19 # The first entry of each tuple is the source file/directory that will be
20 # copied (and must exist), the second entry is its relative path inside the
23 (os.path.join(options.target, 'xwalk_core_library', 'libs'),
25 (os.path.join(options.target, 'xwalk_core_library', 'res'),
29 (os.path.join(options.target, 'gen', 'xwalk_core_internal_java', 'java_R',
32 (os.path.join(options.target, 'xwalk_core_library', 'AndroidManifest.xml'),
33 'AndroidManifest.xml'),
34 (os.path.join(options.target, 'lib.java', 'xwalk_core_library_java.jar'),
37 # This is a list of files that will not be packaged: mostly a blacklist of
38 # files within |dirs|.
40 os.path.join(options.target, 'xwalk_core_library', 'libs',
41 'xwalk_core_library_java_app_part.jar'),
42 os.path.join(options.target, 'xwalk_core_library', 'libs',
43 'xwalk_core_library_java_library_part.jar'),
46 aar_path = os.path.join(options.target, 'xwalk_core_library.aar')
47 with zipfile.ZipFile(aar_path, 'w', zipfile.ZIP_DEFLATED) as aar_file:
48 for src, dest in files:
49 aar_file.write(src, dest)
50 for src, dest in dirs:
51 for root, _, files in os.walk(src):
53 real_path = os.path.join(root, f)
54 zip_path = os.path.join(dest, os.path.relpath(root, src), f)
55 if real_path in exclude_files:
57 aar_file.write(real_path, zip_path)
62 if __name__ == '__main__':