# -*- Python -*-

# Configuration file for the 'lit' test runner.

import os
import sys
import re
import platform

# name: The name of this test suite.
config.name = 'LLVM'

# Tweak PATH for Win32 to decide to use bash.exe or not.
if sys.platform in ['win32']:
    # Seek sane tools in directories and set to $PATH.
    path = getattr(config, 'lit_tools_dir', None)
    path = lit.getToolsPath(path,
                            config.environment['PATH'],
                            ['cmp.exe', 'grep.exe', 'sed.exe'])
    if path is not None:
        path = os.path.pathsep.join((path,
                                     config.environment['PATH']))
        config.environment['PATH'] = path

# testFormat: The test format to use to interpret tests.
execute_external = (not sys.platform in ['win32']
                    or lit.getBashPath() not in [None, ""])
config.test_format = lit.formats.ShTest(execute_external)

# To ignore test output on stderr so it doesn't trigger failures uncomment this:
#config.test_format = lit.formats.TclTest(ignoreStdErr=True)

# suffixes: A list of file extensions to treat as test files, this is actually
# set by on_clone().
config.suffixes = []

# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
# subdirectories contain auxiliary inputs for various tests in their parent
# directories.
config.excludes = ['Inputs']

# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)

# test_exec_root: The root path where tests should be run.
llvm_obj_root = getattr(config, 'llvm_obj_root', None)
if llvm_obj_root is not None:
    config.test_exec_root = os.path.join(llvm_obj_root, 'test')

# Tweak the PATH to include the scripts dir, the tools dir, and the llvm-gcc bin
# dir (if available).
if llvm_obj_root is not None:
    llvm_src_root = getattr(config, 'llvm_src_root', None)
    if not llvm_src_root:
        lit.fatal('No LLVM source root set!')
    path = os.path.pathsep.join((os.path.join(llvm_src_root, 'test',
                                              'Scripts'),
                                 config.environment['PATH']))
    config.environment['PATH'] = path

    llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
    if not llvm_tools_dir:
        lit.fatal('No LLVM tools dir set!')
    path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
    config.environment['PATH'] = path

# Propagate 'HOME' through the environment.
if 'HOME' in os.environ:
    config.environment['HOME'] = os.environ['HOME']

# Propagate 'INCLUDE' through the environment.
if 'INCLUDE' in os.environ:
    config.environment['INCLUDE'] = os.environ['INCLUDE']

# Propagate 'LIB' through the environment.
if 'LIB' in os.environ:
    config.environment['LIB'] = os.environ['LIB']

# Propagate the temp directory. Windows requires this because it uses \Windows\
# if none of these are present.
if 'TMP' in os.environ:
    config.environment['TMP'] = os.environ['TMP']
if 'TEMP' in os.environ:
    config.environment['TEMP'] = os.environ['TEMP']

# Propagate LLVM_SRC_ROOT into the environment.
config.environment['LLVM_SRC_ROOT'] = getattr(config, 'llvm_src_root', '')

# Propagate PYTHON_EXECUTABLE into the environment
config.environment['PYTHON_EXECUTABLE'] = getattr(config, 'python_executable',
                                                  '')

###

import os

# Check that the object root is known.
if config.test_exec_root is None:
    # Otherwise, we haven't loaded the site specific configuration (the user is
    # probably trying to run on a test file directly, and either the site
    # configuration hasn't been created by the build system, or we are in an
    # out-of-tree build situation).

    # Check for 'llvm_site_config' user parameter, and use that if available.
    site_cfg = lit.params.get('llvm_site_config', None)
    if site_cfg and os.path.exists(site_cfg):
        lit.load_config(config, site_cfg)
        raise SystemExit

    # Try to detect the situation where we are using an out-of-tree build by
    # looking for 'llvm-config'.
    #
    # FIXME: I debated (i.e., wrote and threw away) adding logic to
    # automagically generate the lit.site.cfg if we are in some kind of fresh
    # build situation. This means knowing how to invoke the build system
    # though, and I decided it was too much magic.

    llvm_config = lit.util.which('llvm-config', config.environment['PATH'])
    if not llvm_config:
        lit.fatal('No site specific configuration available!')

    # Get the source and object roots.
    llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip()
    llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip()

    # Validate that we got a tree which points to here.
    this_src_root = os.path.dirname(config.test_source_root)
    if os.path.realpath(llvm_src_root) != os.path.realpath(this_src_root):
        lit.fatal('No site specific configuration available!')

    # Check that the site specific configuration exists.
    site_cfg = os.path.join(llvm_obj_root, 'test', 'lit.site.cfg')
    if not os.path.exists(site_cfg):
        lit.fatal('No site specific configuration available!')

    # Okay, that worked. Notify the user of the automagic, and reconfigure.
    lit.note('using out-of-tree build at %r' % llvm_obj_root)
    lit.load_config(config, site_cfg)
    raise SystemExit

###

# Provide a command line for mcjit tests
lli_mcjit = 'lli -use-mcjit'
# The target triple used by default by lli is the process target triple (some
# triple appropriate for generating code for the current process) but because
# we don't support COFF in MCJIT well enough for the tests, force ELF format on
# Windows.  FIXME: the process target triple should be used here, but this is
# difficult to obtain on Windows.
if re.search(r'cygwin|mingw32|win32', config.host_triple):
  lli_mcjit += ' -mtriple='+config.host_triple+'-elf'
config.substitutions.append( ('%lli_mcjit', lli_mcjit) )

# Provide a substition for those tests that need to run the jit to obtain data
# but simply want use the currently considered most reliable jit for platform
# FIXME: ppc32 is not ready for mcjit.
if 'arm' in config.target_triple \
   or 'powerpc64' in config.target_triple:
    defaultIsMCJIT = 'true'
else:
    defaultIsMCJIT = 'false'
config.substitutions.append( ('%defaultjit', '-use-mcjit='+defaultIsMCJIT) )

# Process jit implementation option
jit_impl_cfg = lit.params.get('jit_impl', None)
if jit_impl_cfg == 'mcjit':
  # When running with mcjit, mangle -mcjit into target triple
  # and add -use-mcjit flag to lli invocation
  if 'i686' in config.target_triple:
    config.target_triple += jit_impl_cfg + '-ia32'
  elif 'x86_64' in config.target_triple:
    config.target_triple += jit_impl_cfg + '-ia64'
  else:
    config.target_triple += jit_impl_cfg

  config.substitutions.append( ('%lli', 'lli -use-mcjit') )
else:
  config.substitutions.append( ('%lli', 'lli') )

# Add site-specific substitutions.
config.substitutions.append( ('%ocamlopt', config.ocamlopt_executable) )
config.substitutions.append( ('%llvmshlibdir', config.llvm_shlib_dir) )
config.substitutions.append( ('%shlibext', config.llvm_shlib_ext) )

# For each occurrence of an llvm tool name as its own word, replace it
# with the full path to the build directory holding that tool.  This
# ensures that we are testing the tools just built and not some random
# tools that might happen to be in the user's PATH.  Thus this list
# includes every tool placed in $(LLVM_OBJ_ROOT)/$(BuildMode)/bin
# (llvm_tools_dir in lit parlance).
                # Don't match 'bugpoint-' or 'clang-'.
                # Don't match '/clang' or '-clang'.
if os.pathsep == ';':
    pathext = os.environ.get('PATHEXT', '').split(';')
else:
    pathext = ['']
for pattern in [r"\bbugpoint\b(?!-)",   r"(?<!/|-)\bclang\b(?!-)",
                r"\bgold\b",
                r"\bllc\b",             r"\blli\b",
                r"\bllvm-ar\b",         r"\bllvm-as\b",
                r"\bllvm-bcanalyzer\b", r"\bllvm-config\b",
                r"\bllvm-cov\b",        r"\bllvm-diff\b",
                r"\bllvm-dis\b",        r"\bllvm-dwarfdump\b",
                r"\bllvm-extract\b",    r"\bllvm-jistlistener\b",
                r"\bllvm-link\b",       r"\bllvm-mc\b",
                r"\bllvm-nm\b",         r"\bllvm-objdump\b",
                r"\bllvm-prof\b",       r"\bllvm-ranlib\b",
                r"\bllvm-rtdyld\b",     r"\bllvm-shlib\b",
                r"\bllvm-size\b",
                # Don't match '-llvmc'.
                r"(?<!-)\bllvmc\b",     r"\blto\b",
                                        # Don't match '.opt', '-opt',
                                        # '^opt' or '/opt'.
                r"\bmacho-dump\b",      r"(?<!\.|-|\^|/)\bopt\b",
                r"\bllvm-tblgen\b",     r"\bFileCheck\b",
                r"\bFileUpdate\b",      r"\bc-index-test\b",
                r"\bfpcmp\b",           r"\bllvm-PerfectShuffle\b",
                # Handle these specially as they are strings searched
                # for during testing.
                r"\| \bcount\b",         r"\| \bnot\b"]:
    # Extract the tool name from the pattern.  This relies on the tool
    # name being surrounded by \b word match operators.  If the
    # pattern starts with "| ", include it in the string to be
    # substituted.
    substitution = re.sub(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$",
                          r"\2" + llvm_tools_dir + "/" + r"\4",
                          pattern)
    for ext in pathext:
        substitution_ext = substitution + ext
        if os.path.exists(substitution_ext):
             substitution = substitution_ext
             break
    config.substitutions.append((pattern, substitution))

### Features

# Shell execution
if sys.platform not in ['win32'] or lit.getBashPath() != '':
    config.available_features.add('shell')

# Loadable module
# FIXME: This should be supplied by Makefile or autoconf.
if sys.platform in ['win32', 'cygwin']:
    loadable_module = (config.enable_shared == 1)
else:
    loadable_module = True

if loadable_module:
    config.available_features.add('loadable_module')

# LTO on OS X
if config.lto_is_enabled == "1" and platform.system() == "Darwin":
    config.available_features.add('lto_on_osx')

# llc knows whether he is compiled with -DNDEBUG.
import subprocess
try:
    llc_cmd = subprocess.Popen([os.path.join(llvm_tools_dir, 'llc'), '-version'],
                           stdout = subprocess.PIPE)
except OSError, why:
    print "Could not find llc in " + llvm_tools_dir
    exit(42)

if re.search(r'with assertions', llc_cmd.stdout.read()):
    config.available_features.add('asserts')
llc_cmd.wait()
