Committed by
Gerrit Code Review
remove unused files from buck-tools
Change-Id: Ia0858a89a47b338c1593a8806b17d291f1897ea3
Showing
8 changed files
with
0 additions
and
477 deletions
1 | python_binary( | 1 | python_binary( |
2 | - name = 'download_file', | ||
3 | - main = 'download_file.py', | ||
4 | - deps = [':util'], | ||
5 | - visibility = ['PUBLIC'], | ||
6 | -) | ||
7 | - | ||
8 | -python_binary( | ||
9 | name = 'onos-app-writer', | 2 | name = 'onos-app-writer', |
10 | main = 'onos_app.py', | 3 | main = 'onos_app.py', |
11 | deps = [], | 4 | deps = [], |
... | @@ -33,22 +26,6 @@ python_binary( | ... | @@ -33,22 +26,6 @@ python_binary( |
33 | visibility = ['PUBLIC'], | 26 | visibility = ['PUBLIC'], |
34 | ) | 27 | ) |
35 | 28 | ||
36 | -python_binary( | ||
37 | - name = 'pack_war', | ||
38 | - main = 'pack_war.py', | ||
39 | - deps = [':util'], | ||
40 | - visibility = ['PUBLIC'], | ||
41 | -) | ||
42 | - | ||
43 | -python_library( | ||
44 | - name = 'util', | ||
45 | - srcs = [ | ||
46 | - 'util.py', | ||
47 | - '__init__.py' | ||
48 | - ], | ||
49 | - visibility = ['PUBLIC'], | ||
50 | -) | ||
51 | - | ||
52 | def shquote(s): | 29 | def shquote(s): |
53 | return s.replace("'", "'\\''") | 30 | return s.replace("'", "'\\''") |
54 | 31 | ... | ... |
buck-tools/GoogleFormat.xml
deleted
100644 → 0
This diff is collapsed. Click to expand it.
buck-tools/__init__.py
deleted
100644 → 0
File mode changed
buck-tools/download_all.py
deleted
100755 → 0
1 | -#!/usr/bin/env python | ||
2 | -# Copyright (C) 2013 The Android Open Source Project | ||
3 | -# | ||
4 | -# Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | -# you may not use this file except in compliance with the License. | ||
6 | -# You may obtain a copy of the License at | ||
7 | -# | ||
8 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | -# | ||
10 | -# Unless required by applicable law or agreed to in writing, software | ||
11 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | -# See the License for the specific language governing permissions and | ||
14 | -# limitations under the License. | ||
15 | - | ||
16 | -from optparse import OptionParser | ||
17 | -import re | ||
18 | -from subprocess import check_call, CalledProcessError, Popen, PIPE | ||
19 | - | ||
20 | -MAIN = ['//buck-tools/eclipse:classpath'] | ||
21 | -PAT = re.compile(r'"(//.*?)" -> "//buck-tools:download_file"') | ||
22 | -# TODO(davido): Remove this hack when Buck bugs are fixed: | ||
23 | -# https://github.com/facebook/buck/issues/656 | ||
24 | -# https://github.com/facebook/buck/issues/658 | ||
25 | -JGIT = re.compile(r'//org.eclipse.jgit.*') | ||
26 | -CELL = '//lib/jgit' | ||
27 | - | ||
28 | -opts = OptionParser() | ||
29 | -opts.add_option('--src', action='store_true') | ||
30 | -args, _ = opts.parse_args() | ||
31 | - | ||
32 | -targets = set() | ||
33 | - | ||
34 | -p = Popen(['buck', 'audit', 'classpath', '--dot'] + MAIN, stdout = PIPE) | ||
35 | -for line in p.stdout: | ||
36 | - m = PAT.search(line) | ||
37 | - if m: | ||
38 | - n = m.group(1) | ||
39 | - if JGIT.match(n): | ||
40 | - n = CELL + n[1:] | ||
41 | - if args.src and n.endswith('__download_bin'): | ||
42 | - n = n[:-13] + 'src' | ||
43 | - targets.add(n) | ||
44 | -r = p.wait() | ||
45 | -if r != 0: | ||
46 | - exit(r) | ||
47 | - | ||
48 | -try: | ||
49 | - check_call(['buck', 'build'] + sorted(targets)) | ||
50 | -except CalledProcessError as err: | ||
51 | - exit(1) |
buck-tools/download_file.py
deleted
100755 → 0
1 | -#!/usr/bin/env python | ||
2 | -# Copyright (C) 2013 The Android Open Source Project | ||
3 | -# | ||
4 | -# Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | -# you may not use this file except in compliance with the License. | ||
6 | -# You may obtain a copy of the License at | ||
7 | -# | ||
8 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | -# | ||
10 | -# Unless required by applicable law or agreed to in writing, software | ||
11 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | -# See the License for the specific language governing permissions and | ||
14 | -# limitations under the License. | ||
15 | - | ||
16 | -from __future__ import print_function | ||
17 | - | ||
18 | -from hashlib import sha1 | ||
19 | -from optparse import OptionParser | ||
20 | -from os import link, makedirs, path, remove | ||
21 | -import shutil | ||
22 | -from subprocess import check_call, CalledProcessError | ||
23 | -from sys import stderr | ||
24 | -from util import hash_file, resolve_url | ||
25 | -from zipfile import ZipFile, BadZipfile, LargeZipFile | ||
26 | - | ||
27 | -GERRIT_HOME = path.expanduser('~/.gerritcodereview') | ||
28 | -CACHE_DIR = path.join(GERRIT_HOME, 'buck-cache', 'downloaded-artifacts') | ||
29 | -# LEGACY_CACHE_DIR is only used to allow existing workspaces to move already | ||
30 | -# downloaded files to the new cache directory. | ||
31 | -# Please remove after 3 months (2015-10-07). | ||
32 | -LEGACY_CACHE_DIR = path.join(GERRIT_HOME, 'buck-cache') | ||
33 | -LOCAL_PROPERTIES = 'local.properties' | ||
34 | - | ||
35 | - | ||
36 | -def safe_mkdirs(d): | ||
37 | - if path.isdir(d): | ||
38 | - return | ||
39 | - try: | ||
40 | - makedirs(d) | ||
41 | - except OSError as err: | ||
42 | - if not path.isdir(d): | ||
43 | - raise err | ||
44 | - | ||
45 | - | ||
46 | -def download_properties(root_dir): | ||
47 | - """ Get the download properties. | ||
48 | - | ||
49 | - First tries to find the properties file in the given root directory, | ||
50 | - and if not found there, tries in the Gerrit settings folder in the | ||
51 | - user's home directory. | ||
52 | - | ||
53 | - Returns a set of download properties, which may be empty. | ||
54 | - | ||
55 | - """ | ||
56 | - p = {} | ||
57 | - local_prop = path.join(root_dir, LOCAL_PROPERTIES) | ||
58 | - if not path.isfile(local_prop): | ||
59 | - local_prop = path.join(GERRIT_HOME, LOCAL_PROPERTIES) | ||
60 | - if path.isfile(local_prop): | ||
61 | - try: | ||
62 | - with open(local_prop) as fd: | ||
63 | - for line in fd: | ||
64 | - if line.startswith('download.'): | ||
65 | - d = [e.strip() for e in line.split('=', 1)] | ||
66 | - name, url = d[0], d[1] | ||
67 | - p[name[len('download.'):]] = url | ||
68 | - except OSError: | ||
69 | - pass | ||
70 | - return p | ||
71 | - | ||
72 | - | ||
73 | -def cache_entry(args): | ||
74 | - if args.v: | ||
75 | - h = args.v | ||
76 | - else: | ||
77 | - h = sha1(args.u.encode('utf-8')).hexdigest() | ||
78 | - name = '%s-%s' % (path.basename(args.o), h) | ||
79 | - return path.join(CACHE_DIR, name) | ||
80 | - | ||
81 | -# Please remove after 3 months (2015-10-07). See LEGACY_CACHE_DIR above. | ||
82 | -def legacy_cache_entry(args): | ||
83 | - if args.v: | ||
84 | - h = args.v | ||
85 | - else: | ||
86 | - h = sha1(args.u.encode('utf-8')).hexdigest() | ||
87 | - name = '%s-%s' % (path.basename(args.o), h) | ||
88 | - return path.join(LEGACY_CACHE_DIR, name) | ||
89 | - | ||
90 | - | ||
91 | -opts = OptionParser() | ||
92 | -opts.add_option('-o', help='local output file') | ||
93 | -opts.add_option('-u', help='URL to download') | ||
94 | -opts.add_option('-v', help='expected content SHA-1') | ||
95 | -opts.add_option('-x', action='append', help='file to delete from ZIP') | ||
96 | -opts.add_option('--exclude_java_sources', action='store_true') | ||
97 | -opts.add_option('--unsign', action='store_true') | ||
98 | -args, _ = opts.parse_args() | ||
99 | - | ||
100 | -root_dir = args.o | ||
101 | -while root_dir: | ||
102 | - root_dir, n = path.split(root_dir) | ||
103 | - if n == 'buck-out': | ||
104 | - break | ||
105 | - | ||
106 | -redirects = download_properties(root_dir) | ||
107 | -cache_ent = cache_entry(args) | ||
108 | -legacy_cache_ent = legacy_cache_entry(args) | ||
109 | -src_url = resolve_url(args.u, redirects) | ||
110 | - | ||
111 | -# Please remove after 3 months (2015-10-07). See LEGACY_CACHE_DIR above. | ||
112 | -if not path.exists(cache_ent) and path.exists(legacy_cache_ent): | ||
113 | - try: | ||
114 | - safe_mkdirs(path.dirname(cache_ent)) | ||
115 | - except OSError as err: | ||
116 | - print('error creating directory %s: %s' % | ||
117 | - (path.dirname(cache_ent), err), file=stderr) | ||
118 | - exit(1) | ||
119 | - shutil.move(legacy_cache_ent, cache_ent) | ||
120 | - | ||
121 | -if not path.exists(cache_ent): | ||
122 | - try: | ||
123 | - safe_mkdirs(path.dirname(cache_ent)) | ||
124 | - except OSError as err: | ||
125 | - print('error creating directory %s: %s' % | ||
126 | - (path.dirname(cache_ent), err), file=stderr) | ||
127 | - exit(1) | ||
128 | - | ||
129 | - print('Download %s' % src_url, file=stderr) | ||
130 | - try: | ||
131 | - check_call(['curl', '--proxy-anyauth', '-ksfo', cache_ent, src_url]) | ||
132 | - except OSError as err: | ||
133 | - print('could not invoke curl: %s\nis curl installed?' % err, file=stderr) | ||
134 | - exit(1) | ||
135 | - except CalledProcessError as err: | ||
136 | - print('error using curl: %s' % err, file=stderr) | ||
137 | - exit(1) | ||
138 | - | ||
139 | -if args.v: | ||
140 | - have = hash_file(sha1(), cache_ent).hexdigest() | ||
141 | - if args.v != have: | ||
142 | - print(( | ||
143 | - '%s:\n' + | ||
144 | - 'expected %s\n' + | ||
145 | - 'received %s\n') % (src_url, args.v, have), file=stderr) | ||
146 | - try: | ||
147 | - remove(cache_ent) | ||
148 | - except OSError as err: | ||
149 | - if path.exists(cache_ent): | ||
150 | - print('error removing %s: %s' % (cache_ent, err), file=stderr) | ||
151 | - exit(1) | ||
152 | - | ||
153 | -exclude = [] | ||
154 | -if args.x: | ||
155 | - exclude += args.x | ||
156 | -if args.exclude_java_sources: | ||
157 | - try: | ||
158 | - with ZipFile(cache_ent, 'r') as zf: | ||
159 | - for n in zf.namelist(): | ||
160 | - if n.endswith('.java'): | ||
161 | - exclude.append(n) | ||
162 | - except (BadZipfile, LargeZipFile) as err: | ||
163 | - print('error opening %s: %s' % (cache_ent, err), file=stderr) | ||
164 | - exit(1) | ||
165 | - | ||
166 | -if args.unsign: | ||
167 | - try: | ||
168 | - with ZipFile(cache_ent, 'r') as zf: | ||
169 | - for n in zf.namelist(): | ||
170 | - if (n.endswith('.RSA') | ||
171 | - or n.endswith('.SF') | ||
172 | - or n.endswith('.LIST')): | ||
173 | - exclude.append(n) | ||
174 | - except (BadZipfile, LargeZipFile) as err: | ||
175 | - print('error opening %s: %s' % (cache_ent, err), file=stderr) | ||
176 | - exit(1) | ||
177 | - | ||
178 | -safe_mkdirs(path.dirname(args.o)) | ||
179 | -if exclude: | ||
180 | - try: | ||
181 | - shutil.copyfile(cache_ent, args.o) | ||
182 | - except (shutil.Error, IOError) as err: | ||
183 | - print('error copying to %s: %s' % (args.o, err), file=stderr) | ||
184 | - exit(1) | ||
185 | - try: | ||
186 | - check_call(['zip', '-d', args.o] + exclude) | ||
187 | - except CalledProcessError as err: | ||
188 | - print('error removing files from zip: %s' % err, file=stderr) | ||
189 | - exit(1) | ||
190 | -else: | ||
191 | - try: | ||
192 | - link(cache_ent, args.o) | ||
193 | - except OSError as err: | ||
194 | - try: | ||
195 | - shutil.copyfile(cache_ent, args.o) | ||
196 | - except (shutil.Error, IOError) as err: | ||
197 | - print('error copying to %s: %s' % (args.o, err), file=stderr) | ||
198 | - exit(1) |
buck-tools/java_doc.defs
deleted
100644 → 0
1 | -def java_doc( | ||
2 | - name, | ||
3 | - title, | ||
4 | - pkgs, | ||
5 | - paths, | ||
6 | - srcs = [], | ||
7 | - deps = [], | ||
8 | - visibility = [], | ||
9 | - do_it_wrong = False, | ||
10 | - ): | ||
11 | - if do_it_wrong: | ||
12 | - sourcepath = paths | ||
13 | - else: | ||
14 | - sourcepath = ['$SRCDIR/' + n for n in paths] | ||
15 | - genrule( | ||
16 | - name = name, | ||
17 | - cmd = ' '.join([ | ||
18 | - 'while ! test -f .buckconfig; do cd ..; done;', | ||
19 | - 'javadoc', | ||
20 | - '-quiet', | ||
21 | - '-protected', | ||
22 | - '-encoding UTF-8', | ||
23 | - '-charset UTF-8', | ||
24 | - '-notimestamp', | ||
25 | - '-windowtitle "' + title + '"', | ||
26 | - '-link http://docs.oracle.com/javase/7/docs/api', | ||
27 | - '-subpackages ', | ||
28 | - ':'.join(pkgs), | ||
29 | - '-sourcepath ', | ||
30 | - ':'.join(sourcepath), | ||
31 | - ' -classpath ', | ||
32 | - ':'.join(['$(classpath %s)' % n for n in deps]), | ||
33 | - '-d $TMP', | ||
34 | - ]) + ';jar cf $OUT -C $TMP .', | ||
35 | - srcs = srcs, | ||
36 | - out = name + '.jar', | ||
37 | - visibility = visibility, | ||
38 | -) |
buck-tools/pack_war.py
deleted
100755 → 0
1 | -#!/usr/bin/env python | ||
2 | -# Copyright (C) 2013 The Android Open Source Project | ||
3 | -# | ||
4 | -# Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | -# you may not use this file except in compliance with the License. | ||
6 | -# You may obtain a copy of the License at | ||
7 | -# | ||
8 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | -# | ||
10 | -# Unless required by applicable law or agreed to in writing, software | ||
11 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | -# See the License for the specific language governing permissions and | ||
14 | -# limitations under the License. | ||
15 | - | ||
16 | -from __future__ import print_function | ||
17 | -from optparse import OptionParser | ||
18 | -from os import makedirs, path, symlink | ||
19 | -from subprocess import check_call | ||
20 | -import sys | ||
21 | - | ||
22 | -opts = OptionParser() | ||
23 | -opts.add_option('-o', help='path to write WAR to') | ||
24 | -opts.add_option('--lib', action='append', help='target for WEB-INF/lib') | ||
25 | -opts.add_option('--pgmlib', action='append', help='target for WEB-INF/pgm-lib') | ||
26 | -opts.add_option('--tmp', help='temporary directory') | ||
27 | -args, ctx = opts.parse_args() | ||
28 | - | ||
29 | -war = args.tmp | ||
30 | -jars = set() | ||
31 | -basenames = set() | ||
32 | - | ||
33 | -def prune(l): | ||
34 | - return [j for e in l for j in e.split(':')] | ||
35 | - | ||
36 | -def link_jars(libs, directory): | ||
37 | - makedirs(directory) | ||
38 | - for j in libs: | ||
39 | - if j not in jars: | ||
40 | - # When jgit is consumed from its own cell, | ||
41 | - # potential duplicates should be filtered. | ||
42 | - # e.g. jsch.jar will be reached through: | ||
43 | - # 1. /home/username/projects/gerrit/buck-out/gen/lib/jsch.jar | ||
44 | - # 2. /home/username/projects/jgit/buck-out/gen/lib/jsch.jar | ||
45 | - if (j.find('jgit/buck-out/gen/lib') > 0 | ||
46 | - and path.basename(j) in basenames): | ||
47 | - continue | ||
48 | - jars.add(j) | ||
49 | - n = path.basename(j) | ||
50 | - if j.find('buck-out/gen/gerrit-') > 0: | ||
51 | - n = j[j.find('buck-out'):].split('/')[2] + '-' + n | ||
52 | - basenames.add(n) | ||
53 | - symlink(j, path.join(directory, n)) | ||
54 | - | ||
55 | -if args.lib: | ||
56 | - link_jars(prune(args.lib), path.join(war, 'WEB-INF', 'lib')) | ||
57 | -if args.pgmlib: | ||
58 | - link_jars(prune(args.pgmlib), path.join(war, 'WEB-INF', 'pgm-lib')) | ||
59 | -try: | ||
60 | - for s in ctx: | ||
61 | - check_call(['unzip', '-q', '-d', war, s]) | ||
62 | - check_call(['zip', '-9qr', args.o, '.'], cwd=war) | ||
63 | -except KeyboardInterrupt: | ||
64 | - print('Interrupted by user', file=sys.stderr) | ||
65 | - exit(1) |
buck-tools/util.py
deleted
100644 → 0
1 | -# Copyright (C) 2013 The Android Open Source Project | ||
2 | -# | ||
3 | -# Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | -# you may not use this file except in compliance with the License. | ||
5 | -# You may obtain a copy of the License at | ||
6 | -# | ||
7 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | -# | ||
9 | -# Unless required by applicable law or agreed to in writing, software | ||
10 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | -# See the License for the specific language governing permissions and | ||
13 | -# limitations under the License. | ||
14 | - | ||
15 | -import os | ||
16 | -from os import path | ||
17 | - | ||
18 | -REPO_ROOTS = { | ||
19 | - 'GERRIT': 'http://gerrit-maven.storage.googleapis.com', | ||
20 | - 'GERRIT_API': 'https://gerrit-api.commondatastorage.googleapis.com/release', | ||
21 | - 'MAVEN_CENTRAL': 'http://repo1.maven.org/maven2', | ||
22 | - 'MAVEN_LOCAL': 'file://' + path.expanduser('~/.m2/repository'), | ||
23 | -} | ||
24 | - | ||
25 | - | ||
26 | -def resolve_url(url, redirects): | ||
27 | - """ Resolve URL of a Maven artifact. | ||
28 | - | ||
29 | - prefix:path is passed as URL. prefix identifies known or custom | ||
30 | - repositories that can be rewritten in redirects set, passed as | ||
31 | - second arguments. | ||
32 | - | ||
33 | - A special case is supported, when prefix neither exists in | ||
34 | - REPO_ROOTS, no in redirects set: the url is returned as is. | ||
35 | - This enables plugins to pass custom maven_repository URL as is | ||
36 | - directly to maven_jar(). | ||
37 | - | ||
38 | - Returns a resolved path for Maven artifact. | ||
39 | - """ | ||
40 | - s = url.find(':') | ||
41 | - if s < 0: | ||
42 | - return url | ||
43 | - scheme, rest = url[:s], url[s+1:] | ||
44 | - if scheme in redirects: | ||
45 | - root = redirects[scheme] | ||
46 | - elif scheme in REPO_ROOTS: | ||
47 | - root = REPO_ROOTS[scheme] | ||
48 | - else: | ||
49 | - return url | ||
50 | - root = root.rstrip('/') | ||
51 | - rest = rest.lstrip('/') | ||
52 | - return '/'.join([root, rest]) | ||
53 | - | ||
54 | - | ||
55 | -def hash_file(hash_obj, path): | ||
56 | - """Hash the contents of a file. | ||
57 | - | ||
58 | - Args: | ||
59 | - hash_obj: an open hash object, e.g. hashlib.sha1(). | ||
60 | - path: path to the file to hash. | ||
61 | - | ||
62 | - Returns: | ||
63 | - The passed-in hash_obj. | ||
64 | - """ | ||
65 | - with open(path, 'rb') as f: | ||
66 | - while True: | ||
67 | - b = f.read(8192) | ||
68 | - if not b: | ||
69 | - break | ||
70 | - hash_obj.update(b) | ||
71 | - return hash_obj | ||
72 | - | ||
73 | - | ||
74 | -def hash_bower_component(hash_obj, path): | ||
75 | - """Hash the contents of a bower component directory. | ||
76 | - | ||
77 | - This is a stable hash of a directory downloaded with `bower install`, minus | ||
78 | - the .bower.json file, which is autogenerated each time by bower. Used in lieu | ||
79 | - of hashing a zipfile of the contents, since zipfiles are difficult to hash in | ||
80 | - a stable manner. | ||
81 | - | ||
82 | - Args: | ||
83 | - hash_obj: an open hash object, e.g. hashlib.sha1(). | ||
84 | - path: path to the directory to hash. | ||
85 | - | ||
86 | - Returns: | ||
87 | - The passed-in hash_obj. | ||
88 | - """ | ||
89 | - if not os.path.isdir(path): | ||
90 | - raise ValueError('Not a directory: %s' % path) | ||
91 | - | ||
92 | - path = os.path.abspath(path) | ||
93 | - for root, dirs, files in os.walk(path): | ||
94 | - dirs.sort() | ||
95 | - for f in sorted(files): | ||
96 | - if f == '.bower.json': | ||
97 | - continue | ||
98 | - p = os.path.join(root, f) | ||
99 | - hash_obj.update(p[len(path)+1:]) | ||
100 | - hash_file(hash_obj, p) | ||
101 | - | ||
102 | - return hash_obj |
-
Please register or login to post a comment