blob: e5fc773288330fd92b59e1ac6bb9b5e6af62a808 [file] [log] [blame]
Jeff Gilbert1b605ee2017-10-30 18:41:46 -07001#!/usr/bin/python2
Jamie Madill0448ec82016-12-23 13:41:47 -05002#
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
Jamie Madill8a57b462017-12-28 12:25:03 -050032 if not 'layer' in data:
33 raise Exception("Could not find a layer key in " + json_fname)
34
35 # The standard validation layer has no library path.
36 if 'library_path' in data['layer']:
37 prev_name = os.path.basename(data['layer']['library_path'])
38 data['layer']['library_path'] = prev_name
Jamie Madill0448ec82016-12-23 13:41:47 -050039
40 target_fname = os.path.join(target_dir, os.path.basename(json_fname))
41 with open(target_fname, "w") as outfile:
42 json.dump(data, outfile)