31
31
('*tools/jdk/BUILD' , lambda x : 'tools/jdk/BUILD' ),
32
32
('*tools/build_defs/repo/BUILD.repo' ,
33
33
lambda x : 'tools/build_defs/repo/BUILD' ),
34
- ('*tools/platforms/platforms. BUILD' , lambda x : 'platforms/BUILD' ),
34
+ ('*tools/platforms/BUILD.tools ' , lambda x : 'platforms/BUILD' ),
35
35
('*tools/platforms/*' , lambda x : 'platforms/' + os .path .basename (x )),
36
36
('*tools/cpp/runfiles/generated_*' ,
37
37
lambda x : 'tools/cpp/runfiles/' + os .path .basename (x )[len ('generated_' ):]),
51
51
lambda x : 'tools/objc/make_hashed_objlist.py' ),
52
52
('*xcode*realpath' , lambda x : 'tools/objc/realpath' ),
53
53
('*xcode*xcode-locator' , lambda x : 'tools/objc/xcode-locator' ),
54
- ('*src/tools/xcode/*.sh' , lambda x : 'tools/objc/' + os .path .basename (x )),
55
- ('*src/tools/xcode/*' ,
56
- lambda x : 'tools/objc/' + os .path .basename (x ) + '.sh' ),
54
+ ('*src/tools/xcode/*' , lambda x : 'tools/objc/' + os .path .basename (x )),
57
55
('*external/openjdk_*/file/*.tar.gz' , lambda x : 'jdk.tar.gz' ),
58
56
('*external/openjdk_*/file/*.zip' , lambda x : 'jdk.zip' ),
59
57
('*src/minimal_jdk.tar.gz' , lambda x : 'jdk.tar.gz' ),
@@ -70,15 +68,18 @@ def get_output_path(path):
70
68
71
69
72
70
def get_input_files (argsfile ):
73
- """Returns a sorted list of tuples ( archive_file, input_file) .
71
+ """Returns a dict of archive_file to input_file.
74
72
75
73
This describes the files that should be put into the generated archive.
76
74
77
75
Args:
78
76
argsfile: The file containing the list of input files.
77
+
78
+ Raises:
79
+ ValueError: When two input files map to the same output file.
79
80
"""
80
81
with open (argsfile , 'r' ) as f :
81
- input_files = set (x .strip () for x in f .readlines ())
82
+ input_files = sorted ( set (x .strip () for x in f .readlines () ))
82
83
83
84
result = {}
84
85
for input_file in input_files :
@@ -87,14 +88,16 @@ def get_input_files(argsfile):
87
88
input_file + '.tools' in input_files ):
88
89
continue
89
90
90
- # This gives us the same behavior as the older bash version of this
91
- # tool: If two input files map to the same output files, the one that
92
- # comes last in the list of input files overrides all earlier ones.
93
- result [get_output_path (input_file )] = input_file
91
+ # It's an error to have two files map to the same output file, because the
92
+ # result is hard to predict and can easily be wrong.
93
+ output_path = get_output_path (input_file )
94
+ if output_path in result :
95
+ raise ValueError (
96
+ 'Duplicate output file: Both {} and {} map to {}' .format (
97
+ result [output_path ], input_file , output_path ))
98
+ result [output_path ] = input_file
94
99
95
- # By sorting the file list, the resulting ZIP file will not be reproducible
96
- # and deterministic.
97
- return sorted (result .items ())
100
+ return result
98
101
99
102
100
103
def copy_jdk_into_archive (output_zip , archive_file , input_file ):
@@ -124,7 +127,9 @@ def main():
124
127
zipinfo .external_attr = 0o644 << 16
125
128
output_zip .writestr (zipinfo , 'workspace(name = "bazel_tools")\n ' )
126
129
127
- for archive_file , input_file in input_files :
130
+ # By sorting the file list, the resulting ZIP file will be reproducible and
131
+ # deterministic.
132
+ for archive_file , input_file in sorted (input_files .items ()):
128
133
if os .path .basename (archive_file ) in ('jdk.tar.gz' , 'jdk.zip' ):
129
134
copy_jdk_into_archive (output_zip , archive_file , input_file )
130
135
else :
0 commit comments