1import("//llvm/utils/unittest/unittest.gni")
2
3# Keyed off LLVM_ENABLE_PLUGINS in the CMake build, which is usually false
4# on Windows and true elsewhere.
5if (host_os != "win") {
6  loadable_module("TestPlugin") {
7    # Put plugin next to the unit test executable.
8    output_dir = target_out_dir
9
10    sources = [
11      "TestPlugin.cpp",
12    ]
13
14    deps = [
15      # TestPlugin doesn't want to link in any LLVM code, it just needs its
16      # headers.
17      "//llvm/include/llvm/IR:public_tablegen",
18    ]
19
20    if (host_os != "mac" && host_os != "win") {
21      # The GN build currently doesn't globally pass -fPIC, but that's
22      # needed for building .so files on ELF.  Just pass it manually
23      # for loadable_modules for now.
24      cflags = [ "-fPIC" ]
25    }
26  }
27}
28
29unittest("PluginsTests") {
30  deps = [
31    "//llvm/include/llvm/Config:config",
32    "//llvm/lib/IR",
33    "//llvm/lib/Passes",
34    "//llvm/lib/Support",
35    "//llvm/lib/Testing/Support",
36  ]
37  sources = [
38    "PluginsTest.cpp",
39  ]
40
41  # If plugins are disabled, this test will disable itself at runtime.
42  # Otherwise, reconfiguring with plugins disabled will leave behind a stale
43  # executable.
44  if (host_os != "win") {
45    deps += [ ":TestPlugin" ]
46    defines = [ "LLVM_ENABLE_PLUGINS" ]
47  }
48
49  if (host_os != "mac" && host_os != "win") {
50    # Corresponds to export_executable_symbols() in cmake.
51    ldflags = [ "-rdynamic" ]
52  }
53}
54