blob: e6b1113be505c51f20d84728ed0af160d097ab2b [file] [log] [blame]
#!/usr/bin/env python
# Copyright 2018 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 json
import os
import sys
sys.path.append(os.path.join(
os.path.dirname(__file__),
os.pardir,
"cpp",
))
import binaries
def main():
parser = argparse.ArgumentParser('Builds a metadata file')
parser.add_argument('--base',
help='Path to the base metadata file',
required=True)
parser.add_argument('--out',
help='Path to the output file',
required=True)
parser.add_argument('--lib-debug-file',
help='Path to the source debug version of the library',
required=True)
parser.add_argument('--debug-mapping',
help='Path to the file where to write the file mapping for the debug library',
required=True)
args = parser.parse_args()
# The path of the debug file in the SDK depends on its build id.
debug_path = binaries.get_sdk_debug_path(args.lib_debug_file)
with open(args.debug_mapping, 'w') as mappings_file:
mappings_file.write(debug_path + '=' + args.lib_debug_file + '\n')
with open(args.base, 'r') as base_file:
metadata = json.load(base_file)
metadata['binaries'].values()[0]['debug'] = debug_path
with open(args.out, 'w') as out_file:
json.dump(metadata, out_file, indent=2, sort_keys=True)
return 0
if __name__ == '__main__':
sys.exit(main())