-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathgenerate_checker.py
More file actions
executable file
·64 lines (52 loc) · 1.77 KB
/
generate_checker.py
File metadata and controls
executable file
·64 lines (52 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
Copyright (C) 2024 Intel Corporation
SPDX-License-Identifier: MIT
"""
import os
import re
import util
import argparse
templates_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "templates/checker/")
"""
generates checker files from the templates
"""
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("name", type=str, help="Name of your Validation Layer checker in the form of 'CheckerName'.")
parser.add_argument("out_dir", type=str, help="Root of the loader repository.")
args = parser.parse_args()
name = args.name
env_name = name.upper()
srcpath = os.path.join(args.out_dir, "source/layers/validation/checkers/")
srcpath = os.path.join(srcpath, name)
if not os.path.exists(srcpath):
os.makedirs(srcpath)
print("Generating Checker Template for %s\n" %(name))
loc = 0
template = "template.h.mako"
fin = os.path.join(templates_dir, template)
filename = "zel_%s_checker.h"%(name)
fout = os.path.join(srcpath, filename)
print("Generating %s..."%fout)
loc += util.makoWrite(
fin, fout,
name=name)
template = "template.cpp.mako"
fin = os.path.join(templates_dir, template)
filename = "zel_%s_checker.cpp"%(name)
fout = os.path.join(srcpath, filename)
print("Generating %s..."%fout)
loc += util.makoWrite(
fin, fout,
name=name,
env_name=env_name)
template = "template.cmake.mako"
fin = os.path.join(templates_dir, template)
filename = "CMakeLists.txt"
fout = os.path.join(srcpath, filename)
print("Generating %s..."%fout)
loc += util.makoWrite(
fin, fout,
name=name,
TARGET_NAME="${TARGET_NAME}",
CMAKE_CURRENT_LIST_DIR="${CMAKE_CURRENT_LIST_DIR}")