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

Side by Side Diff: webrtc/build/generate_srcjar.py

Issue 2653593003: Removing unused code from webrtc/build (Closed)
Patch Set: Created 3 years, 11 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 | webrtc/build/google_play_services_download.py » ('j') | 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/env python
2 #
3 # Copyright (c) 2017 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 # TODO(mbonadei): move this script into chromium (build/android/gyp)
12 # when approved
13
14 import optparse
15 import os
16 import re
17 import sys
18 import zipfile
19
20 sys.path.insert(0, os.path.abspath(os.path.join(os.pardir, os.pardir, 'build',
21 'android', 'gyp', 'util')))
22 import build_utils
23
24
25 def PackageToPath(src_file):
26 """Returns the path of a .java file according to the package declaration.
27
28 Example:
29 src_file='/home/foo/bar/org/android/TestClass.java'
30 With the following package definition:
31 package org.android;
32
33 It will return 'org/android'.
34
35 Args:
36 A string with the path of the .java source file to analyze.
37
38 Returns:
39 A string with the translation of the package definition into a path.
40 """
41 with open(src_file) as f:
42 file_src = f.read()
43 package = re.search('package (.*);', file_src).group(1)
44 zip_folder = package.replace('.', os.path.sep)
45 file_name = os.path.basename(src_file)
46 return os.path.join(zip_folder, file_name)
47
48
49 def DoMain(argv):
50 usage = 'usage: %prog [options] input_file(s)...'
51 parser = optparse.OptionParser(usage=usage)
52 parser.add_option('-s', '--srcjar',
53 help='The path where the .srcjar file will be generated')
54
55 options, args = parser.parse_args(argv)
56
57 if not args:
58 parser.error('Need to specify at least one input source file (.java)')
59 input_paths = args
60
61 with zipfile.ZipFile(options.srcjar, 'w', zipfile.ZIP_STORED) as srcjar:
62 for src_path in input_paths:
63 zip_path = PackageToPath(src_path)
64 build_utils.AddToZipHermetic(srcjar, zip_path, src_path)
65
66
67 if __name__ == '__main__':
68 DoMain(sys.argv[1:])
OLDNEW
« no previous file with comments | « no previous file | webrtc/build/google_play_services_download.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698