[gn build] (manually) merge 24ab9b537e61b3 more
authorNico Weber <thakis@chromium.org>
Thu, 2 Jan 2020 16:44:07 +0000 (11:44 -0500)
committerNico Weber <thakis@chromium.org>
Thu, 2 Jan 2020 16:44:34 +0000 (11:44 -0500)
llvm/utils/gn/secondary/llvm/include/llvm/Support/BUILD.gn
llvm/utils/gn/secondary/llvm/include/llvm/Support/write_extension_def.py [new file with mode: 0755]
llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn

index f64eceb..6991ac7 100644 (file)
@@ -3,3 +3,21 @@ import("//llvm/utils/gn/build/write_vcsrevision.gni")
 write_vcsrevision("write_vcsrevision") {
   header = "$target_gen_dir/VCSRevision.h"
 }
+
+# Corresponds to process_llvm_pass_plugins() in the CMake build.
+# For now, just turn everything off.
+# If we ever add real support for this, the GN way for this is probably
+# to have a declare_args() list with plugin names that people can override
+# in their args.gn and with empty defaults (similar to llvm_targets_to_build).
+action("write_extension_def") {
+  script = "//llvm/utils/gn/secondary/llvm/include/llvm/Support/write_extension_def.py"
+  outputs = [
+    "$target_gen_dir/Extension.def",
+  ]
+  # If any extensions should be enabled, they'd be passed as additional
+  # arguments, e.g. `args += [ "Bye", "Polly" ]`.
+  args = [
+    "-o",
+    rebase_path(outputs[0], root_build_dir),
+  ]
+}
diff --git a/llvm/utils/gn/secondary/llvm/include/llvm/Support/write_extension_def.py b/llvm/utils/gn/secondary/llvm/include/llvm/Support/write_extension_def.py
new file mode 100755 (executable)
index 0000000..768e57d
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+from __future__ import print_function
+
+import argparse
+import os
+import sys
+
+
+def main():
+    parser = argparse.ArgumentParser()
+    parser.add_argument('exts', nargs='*', help='list of supported extensions')
+    parser.add_argument('-o', '--output', required=True, help='output file')
+    args = parser.parse_args()
+
+    output = ''.join(['HANDLE_EXTENSION(%s)\n' % ext for ext in args.exts])
+
+    if not os.path.exists(args.output) or open(args.output).read() != output:
+        open(args.output, 'w').write(output)
+
+
+if __name__ == '__main__':
+    sys.exit(main())
index 2c0850a..b5d8e62 100644 (file)
@@ -22,6 +22,9 @@ static_library("Support") {
 
     # public_dep because public header TargetSelect.h includes these .def files.
     "//llvm/include/llvm/Config:write_target_def_files",
+
+    # public_dep because random targets assume its output exists.
+    "//llvm/include/llvm/Support:write_extension_def",
   ]
   include_dirs = [
     "Unix",