1 module mage.msbuild.clcompile; 2 3 import mage; 4 import cpp = mage.msbuild.cpp; 5 import mage.util.option; 6 7 import std.typetuple : allSatisfy; 8 9 10 struct ClCompile 11 { 12 string warningLevel; 13 string pch; 14 string optimization; 15 string compileAs; 16 Option!bool functionLevelLinking; 17 Option!bool intrinsicFunctions; 18 const(Path)[] includePaths; 19 bool inheritIncludePaths = true; 20 string[] defines; 21 bool inheritDefines = true; 22 } 23 24 auto createClCompile(ref in cpp.MSBuildConfig cfg, ref Environment env) 25 { 26 ClCompile clCompile; 27 28 if(auto var = env.first("includePaths")) 29 { 30 clCompile.includePaths = var.get!(Path[]); 31 log.trace(`Found "includePaths": %s`, clCompile.includePaths); 32 } 33 else 34 { 35 log.trace(`No "includePaths" property found.`); 36 } 37 38 if(auto var = env.first("inheritIncludePaths")) { 39 clCompile.inheritIncludePaths = var.get!bool; 40 } 41 42 if(auto var = env.first("warningLevel")) { 43 clCompile.warningLevel = cpp.trWarningLevel(var.get!int); 44 } 45 46 if(auto var = env.first("pch")) { 47 assert(0, `Not implemented (handling of "pch" property)`); 48 } 49 50 if(auto var = env.first("optimization")) { 51 clCompile.optimization = cpp.trOptimization(var.get!int); 52 } 53 54 if(auto var = env.first("language")) 55 { 56 switch(var.get!string) 57 { 58 case "c": clCompile.compileAs = "CompileAsC"; break; 59 case "cpp": clCompile.compileAs = "CompileAsCpp"; break; 60 default: assert(0, `Unsupported language: "%s"`.format(var.get!string)); 61 } 62 } 63 64 if(auto var = env.first("functionLevelLinking")) { 65 clCompile.functionLevelLinking = var.get!bool; 66 } 67 68 if(auto var = env.first("intrinsicFunctions")) { 69 clCompile.intrinsicFunctions = var.get!bool; 70 } 71 72 if(auto var = env.first("defines")) { 73 clCompile.defines = var.get!(string[]).dup; 74 } 75 76 if(auto var = env.first("inheritDefines")) { 77 clCompile.inheritDefines = var.get!bool; 78 } 79 80 return clCompile; 81 }