//
// Copyright (C) 2015 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//

cc_defaults {
    name: "san_test_defaults",

    cflags: [
        "-Wall",
        "-Werror",
    ],
    cppflags: [
        "-fvisibility=hidden",
        "-fno-exceptions",
        "-fno-rtti",
        "-std=c++11",
        "-Wno-unused-parameter",
        "-Wno-non-virtual-dtor",
        "-Wno-format",
    ],

    include_dirs: ["external/compiler-rt/lib"],
}


cc_test_host {
    name: "san_test",
    defaults: ["san_test_defaults"],

    srcs: [
        "sanitizer_allocator_test.cc",
        "sanitizer_atomic_test.cc",
        "sanitizer_bitvector_test.cc",
        "sanitizer_bvgraph_test.cc",
        "sanitizer_common_test.cc",
        "sanitizer_deadlock_detector_test.cc",
        "sanitizer_flags_test.cc",
        "sanitizer_format_interceptor_test.cc",
        "sanitizer_ioctl_test.cc",
        "sanitizer_libc_test.cc",
        "sanitizer_linux_test.cc",
        "sanitizer_list_test.cc",
        "sanitizer_mutex_test.cc",
        "sanitizer_nolibc_test.cc",
        "sanitizer_posix_test.cc",
        "sanitizer_printf_test.cc",
        "sanitizer_procmaps_test.cc",
        "sanitizer_stackdepot_test.cc",
        "sanitizer_stacktrace_printer_test.cc",
        "sanitizer_stacktrace_test.cc",
        "sanitizer_stoptheworld_test.cc",
        "sanitizer_suppressions_test.cc",
        "sanitizer_test_main.cc",
        "sanitizer_thread_registry_test.cc",
    ],
    static_libs: ["libsan"],
    sanitize: {
        never: true,
    },
    target: {
        darwin: {
            enabled: false,
        },
    },
}

cc_binary_host {
    name: "san_test-Nolibc",
    defaults: ["san_test_defaults"],

    srcs: ["sanitizer_nolibc_test_main.cc"],
    static_libs: [
        "libsan",
        "libgtest_host",
    ],
    ldflags: [
        "-nostdlib",
        "-Qunused-arguments",
    ],
    sanitize: {
        never: true,
    },
    target: {
        darwin: {
            enabled: false,
        },
    },
}