public void SetProviderOptions(IEnumerable<CompilerProviderOption> options, ICompilerProjectReader project = null) { foreach (CompilerProviderOption option in options) { if (_providerOption.ContainsKey(option.Name)) { WriteLine(1, "Compiler warning : redefine provider option \"{0}\" value \"{1}\" as \"{2}\" from project \"{3}\"", option.Name, _providerOption[option.Name], option.Value, project != null ? project.ProjectFile : "--no project--"); _providerOption.Remove(option.Name); } _providerOption.Add(option.Name, option.Value); } }
// dontSetOutput : true when executing code from runsource, true for CompilerDefaultValues and ProjectDefaultValues, otherwise false //public void SetParameters(ICompilerProject project, bool includeProject = false, bool dontSetOutput = false) public void SetParameters(ICompilerProjectReader project, bool dontSetOutput = false) { if (project == null) return; //if (!includeProject) //{ //compiler.Language = xe.Get("Language", compiler.Language); string s = project.GetLanguage(); if (s != null) { if (_language != null) WriteLine(1, "Compiler warning : redefine language \"{0}\" as \"{1}\" from project \"{2}\"", _language, s, project.ProjectFile); _language = s; } //foreach (XElement xe2 in xe.GetElements("ProviderOption")) // compiler.SetProviderOption(xe2.zAttribValue("name"), xe2.zAttribValue("value")); SetProviderOptions(project.GetProviderOptions(), project); //compiler.ResourceCompiler = xe.Get("ResourceCompiler", compiler.ResourceCompiler); s = project.GetResourceCompiler(); if (s != null) { if (_resourceCompiler != null) WriteLine(1, "Compiler warning : redefine resource compiler \"{0}\" as \"{1}\" from project \"{2}\"", _resourceCompiler, s, project.ProjectFile); _resourceCompiler = s; } //compiler.OutputDir = xe.Get("OutputDir", compiler.OutputDir); if (!dontSetOutput) { s = project.GetOutputDir(); if (s != null) { if (_outputDir != null) WriteLine(1, "Compiler warning : redefine output directory \"{0}\" as \"{1}\" from project \"{2}\"", _outputDir, s, project.ProjectFile); _outputDir = s; } } //compiler.OutputAssembly = xe.Get("Output", compiler.OutputAssembly); if (!dontSetOutput) { s = project.GetOutput(); if (s != null) SetOutputAssembly(s, project); } //if (s != null) // _outputAssembly = s; //string ext = zPath.GetExtension(_outputAssembly); //if (ext != null) //{ // if (ext.ToLower() == ".exe") // _generateExecutable = true; // else if (ext.ToLower() == ".dll") // _generateExecutable = false; //} bool? b; //compiler.GenerateExecutable = xe.Get("GenerateExecutable").zTryParseAs(compiler.GenerateExecutable); if (!dontSetOutput) { b = project.GetGenerateExecutable(); if (b != null) _generateExecutable = (bool)b; } //compiler.GenerateInMemory = xe.Get("GenerateInMemory").zTryParseAs(compiler.GenerateInMemory); if (!dontSetOutput) { b = project.GetGenerateInMemory(); if (b != null) _generateInMemory = (bool)b; } //compiler.DebugInformation = xe.Get("DebugInformation").zTryParseAs(compiler.DebugInformation); b = project.GetDebugInformation(); if (b != null) _debugInformation = (bool)b; //compiler.WarningLevel = xe.Get("WarningLevel").zTryParseAs<int>(compiler.WarningLevel); int? i = project.GetWarningLevel(); if (i != null) _warningLevel = (int)i; //compiler.AddCompilerOptions(xe.GetValues("CompilerOptions")); AddCompilerOptions(project.GetCompilerOptions()); //string keyfile = xe.Get("KeyFile"); s = project.GetKeyFile(); if (s != null) AddCompilerOption("/keyfile:\"" + s + "\""); //string target = xe.Get("Target"); if (!dontSetOutput) { s = project.GetTarget(); if (s != null) AddCompilerOption("/target:" + s); } //string icon = xe.Get("Icon"); s = project.GetIcon(); if (s != null) //AddCompilerOption("/win32icon:" + s); AddCompilerOption("/win32icon:\"" + s + "\""); //} foreach (ICompilerProjectReader project2 in project.GetIncludeProjects()) { //SetParameters(project2, includeProject: true, dontSetOutput: dontSetOutput); SetParameters(project2, dontSetOutput: dontSetOutput); } //compiler.AddSources(xe.GetElements("Source")); AddSources(project.GetSources()); //compiler.AddFiles(xe.GetElements("File")); // compiler.DefaultDir AddFiles(project.GetFiles()); //compiler.AddAssemblies(xe.GetElements("Assembly")); AddAssemblies(project.GetAssemblies()); //compiler.AddLocalAssemblies(xe.GetElements("LocalAssembly")); //compiler.AddCopyOutputDirectories(xe.GetValues("CopyOutput")); if (!dontSetOutput) { AddCopyOutputDirectories(project.GetCopyOutputs()); } }
public void SetOutputAssembly(string outputAssembly, ICompilerProjectReader project = null) { if (outputAssembly != null) { if (_outputAssembly != null) WriteLine(1, "Compiler warning : redefine output assembly \"{0}\" as \"{1}\" from project \"{2}\"", _outputAssembly, outputAssembly, project.ProjectFile); _outputAssembly = outputAssembly; string ext = zPath.GetExtension(outputAssembly); if (ext != null) { if (ext.ToLower() == ".exe") _generateExecutable = true; else if (ext.ToLower() == ".dll") _generateExecutable = false; } } }