Path: blob/21.2-virgl/src/gallium/drivers/swr/rasterizer/codegen/gen_knobs.py
4574 views
# Copyright (C) 2014-2018 Intel Corporation. All Rights Reserved.1#2# Permission is hereby granted, free of charge, to any person obtaining a3# copy of this software and associated documentation files (the "Software"),4# to deal in the Software without restriction, including without limitation5# the rights to use, copy, modify, merge, publish, distribute, sublicense,6# and/or sell copies of the Software, and to permit persons to whom the7# Software is furnished to do so, subject to the following conditions:8#9# The above copyright notice and this permission notice (including the next10# paragraph) shall be included in all copies or substantial portions of the11# Software.12#13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING18# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS19# IN THE SOFTWARE.2021# Python source22from __future__ import print_function23import os24import sys25import knob_defs26from gen_common import *2728def main(args=sys.argv[1:]):2930# parse args31parser = ArgumentParser()32parser.add_argument("--output", "-o", help="Path to output file", required=True)33parser.add_argument("--gen_h", "-gen_h", help="Generate gen_knobs.h", action="store_true", default=False)34parser.add_argument("--gen_cpp", "-gen_cpp", help="Generate gen_knobs.cpp", action="store_true", required=False)3536args = parser.parse_args()3738cur_dir = os.path.dirname(os.path.abspath(__file__))39template_cpp = os.path.join(cur_dir, 'templates', 'gen_knobs.cpp')40template_h = os.path.join(cur_dir, 'templates', 'gen_knobs.h')4142output_filename = os.path.basename(args.output)43output_dir = MakeTmpDir('_codegen')4445output_file = os.path.join(output_dir, output_filename)4647rval = 04849try:50if args.gen_h:51MakoTemplateWriter.to_file(52template_h,53output_file,54cmdline=sys.argv,55filename='gen_knobs',56knobs=knob_defs.KNOBS)5758if args.gen_cpp:59MakoTemplateWriter.to_file(60template_cpp,61output_file,62cmdline=sys.argv,63filename='gen_knobs',64knobs=knob_defs.KNOBS,65includes=['core/knobs_init.h', 'common/os.h', 'sstream', 'iomanip'])6667rval = CopyFileIfDifferent(output_file, args.output)6869except:70rval = 17172finally:73# ignore errors from delete of tmp directory74DeleteDirTree(output_dir)7576return 07778if __name__ == '__main__':79sys.exit(main())80818283