blob: 77990c2ea5d548088680fba8ebccbf5fde2b5f31 [file] [log] [blame]
Jamie Madill0448ec82016-12-23 13:41:47 -05001#!/usr/bin/python
2#
3# Copyright 2016 The ANGLE Project Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6#
7# generate_vulkan_layers_json.py:
8# Generate copies of the Vulkan layers JSON files, with no paths, forcing
9# Vulkan to use the default search path to look for layers.
10
11import os, sys, json, glob
12
Jamie Madill93780e62017-01-31 15:38:26 -050013if len(sys.argv) != 3:
Jamie Madill0448ec82016-12-23 13:41:47 -050014 print("Usage: " + sys.argv[0] + " <source_dir> <target_dir>")
15 sys.exit(1)
16
17source_dir = sys.argv[1]
18target_dir = sys.argv[2]
19
20if not os.path.isdir(source_dir):
21 print(source_dir + " is not a directory.")
22 sys.exit(1)
23
24if not os.path.exists(target_dir):
25 os.makedirs(target_dir)
26
27for json_fname in glob.glob(os.path.join(source_dir, "*.json")):
28 with open(json_fname) as infile:
29 data = json.load(infile)
30
31 # update the path
32 prev_name = os.path.basename(data['layer']['library_path'])
33 data['layer']['library_path'] = prev_name
34
35 target_fname = os.path.join(target_dir, os.path.basename(json_fname))
36 with open(target_fname, "w") as outfile:
37 json.dump(data, outfile)