def generate(self) : self.vox_file = os.path.dirname(self.input) + '/' + self.vox_file if util.isDirty(Version, [self.input, self.vox_file], [self.out_src, self.out_hdr]) : self.load() self.reduce_palette() self.runlength_encode() self.gen_header(self.out_hdr) self.gen_source(self.out_src)
def generate(input, out_src, out_hdr): if genutil.isDirty(Version, [input], [out_src, out_hdr]): proc = subprocess.Popen([get_generator_path()], stdout=subprocess.PIPE) function_name, std_err = proc.communicate() print "GENERATING FUNCTION: " + function_name generateHeader(out_hdr, function_name) generateSource(out_src, function_name)
def generate(input, out_src, out_hdr) : if genutil.isDirty(Version, [input], [out_src, out_hdr]) : proc = subprocess.Popen([get_generator_path()], stdout=subprocess.PIPE) function_name, std_err = proc.communicate() print "GENERATING FUNCTION: " + function_name generateHeader(out_hdr, function_name) generateSource(out_src, function_name)
def generate(self) : selfPath = self.directory + self.name + '.py' hdrPath = self.directory + self.name + '.h' srcPath = self.directory + self.name + '.cc' if util.isDirty([selfPath, self.imagePath], Version, hdrPath, srcPath) : self.loadImage() self.genHeader(hdrPath) self.genSource(srcPath)
def generate(input, out_src, out_hdr, func_name, msg) : if util.isDirty(Version, [input], [out_src, out_hdr]) : print('## generating {}'.format(out_hdr)) generateHeader(func_name, msg, out_hdr) print('## generating {}'.format(out_src)) generateSource(func_name, msg, out_src) else : print('## nothing to do for {}'.format(input))
def generate(input, out_src, out_hdr, func_name, msg): if util.isDirty(Version, [input], [out_src, out_hdr]): print('## generating {}'.format(out_hdr)) generateHeader(func_name, msg, out_hdr) print('## generating {}'.format(out_src)) generateSource(func_name, msg, out_src) else: print('## nothing to do for {}'.format(input))
def generate(input, out_src, out_hdr, out_body): if genutil.isDirty(Version, [input], [out_hdr]): with open(input, 'r', encoding="utf-8") as f: desc = yaml.load(f) if 'src_dir' in desc: src_dir = desc['src_dir'] + '/' else: src_dir = '' gen_header(out_hdr, out_body, src_dir, desc['files'])
def generate(self): self.vox_file = os.path.dirname(self.input) + '/' + self.vox_file if util.isDirty(Version, [self.input, self.vox_file], [self.out_src, self.out_hdr]): self.load() self.reduce_palette() self.runlength_encode() self.gen_header(self.out_hdr) self.gen_source(self.out_src)
def generate(input, out_src, out_hdr) : if util.isDirty(Version, [input], [out_src, out_hdr]) : shaderLibrary = ShaderLibrary([input]) shaderLibrary.parseSources() shaderLibrary.resolveAllDependencies() shaderLibrary.generateShaderSources() shaderLibrary.validateShaders() generateSource(out_src, shaderLibrary) generateHeader(out_hdr, shaderLibrary)
def generate(input_file, out_src, out_hdr): """ :param input_file: flatbuffers fbs file :param out_src: must be None :param out_hdr: path for output header files """ if genutil.isDirty(Version, [input_file], [out_hdr]): flatc_path = get_flatc_path() run_flatc(input_file, out_hdr)
def generate(input, out_src, out_hdr): if util.isDirty(Version, [input], [out_src, out_hdr]): shaderLibrary = ShaderLibrary([input]) shaderLibrary.parseSources() shaderLibrary.resolveAllDependencies() shaderLibrary.generateShaderSources() shaderLibrary.validateShaders() generateSource(out_src, shaderLibrary) generateHeader(out_hdr, shaderLibrary)
def generate(input, out_src, out_hdr, args): if util.isDirty(Version, [input], [out_src, out_hdr]): slangs = slVersions[args['slang']] shaderLibrary = ShaderLibrary([input]) shaderLibrary.parseSources() shaderLibrary.generateShaderSources() shaderLibrary.compile(input, out_hdr, slangs, args) shaderLibrary.validate(slangs) generateSource(out_src, shaderLibrary, slangs) generateHeader(out_hdr, shaderLibrary, slangs)
def generate(directory, name, desc) : selfPath = directory + name + '.py' hdrPath = directory + name + '.h' srcPath = directory + name + '.cc' if util.isDirty([selfPath], Version, hdrPath, srcPath) : print '## generating {}'.format(hdrPath) generateHeader(desc, hdrPath) print '## generating {}'.format(srcPath) generateSource(desc, srcPath) else : print '## nothing to do for {}'.format(selfPath)
def generate(input, out_src, out_hdr, args): errfmt = 'msvc' if args['compiler'] == 'MSVC' else 'gcc' if util.isDirty(Version, [input], [out_hdr]): print('## sokol-shdc: {} {}'.format(input, args['slang'])) cmd = [ find_shdc(), '--input', input, '--output', out_hdr, '--slang', args['slang'], '--genver', str(Version), '--errfmt', errfmt, '--format', 'sokol', '--bytecode' ] res = subprocess.call(cmd) if res != 0: log.error('sokol-shdc returned with error code {}'.format(res))
def generate(input, out_src, out_hdr): if not util.isDirty(Version, [input], [out_src, out_hdr]): return idlc = IDLC.IDLCodeGenerator() idlc.SetVersion(Version) idlc.SetDocument(input) generateSource = idlc.GenerateHeader(out_hdr) # reset document idlc.SetDocument(input) idlc.GenerateSource(out_src, out_hdr)
def generate(self) : selfPath = self.directory + self.name + '.py' hdrPath = self.directory + self.name + '.h' srcPath = self.directory + self.name + '.cc' if util.isDirty([selfPath, self.imagePath], Version, hdrPath, srcPath) : print '## loading {}'.format(self.imagePath) self.loadImage() print '## generating {}'.format(hdrPath) self.genHeader(hdrPath) print '## generating {}'.format(srcPath) self.genSource(srcPath) else : print '## nothing to do for {}'.format(selfPath)
def generate(self): selfPath = self.directory + self.name + '.py' hdrPath = self.directory + self.name + '.h' srcPath = self.directory + self.name + '.cc' if util.isDirty([selfPath, self.imagePath], Version, hdrPath, srcPath): print '## loading {}'.format(self.imagePath) self.loadImage() print '## generating {}'.format(hdrPath) self.genHeader(hdrPath) print '## generating {}'.format(srcPath) self.genSource(srcPath) else: print '## nothing to do for {}'.format(selfPath)
def generate(input_file, out_src, out_hdr) : """ :param input: bgfx .sc file :param out_src: must be None :param out_hdr: path of output header file """ if not os.path.isfile(out_hdr) or genutil.isDirty(Version, [input_file], [out_hdr]): # deduce shader type base_file = os.path.basename(input_file) shader_type = None if base_file.startswith("vs_"): shader_type = "vertex" if base_file.startswith("fs_"): shader_type = "fragment" if base_file.startswith("cs_"): shader_type = "compute" if not shader_type: log.error("Could not identify shader type, please use prefix vs_, fs_ or cs_ on file " + input_file) return # source to bgfx shader compiler shaderc_path = get_shaderc_path() include_path = get_include_path() basename = get_basename(input_file) glsl = BuildShaderTask(input_file, 'glsl', 'linux', shader_type, None, basename) mtl = BuildShaderTask(input_file, 'mtl', 'ios', shader_type, None, basename) dx9 = BuildShaderTask(input_file, 'dx9', 'windows', shader_type, 'vs_3_0' if shader_type == 'vertex' else 'ps_3_0', basename) dx11 = BuildShaderTask(input_file, 'dx11', 'windows', shader_type, 'vs_4_0' if shader_type == 'vertex' else 'cs_5_0' if shader_type == 'compute' else 'ps_4_0', basename) glsl.start() mtl.start() dx9.start() dx11.start() glsl.join() mtl.join() dx9.join() dx11.join() contents = glsl.contents + mtl.contents + dx9.contents + dx11.contents if len(contents): with open(out_hdr, 'w') as f: contents = "// #version:{}#\n".format(Version) + contents f.write(contents)
def generate(input, out_src, out_hdr): if genutil.isDirty(Version, [input], [out_hdr]): with open(input, 'r') as f: desc = yaml.load(f) prefix = 'embed_' src_dir = '' list_items = False if 'options' in desc: opts = desc['options'] if 'prefix' in opts: prefix = opts['prefix'] if 'src_dir' in opts: src_dir = opts['src_dir'] + '/' if 'list_items' in opts: list_items = opts['list_items'] gen_header(out_hdr, src_dir, desc['files'], prefix, list_items)
def generate(input, out_src, out_hdr): with open(input, 'r') as f: desc = yaml.load(f) if 'src_dir' in desc: src_dir = desc['src_dir'] + '/' else: src_dir = '' files = desc['files'] input_files = [input] for file in files: input_files.append(get_file_path(file, src_dir, out_hdr)) if genutil.isDirty(Version, input_files, [out_hdr]): as_text = False if 'as_text' in desc: as_text = desc['as_text'] gen_header(out_hdr, src_dir, files, as_text)
def generate(directory, fileName, shdName, dirs) : selfPath = directory + fileName + '.py' hdrPath = directory + fileName + '.h' srcPath = directory + fileName + '.cc' files = gatherShaderSources(directory, dirs) files.append(selfPath) if util.isDirty(files, Version, hdrPath, srcPath) : shaderLibrary = ShaderLibrary(directory, shdName, dirs) shaderLibrary.parseSources() shaderLibrary.resolveAllDependencies() shaderLibrary.generateShaderSources() shaderLibrary.validateShaders() print '## generating {}'.format(hdrPath) generateHeader(hdrPath, shaderLibrary) print '## generating {}'.format(srcPath) generateSource(srcPath, shaderLibrary) else : print '## nothing to do for {}'.format(selfPath)
def generate(directory, fileName, shdName, dirs): selfPath = directory + fileName + '.py' hdrPath = directory + fileName + '.h' srcPath = directory + fileName + '.cc' files = gatherShaderSources(directory, dirs) files.append(selfPath) if util.isDirty(files, Version, hdrPath, srcPath): shaderLibrary = ShaderLibrary(directory, shdName, dirs) shaderLibrary.parseSources() shaderLibrary.resolveAllDependencies() shaderLibrary.generateShaderSources() shaderLibrary.validateShaders() print '## generating {}'.format(hdrPath) generateHeader(hdrPath, shaderLibrary) print '## generating {}'.format(srcPath) generateSource(srcPath, shaderLibrary) else: print '## nothing to do for {}'.format(selfPath)
def generate(input, out_src, out_hdr, args): out_tex = input + '.basis' inputs = [input] if (os.path.exists(out_tex)) : inputs.append(out_tex) texop = args['texop'] if 'texop' in args else None if util.isDirty(Version, inputs, [out_hdr]) or not os.path.exists(out_tex) or fileFormatDirty(out_hdr, texop): print('## basisu: {} {}'.format(input, texop)) cmd = [find_basisu(), '-file', input, '-output_file', out_tex, ] if texop != None: ops = texop.split(' ') for i in range(len(ops)): cmd.insert(1 + i, ops[i]) print(cmd) print(args) res = subprocess.call(cmd) if res != 0: log.error('basisu returned with error code {}'.format(res)) else: generateHeader(out_hdr, texop)
def generate(input, out_src, out_hdr): if genutil.isDirty(Version, [input], [out_hdr]): with open(input, 'r') as f: desc = yaml.load(f) gen_header(out_hdr, desc['files'])
def generate(input, out_src, out_hdr) : if util.isDirty(Version, [input], [out_src, out_hdr]) : with open(input, 'r') as f : desc = yaml.load(f) generateHeader(desc, out_hdr) generateSource(desc, out_src)
def generate(input_file, out_src, out_hdr) : """ :param input: bgfx .sc file :param out_src: must be None :param out_hdr: path of output header file """ if not os.path.isfile(out_hdr) or genutil.isDirty(Version, [input_file], [out_hdr]): # deduce shader type base_file = os.path.basename(input_file) shader_type = None if base_file.startswith("vs_"): shader_type = "vertex" if base_file.startswith("fs_"): shader_type = "fragment" if base_file.startswith("cs_"): shader_type = "compute" if not shader_type: log.error("Could not identify shader type, please use prefix vs_, fs_ or cs_ on file " + input_file) return # source to bgfx shader compiler shaderc_path = get_shaderc_path() include_path = get_include_path() basename = get_basename(input_file) # call shader 3 times for glsl, dx9, dx11 into tmp files out_glsl = tempfile.mktemp(prefix='bgfx_glsl_shaderc_') out_dx9 = tempfile.mktemp(prefix='bgfx_dx9_shaderc_') out_dx11 = tempfile.mktemp(prefix='bgfx_dx11_shaderc_') # FIXME: the HLSL compiler is only supported on Windows platforms, # thus we would get incomplete .bin.h files on non-windows platforms... contents = "" print "Compiling", os.path.basename(input_file), "as", shader_type, "..." run_shaderc(input_file, out_glsl, 'linux', shader_type, None, basename+'_glsl') with open(out_glsl, 'r') as f: contents += f.read() if os_name == 'windows': run_shaderc(input_file, out_dx9, 'windows', shader_type, 'vs_3_0' if shader_type == 'vertex' else 'cs_5_0' if shader_type == 'compute' else 'ps_3_0', basename+'_dx9') run_shaderc(input_file, out_dx11, 'windows', shader_type, 'vs_4_0' if shader_type == 'vertex' else 'cs_5_0' if shader_type == 'compute' else 'ps_4_0', basename+'_dx11') with open(out_dx9, 'r') as f: contents += f.read() with open(out_dx11, 'r') as f: contents += f.read() else: contents += "\n" contents += "// built on {}, hlsl compiler not disponible\n".format(os_name) contents += "static const uint8_t {}_dx9[1] = {{ 0 }};\n\n".format(basename) contents += "// built on {}, hlsl compiler not disponible\n".format(os_name) contents += "static const uint8_t {}_dx11[1] = {{ 0 }};\n\n".format(basename) if len(contents): with open(out_hdr, 'w') as f: contents = "// #version:{}#\n".format(Version) + contents f.write(contents)
def generate(input, out_src, out_hdr) : if genutil.isDirty(Version, [input], [out_src, out_hdr]) : with open(input, 'r') as f : desc = yaml.load(f) gen_header(out_hdr, desc['files']) gen_source(out_src, desc['files'])
def generate(self) : if util.isDirty(Version, [self.input, self.imagePath], [self.out_src, self.out_hdr]) : self.loadImage() self.genHeader(self.out_hdr) self.genSource(self.out_src)
def generate(self): if util.isDirty(Version, [self.input, self.imagePath], [self.out_src, self.out_hdr]): self.loadImage() self.genHeader(self.out_hdr) self.genSource(self.out_src)
def generate(input, out_src, out_hdr): if genutil.isDirty(Version, [input], [out_hdr]): gen_header(input, out_hdr)
def generate(input, out_src, out_hdr, args): if util.isDirty(Version, [input], [out_src, out_hdr]): generateSource(out_src, args) generateHeader(out_hdr, args)
def check_dirty(src_root_path, input, out_hdr, yml): out_files = [out_hdr] in_files = [input] for filename in yml['files']: in_files.append(os.path.abspath(src_root_path + filename)) return util.isDirty(Version, in_files, out_files)
def generate(input_file, out_src, out_hdr) : """ :param input: bgfx .sc file :param out_src: must be None :param out_hdr: path of output header file """ if not os.path.isfile(out_hdr) or genutil.isDirty(Version, [input_file], [out_hdr]): # deduce shader type base_file = os.path.basename(input_file) shader_type = None if base_file.startswith("vs_"): shader_type = "vertex" if base_file.startswith("fs_"): shader_type = "fragment" if base_file.startswith("cs_"): shader_type = "compute" if not shader_type: log.error("Could not identify shader type, please use prefix vs_, fs_ or cs_ on file " + input_file) return # source to bgfx shader compiler shaderc_path = get_shaderc_path() include_path = get_include_path() basename = get_basename(input_file) # call shader 3 times for glsl, dx9, dx11 into tmp files out_glsl = tempfile.mktemp(prefix='bgfx_glsl_shaderc_') out_dx9 = tempfile.mktemp(prefix='bgfx_dx9_shaderc_') out_dx11 = tempfile.mktemp(prefix='bgfx_dx11_shaderc_') # FIXME: the HLSL compiler is only supported on Windows platforms, # thus we would get incomplete .bin.h files on non-windows platforms... contents = "" os_name = platform.system().lower() run_shaderc(input_file, out_glsl, 'linux', shader_type, None, basename+'_glsl') with open(out_glsl, 'r') as f: contents += f.read() if os_name == 'windows': run_shaderc(input_file, out_dx9, 'windows', shader_type, 'vs_3_0' if shader_type == 'vertex' else 'ps_3_0', basename+'_dx9') run_shaderc(input_file, out_dx11, 'windows', shader_type, 'vs_4_0' if shader_type == 'vertex' else 'ps_4_0', basename+'_dx11') with open(out_dx9, 'r') as f: contents += f.read() with open(out_dx11, 'r') as f: contents += f.read() else: contents += "\n" contents += "// built on {}, hlsl compiler not disponible\n".format(os_name) contents += "static const uint8_t {}_dx9[1] = {{ 0 }};\n\n".format(basename) contents += "// built on {}, hlsl compiler not disponible\n".format(os_name) contents += "static const uint8_t {}_dx11[1] = {{ 0 }};\n\n".format(basename) if len(contents): with open(out_hdr, 'w') as f: f.write(contents)
def generate(input, out_src, out_hdr) : if genutil.isDirty(Version, [input], [out_src]) : with open(out_src, 'w') as f: do_it(f)
def generate(input, out_src, out_hdr, args): if util.isDirty(Version, [input], [out_src]): parseSource(input) generateSource(out_src, args) generateConfig(args['cfg']) touch(out_hdr)