public static MsvcLibParams Canonicalize(this MsvcLibParams p) { MsvcLibParams o = new MsvcLibParams(); //-- Meta if (String.IsNullOrEmpty(p.VcBinDir)) { throw new InvalidOperationException("VcBinDir not specified"); } if (String.IsNullOrEmpty(p.CompileDir)) { throw new InvalidOperationException("CompileDir not specified"); } o.CompileDir = QRPath.GetCanonical(p.CompileDir); o.BuildFileDir = String.IsNullOrEmpty(p.BuildFileDir) ? p.CompileDir : QRPath.GetCanonical(p.BuildFileDir); o.VcBinDir = QRPath.GetAbsolutePath(p.VcBinDir, p.CompileDir); o.ToolChain = p.ToolChain; o.OutputType = p.OutputType; //-- Input if (p.Inputs.Count == 0) { throw new InvalidOperationException("No Inputs specified"); } foreach (string path in p.Inputs) { string absPath = QRPath.GetAbsolutePath(path, o.CompileDir); o.Inputs.Add(absPath); } if (!String.IsNullOrEmpty(p.DefFilePath)) { o.DefFilePath = QRPath.GetAbsolutePath(p.DefFilePath, o.CompileDir); } foreach (string path in p.NoDefaultLib) { o.NoDefaultLib.Add(path); } //-- Output o.SubSystem = p.SubSystem; if (!String.IsNullOrEmpty(p.OutputFilePath)) { o.OutputFilePath = QRPath.GetAbsolutePath(p.OutputFilePath, o.CompileDir); } else { string firstInput = o.Inputs[0]; string newExtension = ".lib"; o.OutputFilePath = QRPath.ChangeExtension(firstInput, newExtension); } //-- Options foreach (string symbol in p.Export) { o.Export.Add(symbol); } foreach (string symbol in p.Include) { o.Include.Add(symbol); } o.LinkTimeCodeGeneration = p.LinkTimeCodeGeneration; if (o.OutputType == MsvcLibOutputType.ImportLibrary) { if (String.IsNullOrEmpty(p.DllNameForImportLibrary)) { throw new InvalidOperationException("DllName is required if creating an import library."); } o.DllNameForImportLibrary = p.DllNameForImportLibrary; } o.NoLogo = p.NoLogo; o.Verbose = p.Verbose; o.WarningsAsErrors = p.WarningsAsErrors; return o; }
/// Derived project classes can override this to set project-level /// defaults on lib params. protected virtual void LibOverride(MsvcLibParams lp) { }
public MsvcLib(BuildGraph buildGraph, MsvcLibParams p) : base(buildGraph) { m_params = p.Canonicalize(); }
protected MsvcLibParams CreateLibParams( string outputName, Action<MsvcLibParams> overrideParams) { var lp = new MsvcLibParams(); lp.VcBinDir = Config.VcBinDir; lp.ToolChain = ToolChain; lp.CompileDir = ProjectDir; lp.BuildFileDir = OutDir; foreach (MsvcCompile cc in m_compiles) { lp.Inputs.Add(cc.Params.ObjectPath); } lp.OutputFilePath = Path.Combine(OutDir, outputName); LibOverride(lp); if (overrideParams != null) { overrideParams(lp); } return lp; }