1 /* include/llvm/Config/llvm-config.h. Generated from llvm-config.h.in by configure. */ 2 /*===-- llvm/config/llvm-config.h - llvm configure variable -------*- C -*-===*/ 3 /* */ 4 /* The LLVM Compiler Infrastructure */ 5 /* */ 6 /* This file is distributed under the University of Illinois Open Source */ 7 /* License. See LICENSE.TXT for details. */ 8 /* */ 9 /*===----------------------------------------------------------------------===*/ 10 11 /* This file enumerates all of the llvm variables from configure so that 12 they can be in exported headers and won't override package specific 13 directives. This is a C file so we can include it in the llvm-c headers. */ 14 15 module deimos.llvm.config.llvm_config; 16 17 version(llvmNoConfig) {} 18 else: 19 20 private 21 { 22 import std.string : splitLines; 23 import std.algorithm : startsWith, countUntil, filter; 24 25 string llvmConfig() 26 { 27 enum defineStr = "#define"; 28 auto defines = import("llvm-config.h") 29 .splitLines() 30 .filter!(line => line.startsWith(defineStr))(); 31 32 auto code = ""; 33 foreach (d; defines) 34 { 35 d = d[defineStr.length+1 .. $]; 36 auto identifier = d[0 .. d.countUntil(" ")]; 37 d = d[identifier.length+1 .. $]; 38 switch (identifier) 39 { 40 default: 41 if (d.startsWith("LLVMInitialize")) 42 code ~= "alias " ~ identifier ~ " = " ~ d ~ ";\n"; 43 else 44 code ~= "enum " ~ identifier ~ " = " ~ d ~ ";\n"; 45 break; 46 case "LLVM_NATIVE_ARCH": 47 code ~= "enum " ~ identifier ~ " = \"" ~ d ~ "\";\n"; 48 break; 49 case "HAVE_MMAP_FILE": 50 code ~= "enum " ~ identifier ~ " = true;\n"; 51 break; 52 case "RETSIGTYPE": 53 code ~= "enum " ~ identifier ~ " = typeid(" ~ d ~ ");\n"; 54 break; 55 } 56 } 57 58 return code; 59 } 60 } 61 62 import deimos.llvm.c.target; 63 extern(C) nothrow: 64 mixin(llvmConfig());