Maintain header order in merge_csv am: 84c1cdf31f

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1731412

Change-Id: I593e0e23c166a1752c5419637579718b6a894232
This commit is contained in:
Paul Duffin
2021-06-10 11:51:33 +00:00
committed by Automerger Merge Worker
2 changed files with 4 additions and 4 deletions

View File

@@ -219,7 +219,6 @@ func buildRuleToGenerateIndex(ctx android.ModuleContext, desc string, classesJar
BuiltTool("merge_csv").
Flag("--zip_input").
Flag("--key_field signature").
FlagWithArg("--header=", "signature,file,startline,startcol,endline,endcol,properties").
FlagWithOutput("--output=", indexCSV).
Inputs(classesJars)
rule.Build(desc, desc)

View File

@@ -55,14 +55,15 @@ else:
if entry.endswith('.uau'):
csv_readers.append(dict_reader(io.TextIOWrapper(zip.open(entry, 'r'))))
headers = set()
if args.header:
fieldnames = args.header.split(',')
else:
headers = {}
# Build union of all columns from source files:
for reader in csv_readers:
headers = headers.union(reader.fieldnames)
fieldnames = sorted(headers)
for fieldname in reader.fieldnames:
headers[fieldname] = ""
fieldnames = list(headers.keys())
# By default chain the csv readers together so that the resulting output is
# the concatenation of the rows from each of them: