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 def DoCopy(path, target_path):
15 if os.path.isfile(path):
17 package_re = re.compile(
18 '^package (?P<package>([a-zA-Z0-9_]+.)*[a-zA-Z0-9_]+);$')
19 for line in open(path).readlines():
20 match = package_re.match(line)
22 package = match.group('package')
24 sub_path = os.path.sep.join(package.split('.'))
25 shutil.copy(path, os.path.join(target_path, sub_path))
28 for dirpath, _, files in os.walk(path):
31 sub_path = os.path.relpath(dirpath, path)
32 target_dirpath = os.path.join(target_path, sub_path)
33 if not os.path.isdir(target_dirpath):
34 os.makedirs(target_dirpath)
36 fpath = os.path.join(dirpath, f)
37 # "interface type;" is invalid for normal android project,
38 # It's only for chromium's build system, ignore these aidl files.
39 if f.endswith('.aidl'):
41 for line in open(fpath).readlines():
42 if re.match('^interface .*;$', line):
43 invalid_lines.append(line)
46 elif not f.endswith('.java'):
48 shutil.copy(fpath, target_dirpath)
52 parser = optparse.OptionParser()
53 info = ('The java source dirs to merge.')
54 parser.add_option('--dirs', help=info)
55 info = ('The target to place all the sources.')
56 parser.add_option('--target-path', help=info)
57 options, _ = parser.parse_args()
59 if os.path.isdir(options.target_path):
60 shutil.rmtree(options.target_path)
61 os.makedirs(options.target_path)
63 for path in options.dirs.split(' '):
64 if path.startswith('"') and path.endswith('"'):
66 DoCopy(path, options.target_path)
69 if __name__ == '__main__':