Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- if __name__ != "__main__": exit(0)
- from time import time
- from os import walk as folderIterate, system as cmd
- from os.path import isdir, exists, join as pathJoin
- from sys import argv
- #1st argument is one of these build modes
- #2nd argument is the output file name
- #the rest are input file names
- build_modes = {
- "-release" : "",
- "-debug" : "--no-renaming"
- }
- def getFilesInFolderRecursively(rootIn):
- paths = ''
- if not exists(rootIn): return None
- if not isdir(rootIn): return False
- for root, dirs, files in folderIterate(rootIn,topdown=True):
- for fi in files:
- paths += pathJoin(root,fi)+' '
- return paths
- if len(argv) < 4: exit()
- if not argv[1].lower() in build_modes:
- print("Error: \"{}\" is not a valid build mode!".format(argv[1]))
- exit(1)
- flags, paths = build_modes[argv[1]], ''
- #(starting at 3 because argv[2] is the OUTPUT file, not input)
- for i in range(3,len(argv)):
- paths += getFilesInFolderRecursively(argv[i])
- if type(paths) == bool:
- print("Error: \"{}\" is a file, not a folder!".format(argv[i]))
- exit(1)
- elif paths == None:
- print("Error: \"{}\" does not exist!".format(argv[i]))
- exit(1)
- elif type(paths) != str:
- print("Error: paths returned unknown type")
- exit(1)
- if paths != '':
- cmd("shader_minifier.exe {} -o {} {}".format(flags, argv[2], paths))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement