blob: eedc94002faea2b772ac4d7cfc764c78f7acb4ff [file] [log] [blame]
#!/usr/bin/env python3.8
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import argparse
import hashlib
import json
import sys
# Builds a representation of the atom's "API" by computing hashes for the files
# that contribute to the atom's API.
# This is only meant to be provide a (very) rough signal of changes in an atom.
# Templates that generate sdk_atom instances should generate that file
# themselves instead.
def main():
parser = argparse.ArgumentParser()
help='A (destination <-- source) mapping',
'--output', help='The API file to generate', required=True)
args = parser.parse_args()
api = {}
for destination, source in args.file:
with open(source, 'r') as source_file:
hash = hashlib.md5('utf-8')).hexdigest()
api[destination] = hash
with open(args.output, 'w') as output_file:
# Specify `separators` to prevent whitespaces at the end of lines.
api, output_file, indent=2, sort_keys=True, separators=(',', ': '))
return 0
if __name__ == '__main__':