🐛 Fixed shadergen unable to find tools

This commit is contained in:
Edgar 2023-09-24 11:28:32 +02:00
parent 562f0a2021
commit e8c50c87cf
No known key found for this signature in database
GPG key ID: 3C2E1F2C1C353131
3 changed files with 43 additions and 32 deletions

View file

@ -380,6 +380,8 @@ macro(AUTOSCRIBE_SHADER_LIB)
endmacro()
macro(AUTOSCRIBE_SHADER_LIBS)
include(${CMAKE_BINARY_DIR}/cmake/ConanToolsDirs.cmake)
message(STATUS "Shader processing start")
set(AUTOSCRIBE_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/headers)
# Start the shader IDs
@ -431,13 +433,17 @@ macro(AUTOSCRIBE_SHADER_LIBS)
endif()
endif()
# A custom python script which will generate all our shader artifacts
add_custom_command(
OUTPUT ${SCRIBED_SHADERS} ${SPIRV_SHADERS} ${REFLECTED_SHADERS}
COMMENT "Generating/updating shaders"
COMMAND python ${CMAKE_SOURCE_DIR}/tools/shadergen.py
--commands ${AUTOSCRIBE_SHADERGEN_COMMANDS_FILE}
--tools-dir ${CMAKE_BINARY_DIR}/bin #${VCPKG_TOOLS_DIR}
--glslang "${GLSLANG_DIR}/glslangValidator"
--scribe "${SCRIBE_DIR}/scribe"
--spirv-cross "${SPIRV_CROSS_DIR}/spirv-cross"
--spirv-opt "${SPIRV_TOOLS_DIR}/spirv-opt"
--build-dir ${CMAKE_CURRENT_BINARY_DIR}
--source-dir ${CMAKE_SOURCE_DIR}
${EXTRA_SHADERGEN_ARGS}

View file

@ -1,6 +1,7 @@
import os
from conan import ConanFile
from conan.tools.files import copy
from conan.tools.files import copy, save
class Overte(ConanFile):
name = "Overte"
@ -58,12 +59,29 @@ class Overte(ConanFile):
# webrtc
self.requires("zlib/1.2.13")
# def generate(self):
# for dep in self.dependencies.values():
# for f in dep.cpp_info.bindirs:
# copy(self, "*.exe", f, os.path.join(self.build_folder, "bin"))
def generate(self):
bindirs = []
for dep in self.dependencies.values():
bindirs += dep.cpp_info.bindirs
save(
self,
os.path.join(self.build_folder, "cmake", "ConanBinDirs.cmake"),
'set(CONAN_BIN_DIRS "%s")' % ";".join(bindirs).replace('\\', '/'),
)
def cp_data(self, src):
bindir = os.path.join(self.build_folder, "bin")
copy(self, "*.exe", src, bindir)
# copy(self, "*.so*", src, bindir, False)
toolspath = """
set(GLSLANG_DIR "%s")
set(SCRIBE_DIR "%s/tools")
set(SPIRV_CROSS_DIR "%s")
set(SPIRV_TOOLS_DIR "%s")
""" % (
";".join(self.dependencies["glslang"].cpp_info.bindirs).replace('\\', '/'),
self.dependencies["scribe"].package_folder.replace('\\', '/'),
";".join(self.dependencies["spirv-cross"].cpp_info.bindirs).replace('\\', '/'),
";".join(self.dependencies["spirv-tools"].cpp_info.bindirs).replace('\\', '/'),
)
save(
self,
os.path.join(self.build_folder, "cmake", "ConanToolsDirs.cmake"),
toolspath,
)

View file

@ -39,7 +39,7 @@ def getTypeForScribeFile(scribefilename):
return switcher.get(extension)
def getCommonScribeArgs(scribefile, includeLibs):
scribeArgs = [os.path.join(args.tools_dir, 'scribe')]
scribeArgs = [args.scribe] # args.scribe is the executable
# FIXME use the sys.platform to set the correct value
scribeArgs.extend(['-D', 'GLPROFILE', 'PC_GL'])
scribeArgs.extend(['-T', getTypeForScribeFile(scribefile)])
@ -166,9 +166,9 @@ folderMutex = Lock()
def processCommand(line):
global args
global scribeDepCache
glslangExec = args.tools_dir + '/glslangValidator'
spirvCrossExec = args.tools_dir + '/spirv-cross'
spirvOptExec = args.tools_dir + '/spirv-opt'
glslangExec = args.glslang
spirvCrossExec = args.spirv_cross
spirvOptExec = args.spirv_opt
params = line.split(';')
dialect = params.pop(0)
variant = params.pop(0)
@ -261,7 +261,10 @@ def main():
parser = ArgumentParser(description='Generate shader artifacts.')
parser.add_argument('--extensions', type=str, nargs='*', help='Available extensions for the shaders')
parser.add_argument('--commands', type=argparse.FileType('r'), help='list of commands to execute')
parser.add_argument('--tools-dir', type=str, help='location of the host compatible binaries')
parser.add_argument('--glslang', type=str, help='location of glslangValidator')
parser.add_argument('--scribe', type=str, help='location of scribe')
parser.add_argument('--spirv-cross', type=str, help='location of spirv-cross')
parser.add_argument('--spirv-opt', type=str, help='location of spirv-opt')
parser.add_argument('--build-dir', type=str, help='The build directory base path')
parser.add_argument('--source-dir', type=str, help='The root directory of the git repository')
parser.add_argument('--debug', action='store_true')
@ -269,23 +272,7 @@ parser.add_argument('--force', action='store_true', help='Ignore timestamps and
parser.add_argument('--dry-run', action='store_true', help='Report the files that would be process, but do not output')
args = None
if len(sys.argv) == 1:
# for debugging
sourceDir = expanduser('~/git/hifi')
toolsDir = 'd:/hifi/vcpkg/android/fd82f0a8/installed/x64-windows/tools'
buildPath = sourceDir + '/build_android'
commandsPath = buildPath + '/libraries/shaders/shadergen.txt'
shaderDir = buildPath + '/libraries/shaders'
testArgs = '--commands {} --tools-dir {} --build-dir {} --source-dir {}'.format(
commandsPath, toolsDir, shaderDir, sourceDir
).split()
testArgs.append('--debug')
testArgs.append('--force')
testArgs.extend('--extensions EXT_clip_cull_distance'.split())
#testArgs.append('--dry-run')
args = parser.parse_args(testArgs)
else:
args = parser.parse_args()
args = parser.parse_args()
scribeDepCache = ScribeDependenciesCache(args.build_dir + '/shaderDeps.json')
scribeDepCache.load()