import lit.formats
import os
import sys
import platform

## Autogenerated paths by cmake:
config.ldc2_bin         = "@LDC2_BIN@"
config.ldc2_bin_dir     = "@LDC2_BIN_DIR@"
config.test_source_root = "@TESTS_IR_DIR@"
config.llvm_tools_dir   = "@LLVM_TOOLS_DIR@"
config.llvm_version     = @LDC_LLVM_VER@

config.name = 'LLVM IR codegen'

# testFormat: The test format to use to interpret tests.
config.test_format = lit.formats.ShTest(execute_external=False)

# suffixes: A list of file extensions to treat as test files. This is overriden
# by individual lit.local.cfg files in the test subdirectories.
config.suffixes = ['.d',
                   ]

# 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 = []

# Define available features so that we can disable tests depending on LLVM version
config.available_features.add("llvm%d" % config.llvm_version)
for version in range(305, config.llvm_version+1):
    config.available_features.add("atleast_llvm%d" % version)

# Define OS as available feature (Windows, Darwin, Linux)
config.available_features.add(platform.system())

config.target_triple = '(unused)'

# test_exec_root: The root path where tests should be run.
config.test_exec_root = os.path.dirname(__file__)

# add LDC bin dir to the path
path = os.path.pathsep.join( (config.ldc2_bin_dir, config.environment['PATH']) )
config.environment['PATH'] = path

# add LLVM tools bin dir to the path
path = os.path.pathsep.join( (config.llvm_tools_dir, config.environment['PATH']) )
config.environment['PATH'] = path

# add test root dir to the path (FileCheck might sit there)
path = os.path.pathsep.join( (config.test_source_root, config.environment['PATH']) )
config.environment['PATH'] = path

# Add substitutions
config.substitutions.append( ('%ldc', config.ldc2_bin) )
