# -*- Python -*-

import os

# Setup config name.
config.name = 'Scudo'

# Setup source root.
config.test_source_root = os.path.dirname(__file__)

# Path to the static library
base_lib = os.path.join(config.compiler_rt_libdir,
                        "libclang_rt.scudo-%s.a" % config.target_arch)
whole_archive = "-Wl,-whole-archive %s -Wl,-no-whole-archive " % base_lib

# Test suffixes.
config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test']

# C flags.
c_flags = ["-std=c++11",
           "-lstdc++",
           "-ldl",
           "-lrt",
           "-pthread",
           "-latomic",
           "-fPIE",
           "-pie",
           "-O0"]

def build_invocation(compile_flags):                                            
  return " " + " ".join([config.clang] + compile_flags) + " "                   

# Add clang substitutions.
config.substitutions.append( ("%clang_scudo ",
                              build_invocation(c_flags) + whole_archive) )

# Hardened Allocator tests are currently supported on Linux only.
if config.host_os not in ['Linux']:
   config.unsupported = True