-
-
Notifications
You must be signed in to change notification settings - Fork 168
/
prune.py
61 lines (52 loc) · 1.51 KB
/
prune.py
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
import glob
import argparse
import os
languages = {
'GLSL': {
'ext': 'glsl',
'frameworks': ["OpenGL", "WebGL", "Vulkan"],
},
'HLSL': {
'ext': 'hlsl',
'frameworks': [ "DirectX" ],
},
'METAL': {
'ext': 'msl',
'frameworks': [ "Metal" ],
},
'WGSL': {
'ext': 'wgsl',
'frameworks': [ "WebGPU" ],
},
'CUDA': {
'ext': 'cuh',
'frameworks': [ "CUDA" ],
},
}
def getAll(extension: str):
list = []
for file in glob.glob("**/*." + extension, recursive = True):
list.append(file);
list.sort()
return list
if __name__ == "__main__":
argparser = argparse.ArgumentParser(description='Prune one or multiple shader languages.')
argparser.add_argument('--all', '-A', help='Prune all shader languages', action='store_true')
argparser.add_argument('--keep', '-k', type=str, help='Keep only the specified shader language')
argparser.add_argument('--remove', '-r', type=str, help='Remove the specified shader language')
args = argparser.parse_args()
prune = []
if args.all:
prune = list(languages.keys())
if args.keep:
keep_list = args.keep.upper().split(',')
print(keep_list)
for lang in keep_list:
if lang in prune:
prune.remove(lang)
if args.remove:
prune.append(args.remove)
print(f"Pruning: {prune}")
for lang in prune:
for file in getAll(languages[lang]['ext']):
os.remove(file)