<commit_before>import sys, os

def find_path_of(filename, envvar='PATH'):
    """Finds the path from $PATH where the file exists, returns None if not found."""
    pathlist = os.getenv(envvar).split(os.pathsep)
    for path in pathlist:
        if os.path.exists(os.path.join(path, filename)):
            return os.path.abspath(path)
    return None

if sys.argv[1] == '--version':
    cmd = 'llvm-tblgen --version'
    # Hardcoded extraction, only tested on llvm 3.1
    result = os.popen(cmd).read().split('\n')[1].strip().split(' ')[2]
    print result
elif sys.argv[1] == '--libs':
    # NOTE: instead of actually looking at the components requested,
    #       we just spit out a bunch of libs
    for lib in """
LLVMAnalysis
LLVMAsmParser
LLVMAsmPrinter
LLVMBitReader
LLVMBitWriter
LLVMCodeGen
LLVMCore
LLVMExecutionEngine
LLVMInstCombine
LLVMInstrumentation
LLVMInterpreter
LLVMipa
LLVMipo
LLVMJIT
LLVMLinker
LLVMMC
LLVMMCParser
LLVMObject
LLVMRuntimeDyld
LLVMScalarOpts
LLVMSelectionDAG
LLVMSupport
LLVMTarget
LLVMTransformUtils
LLVMVectorize
LLVMX86AsmParser
LLVMX86AsmPrinter
LLVMX86CodeGen
LLVMX86Desc
LLVMX86Info
LLVMX86Utils
Advapi32
Shell32
""".split():
        print('-l%s' % lib)
    llvmbin = find_path_of('llvm-tblgen.exe')
    if os.path.exists(os.path.join(llvmbin, '../lib/LLVMPTXCodeGen.lib')):
        print('-lLLVMPTXAsmPrinter')
        print('-lLLVMPTXCodeGen')
        print('-lLLVMPTXDesc')
        print('-lLLVMPTXInfo')
elif sys.argv[1] == '--includedir': 
    llvmbin = find_path_of('llvm-tblgen.exe')<commit_msg>Detect and use NVPTX libraries on Windows<commit_after>import sys, os

def find_path_of(filename, envvar='PATH'):
    """Finds the path from $PATH where the file exists, returns None if not found."""
    pathlist = os.getenv(envvar).split(os.pathsep)
    for path in pathlist:
        if os.path.exists(os.path.join(path, filename)):
            return os.path.abspath(path)
    return None

if sys.argv[1] == '--version':
    cmd = 'llvm-tblgen --version'
    # Hardcoded extraction, only tested on llvm 3.1
    result = os.popen(cmd).read().split('\n')[1].strip().split(' ')[2]
    print result
elif sys.argv[1] == '--libs':
    # NOTE: instead of actually looking at the components requested,
    #       we just spit out a bunch of libs
    for lib in """
LLVMAnalysis
LLVMAsmParser
LLVMAsmPrinter
LLVMBitReader
LLVMBitWriter
LLVMCodeGen
LLVMCore
LLVMExecutionEngine
LLVMInstCombine
LLVMInstrumentation
LLVMInterpreter
LLVMipa
LLVMipo
LLVMJIT
LLVMLinker
LLVMMC
LLVMMCParser
LLVMObject
LLVMRuntimeDyld
LLVMScalarOpts
LLVMSelectionDAG
LLVMSupport
LLVMTarget
LLVMTransformUtils
LLVMVectorize
LLVMX86AsmParser
LLVMX86AsmPrinter
LLVMX86CodeGen
LLVMX86Desc
LLVMX86Info
LLVMX86Utils
Advapi32
Shell32
""".split():
        print('-l%s' % lib)
    llvmbin = find_path_of('llvm-tblgen.exe')
    if os.path.exists(os.path.join(llvmbin, '../lib/LLVMPTXCodeGen.lib')):
        print('-lLLVMPTXAsmPrinter')
        print('-lLLVMPTXCodeGen')
        print('-lLLVMPTXDesc')
        print('-lLLVMPTXInfo')
    elif os.path.exists(os.path.join(llvmbin, '../lib/LLVMNVPTXCodeGen.lib')):
        print('-lLLVMNVPTXAsmPrinter')
        print('-lLLVMNVPTXCodeGen')
        print('-lLLVMNVPTXDesc')
        print('-lLLVMNVPTXInfo')
elif sys.argv[1] == '--includedir': 
    llvmbin = find_path_of('llvm-tblgen.exe')
{'fraction_non_alphanumeric': 0.11826347305389222, 'fraction_numerical': 0.013772455089820359, 'mean_word_length': 3.906020558002937, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2089513', 'n_tokens_mistral': 1280, 'n_tokens_neox': 1252, 'n_words': 260}