コード例 #1
0
def parseOutput(output, lines):
    '''
    Parse error output lines from FXC, 
    map them to the original source code location and output
    an error message compatible with Xcode or VStudio
    '''
    hasError = False
    hasWarning = False
    outLines = output.splitlines()

    for outLine in outLines:

        # extract generated shader source column, line and message
        # format is 'filename(line,startcol-endcol): msg
        lineStartIndex = outLine.find('(', 0) + 1
        if lineStartIndex == 0:
            continue
        lineEndIndex = outLine.find(',', lineStartIndex)
        if lineEndIndex == -1:
            continue
        colStartIndex = lineEndIndex + 1
        colEndIndex = outLine.find('-', colStartIndex)
        if colEndIndex == -1:
            colEndIndex = outLine.find(')', colStartIndex)
            if colEndIndex == -1:
                continue
        msgStartIndex = outLine.find(':', colStartIndex + 1)
        if msgStartIndex == -1:
            continue

        colNr = int(outLine[colStartIndex:colEndIndex])
        lineNr = int(outLine[lineStartIndex:lineEndIndex])
        msg = outLine[msgStartIndex:]

        # map to original location
        lineIndex = lineNr - 1
        if lineIndex >= len(lines):
            lineIndex = len(lines) - 1
        srcPath = lines[lineIndex].path
        srcLineNr = lines[lineIndex].lineNumber

        # and output...
        util.setErrorLocation(srcPath, srcLineNr)
        if 'error' in outLine:
            hasError = True
            util.fmtError(msg, False)
        elif 'warning' in outLine:
            hasWarning = True
            util.fmtWarning(msg)

    if hasError:
        for line in lines:
            print(line.content)
        sys.exit(10)
コード例 #2
0
ファイル: hlslcompiler.py プロジェクト: aonorin/oryol
def parseOutput(output, lines) :
    '''
    Parse error output lines from FXC, 
    map them to the original source code location and output
    an error message compatible with Xcode or VStudio
    '''
    hasError = False
    hasWarning = False
    outLines = output.splitlines()

    for outLine in outLines :

        # extract generated shader source column, line and message
        # format is 'filename(line,startcol-endcol): msg
        lineStartIndex = outLine.find('(', 0) + 1
        if lineStartIndex == 0 :
            continue
        lineEndIndex = outLine.find(',', lineStartIndex)
        if lineEndIndex == -1 :
            continue
        colStartIndex = lineEndIndex + 1
        colEndIndex = outLine.find('-', colStartIndex)
        if colEndIndex == -1 :
            colEndIndex = outLine.find(')', colStartIndex)
            if colEndIndex == -1 :
                continue
        msgStartIndex = outLine.find(':', colStartIndex+1)
        if msgStartIndex == -1 :
            continue

        colNr = int(outLine[colStartIndex:colEndIndex])
        lineNr = int(outLine[lineStartIndex:lineEndIndex])
        msg = outLine[msgStartIndex:]

        # map to original location
        lineIndex = lineNr - 1
        if lineIndex >= len(lines) :
            lineIndex = len(lines) - 1
        srcPath = lines[lineIndex].path
        srcLineNr = lines[lineIndex].lineNumber
        
        # and output...
        util.setErrorLocation(srcPath, srcLineNr)
        if 'error' in outLine :
            hasError = True
            util.fmtError(msg, False)
        elif 'warning' in outLine :
            hasWarning = True
            util.fmtWarning(msg)

    if hasError :
        for line in lines :
            print(line.content)
        sys.exit(10) 
コード例 #3
0
ファイル: metalcompiler.py プロジェクト: UIKit0/oryol
def validate(platform, lines, outPath, c_name):

    if platform != 'ios' and platform != 'osx':
        return

    # test if tools exists
    if not get_tool(platform, 'metal'):
        util.fmtWarning('metal compiler not found\n')
        return
    if not get_tool(platform, 'metal-ar'):
        util.fmtWarning('metal librarian not found\n')
        return
    if not get_tool(platform, 'metallib'):
        util.fmtWarning('metal linker not found\n')
        return

    # filenames
    rootPath = os.path.splitext(outPath)[0]
    metal_src_path = rootPath + '.metal'
    metal_dia_path = rootPath + '.dia'
    metal_air_path = rootPath + '.air'
    metal_lib_path = rootPath + '.metal-ar'
    metal_bin_path = rootPath + '.metallib'
    c_header_path = rootPath + '.metallib.h'

    # write metal source file
    with open(metal_src_path, 'w') as f:
        writeFile(f, lines)

    # compile .metal source file
    output = cc(platform, metal_src_path, metal_dia_path, metal_air_path)
    parseOutput(output, lines)
    output += ar(platform, metal_air_path, metal_lib_path)
    output += link(platform, metal_lib_path, metal_bin_path)
    writeBinHeader(metal_bin_path, c_header_path, c_name)
コード例 #4
0
ファイル: metalcompiler.py プロジェクト: kroisos/oryol
def validate(lines, outPath, c_name) :
    
    # test if tools exists
    if not get_tool('metal') :
        util.fmtWarning('metal compiler not found\n')
        return
    if not get_tool('metal-ar') :
        util.fmtWarning('metal librarian not found\n')
        return
    if not get_tool('metallib') :
        util.fmtWarning('metal linker not found\n')
        return

    # filenames
    rootPath = os.path.splitext(outPath)[0]
    metal_src_path = rootPath + '.metal'
    metal_dia_path = rootPath + '.dia'
    metal_air_path = rootPath + '.air'
    metal_lib_path = rootPath + '.metal-ar'
    metal_bin_path = rootPath + '.metallib'
    c_header_path  = rootPath + '.metallib.h'

    # write metal source file
    with open(metal_src_path, 'w') as f :
        writeFile(f, lines)

    # compile .metal source file
    output = cc(metal_src_path, metal_dia_path, metal_air_path)
    parseOutput(output, lines)
    output += ar(metal_air_path, metal_lib_path)
    output += link(metal_lib_path, metal_bin_path)
    writeBinHeader(metal_bin_path, c_header_path, c_name)
コード例 #5
0
def compile(lines, base_path, c_name, args):

    platform = util.getEnv('target_platform')
    if platform != 'ios' and platform != 'osx':
        return

    # test if tools exists
    if not get_tool(platform, 'metal'):
        util.fmtWarning('metal compiler not found\n')
        return
    if not get_tool(platform, 'metal-ar'):
        util.fmtWarning('metal librarian not found\n')
        return
    if not get_tool(platform, 'metallib'):
        util.fmtWarning('metal linker not found\n')
        return

    # filenames
    metal_src_path = base_path + '.metal'
    metal_dia_path = base_path + '.dia'
    metal_air_path = base_path + '.air'
    metal_lib_path = base_path + '.metal-ar'
    metal_bin_path = base_path + '.metallib'
    c_header_path = base_path + '.metallib.h'

    # compile .metal source file
    output = cc(platform, metal_src_path, metal_dia_path, metal_air_path)
    parseOutput(output, lines)
    output += ar(platform, metal_air_path, metal_lib_path)
    output += link(platform, metal_lib_path, metal_bin_path)
    writeBinHeader(metal_bin_path, c_header_path, c_name)
コード例 #6
0
def generate(input, out_src, out_hdr, args) :    
    shaderc_path = input
    if not os.path.isfile(shaderc_path) :
        genutil.fmtWarning("Can't find shaderbatcher, ignoring shaders")
    else :
        run_shaderc(shaderc_path, args)