public object Build( CSharp.Assembly moduleToBuild, out System.Boolean success) { var assemblyModule = moduleToBuild as Bam.Core.BaseModule; var node = assemblyModule.OwningNode; var target = node.Target; var assemblyOptions = assemblyModule.Options; var options = assemblyOptions as CSharp.OptionCollection; var inputVariables = new MakeFileVariableDictionary(); if (node.ExternalDependents != null) { foreach (var dependentNode in node.ExternalDependents) { if (null != dependentNode.Data) { continue; } var keyFilters = new Bam.Core.Array<Bam.Core.LocationKey>( CSharp.Assembly.OutputFile ); var assemblyLocations = new Bam.Core.LocationArray(); dependentNode.FilterOutputLocations(keyFilters, assemblyLocations); var data = dependentNode.Data as MakeFileData; var csharpOptions = options as CSharp.IOptions; foreach (var loc in assemblyLocations) { csharpOptions.References.Add(loc.GetSinglePath()); inputVariables.Add(CSharp.Assembly.OutputFile, data.VariableDictionary[CSharp.Assembly.OutputDir]); } } } var sourceFiles = new Bam.Core.StringArray(); var fields = moduleToBuild.GetType().GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic); foreach (var field in fields) { // C# files { var sourceFileAttributes = field.GetCustomAttributes(typeof(Bam.Core.SourceFilesAttribute), false); if (null != sourceFileAttributes && sourceFileAttributes.Length > 0) { var sourceField = field.GetValue(moduleToBuild); if (sourceField is Bam.Core.Location) { var file = sourceField as Bam.Core.Location; var absolutePath = file.GetSinglePath(); if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Source file '{0}' does not exist", absolutePath); } sourceFiles.Add(absolutePath); } else if (sourceField is Bam.Core.FileCollection) { var sourceCollection = sourceField as Bam.Core.FileCollection; // TODO: convert to var foreach (Bam.Core.Location location in sourceCollection) { var absolutePath = location.GetSinglePath(); if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Source file '{0}' does not exist", absolutePath); } sourceFiles.Add(absolutePath); } } else { throw new Bam.Core.Exception("Field '{0}' of '{1}' should be of type Bam.Core.File or Bam.Core.FileCollection, not '{2}'", field.Name, node.ModuleName, sourceField.GetType().ToString()); } } } // WPF application definition .xaml file { var xamlFileAttributes = field.GetCustomAttributes(typeof(CSharp.ApplicationDefinitionAttribute), false); if (null != xamlFileAttributes && xamlFileAttributes.Length > 0) { var sourceField = field.GetValue(moduleToBuild); if (sourceField is Bam.Core.Location) { var file = sourceField as Bam.Core.Location; var absolutePath = file.GetSinglePath(); if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Application definition file '{0}' does not exist", absolutePath); } var csPath = absolutePath + ".cs"; if (!System.IO.File.Exists(csPath)) { throw new Bam.Core.Exception("Associated source file '{0}' to application definition file '{1}' does not exist", csPath, absolutePath); } sourceFiles.Add(csPath); } else if (sourceField is Bam.Core.FileCollection) { var sourceCollection = sourceField as Bam.Core.FileCollection; if (sourceCollection.Count != 1) { throw new Bam.Core.Exception("There can be only one application definition"); } // TODO: convert to var foreach (string absolutePath in sourceCollection) { if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Application definition file '{0}' does not exist", absolutePath); } var csPath = absolutePath + ".cs"; if (!System.IO.File.Exists(csPath)) { throw new Bam.Core.Exception("Associated source file '{0}' to application definition file '{1}' does not exist", csPath, absolutePath); } sourceFiles.Add(csPath); } } else { throw new Bam.Core.Exception("Field '{0}' of '{1}' should be of type Bam.Core.File or Bam.Core.FileCollection, not '{2}'", field.Name, node.ModuleName, sourceField.GetType().ToString()); } } } // WPF page .xaml files { var xamlFileAttributes = field.GetCustomAttributes(typeof(CSharp.PagesAttribute), false); if (null != xamlFileAttributes && xamlFileAttributes.Length > 0) { var sourceField = field.GetValue(moduleToBuild); if (sourceField is Bam.Core.Location) { var file = sourceField as Bam.Core.Location; var absolutePath = file.GetSinglePath(); if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Page file '{0}' does not exist", absolutePath); } var csPath = absolutePath + ".cs"; if (!System.IO.File.Exists(csPath)) { throw new Bam.Core.Exception("Associated source file '{0}' to page file '{1}' does not exist", csPath, absolutePath); } sourceFiles.Add(csPath); } else if (sourceField is Bam.Core.FileCollection) { var sourceCollection = sourceField as Bam.Core.FileCollection; if (sourceCollection.Count != 1) { throw new Bam.Core.Exception("There can be only one page file"); } // TODO: convert to var foreach (string absolutePath in sourceCollection) { if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Page file '{0}' does not exist", absolutePath); } var csPath = absolutePath + ".cs"; if (!System.IO.File.Exists(csPath)) { throw new Bam.Core.Exception("Associated source file '{0}' to page file '{1}' does not exist", csPath, absolutePath); } sourceFiles.Add(csPath); } } else { throw new Bam.Core.Exception("Field '{0}' of '{1}' should be of type Bam.Core.File or Bam.Core.FileCollection, not '{2}'", field.Name, node.ModuleName, sourceField.GetType().ToString()); } } } } if (0 == sourceFiles.Count) { throw new Bam.Core.Exception("There were no source files specified for the module '{0}'", node.ModuleName); } // at this point, we know the node outputs need building // create all directories required var dirsToCreate = moduleToBuild.Locations.FilterByType(Bam.Core.ScaffoldLocation.ETypeHint.Directory, Bam.Core.Location.EExists.WillExist); var commandLineBuilder = new Bam.Core.StringArray(); if (options is CommandLineProcessor.ICommandLineSupport) { var commandLineOption = options as CommandLineProcessor.ICommandLineSupport; commandLineOption.ToCommandLineArguments(commandLineBuilder, target, null); } else { throw new Bam.Core.Exception("Compiler options does not support command line translation"); } foreach (var source in sourceFiles) { if (source.Contains(" ")) { commandLineBuilder.Add(System.String.Format("\"{0}\"", source)); } else { commandLineBuilder.Add(source); } } var compilerInstance = target.Toolset.Tool(typeof(CSharp.ICSharpCompilerTool)); var executablePath = compilerInstance.Executable((Bam.Core.BaseTarget)target); var recipes = new Bam.Core.StringArray(); if (executablePath.Contains(" ")) { recipes.Add(System.String.Format("\"{0}\" {1}", executablePath, commandLineBuilder.ToString(' '))); } else { recipes.Add(System.String.Format("{0} {1}", executablePath, commandLineBuilder.ToString(' '))); } var makeFile = new MakeFile(node, this.topLevelMakeFilePath); var rule = new MakeFileRule( moduleToBuild, CSharp.Assembly.OutputFile, node.UniqueModuleName, dirsToCreate, inputVariables, null, recipes); var toolOutputLocKeys = compilerInstance.OutputLocationKeys(moduleToBuild); var outputFileLocations = moduleToBuild.Locations.Keys(Bam.Core.ScaffoldLocation.ETypeHint.File, Bam.Core.Location.EExists.WillExist); var outputFileLocationsOfInterest = outputFileLocations.Intersect(toolOutputLocKeys); rule.OutputLocationKeys = outputFileLocationsOfInterest; makeFile.RuleArray.Add(rule); var makeFilePath = MakeFileBuilder.GetMakeFilePathName(node); System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(makeFilePath)); Bam.Core.Log.DebugMessage("Makefile : '{0}'", makeFilePath); using (System.IO.TextWriter makeFileWriter = new System.IO.StreamWriter(makeFilePath)) { makeFile.Write(makeFileWriter); } success = true; var compilerTool = compilerInstance as Bam.Core.ITool; System.Collections.Generic.Dictionary<string, Bam.Core.StringArray> environment = null; if (compilerTool is Bam.Core.IToolEnvironmentVariables) { environment = (compilerTool as Bam.Core.IToolEnvironmentVariables).Variables((Bam.Core.BaseTarget)target); } var returnData = new MakeFileData(makeFilePath, makeFile.ExportedTargets, makeFile.ExportedVariables, environment); return returnData; }
public object Build( CSharp.Assembly moduleToBuild, out System.Boolean success) { var assemblyModule = moduleToBuild as Bam.Core.BaseModule; var node = assemblyModule.OwningNode; var target = node.Target; var assemblyOptions = assemblyModule.Options; var options = assemblyOptions as CSharp.IOptions; if (node.ExternalDependents != null) { var keyFilters = new Bam.Core.Array<Bam.Core.LocationKey>( CSharp.Assembly.OutputFile ); var dependentAssemblies = new Bam.Core.LocationArray(); node.ExternalDependents.FilterOutputLocations(keyFilters, dependentAssemblies); foreach (var loc in dependentAssemblies) { options.References.Add(loc.GetSinglePath()); } } var sourceFiles = new Bam.Core.StringArray(); var fields = moduleToBuild.GetType().GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic); foreach (var field in fields) { // C# files { var sourceFileAttributes = field.GetCustomAttributes(typeof(Bam.Core.SourceFilesAttribute), false); if (null != sourceFileAttributes && sourceFileAttributes.Length > 0) { var sourceField = field.GetValue(moduleToBuild); if (sourceField is Bam.Core.Location) { var file = sourceField as Bam.Core.Location; var absolutePath = file.GetSinglePath(); if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Source file '{0}' does not exist", absolutePath); } sourceFiles.Add(absolutePath); } else if (sourceField is Bam.Core.FileCollection) { var sourceCollection = sourceField as Bam.Core.FileCollection; // TODO: convert to var foreach (Bam.Core.Location location in sourceCollection) { var absolutePath = location.AbsolutePath; if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Source file '{0}' does not exist", absolutePath); } sourceFiles.Add(absolutePath); } } else { throw new Bam.Core.Exception("Field '{0}' of '{1}' should be of type Bam.Core.File or Bam.Core.FileCollection, not '{2}'", field.Name, node.ModuleName, sourceField.GetType().ToString()); } } } // WPF application definition .xaml file { var xamlFileAttributes = field.GetCustomAttributes(typeof(CSharp.ApplicationDefinitionAttribute), false); if (null != xamlFileAttributes && xamlFileAttributes.Length > 0) { var sourceField = field.GetValue(moduleToBuild); if (sourceField is Bam.Core.Location) { var file = sourceField as Bam.Core.Location; var absolutePath = file.GetSinglePath(); if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Application definition file '{0}' does not exist", absolutePath); } var csPath = absolutePath + ".cs"; if (!System.IO.File.Exists(csPath)) { throw new Bam.Core.Exception("Associated source file '{0}' to application definition file '{1}' does not exist", csPath, absolutePath); } sourceFiles.Add(csPath); } else if (sourceField is Bam.Core.FileCollection) { var sourceCollection = sourceField as Bam.Core.FileCollection; if (sourceCollection.Count != 1) { throw new Bam.Core.Exception("There can be only one application definition"); } // TODO: convert to var foreach (string absolutePath in sourceCollection) { if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Application definition file '{0}' does not exist", absolutePath); } var csPath = absolutePath + ".cs"; if (!System.IO.File.Exists(csPath)) { throw new Bam.Core.Exception("Associated source file '{0}' to application definition file '{1}' does not exist", csPath, absolutePath); } sourceFiles.Add(csPath); } } else { throw new Bam.Core.Exception("Field '{0}' of '{1}' should be of type Bam.Core.File or Bam.Core.FileCollection, not '{2}'", field.Name, node.ModuleName, sourceField.GetType().ToString()); } } } // WPF page .xaml files { var xamlFileAttributes = field.GetCustomAttributes(typeof(CSharp.PagesAttribute), false); if (null != xamlFileAttributes && xamlFileAttributes.Length > 0) { var sourceField = field.GetValue(moduleToBuild); if (sourceField is Bam.Core.Location) { var file = sourceField as Bam.Core.Location; var absolutePath = file.GetSinglePath(); if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Page file '{0}' does not exist", absolutePath); } var csPath = absolutePath + ".cs"; if (!System.IO.File.Exists(csPath)) { throw new Bam.Core.Exception("Associated source file '{0}' to page file '{1}' does not exist", csPath, absolutePath); } sourceFiles.Add(csPath); } else if (sourceField is Bam.Core.FileCollection) { var sourceCollection = sourceField as Bam.Core.FileCollection; if (sourceCollection.Count != 1) { throw new Bam.Core.Exception("There can be only one page file"); } // TODO: convert to var foreach (string absolutePath in sourceCollection) { if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Page file '{0}' does not exist", absolutePath); } var csPath = absolutePath + ".cs"; if (!System.IO.File.Exists(csPath)) { throw new Bam.Core.Exception("Associated source file '{0}' to page file '{1}' does not exist", csPath, absolutePath); } sourceFiles.Add(csPath); } } else { throw new Bam.Core.Exception("Field '{0}' of '{1}' should be of type Bam.Core.File or Bam.Core.FileCollection, not '{2}'", field.Name, node.ModuleName, sourceField.GetType().ToString()); } } } } if (0 == sourceFiles.Count) { throw new Bam.Core.Exception("There were no source files specified for the module '{0}'", node.ModuleName); } // dependency checking { var inputLocations = new Bam.Core.LocationArray(); foreach (var source in sourceFiles) { inputLocations.Add(Bam.Core.FileLocation.Get(source)); } var outputLocations = moduleToBuild.Locations.FilterByType(Bam.Core.ScaffoldLocation.ETypeHint.File, Bam.Core.Location.EExists.WillExist); if (!RequiresBuilding(outputLocations, inputLocations)) { Bam.Core.Log.DebugMessage("'{0}' is up-to-date", node.UniqueModuleName); success = true; return null; } } // at this point, we know the node outputs need building // create all directories required var dirsToCreate = moduleToBuild.Locations.FilterByType(Bam.Core.ScaffoldLocation.ETypeHint.Directory, Bam.Core.Location.EExists.WillExist); foreach (var dir in dirsToCreate) { var dirPath = dir.GetSinglePath(); NativeBuilder.MakeDirectory(dirPath); } var commandLineBuilder = new Bam.Core.StringArray(); if (options is CommandLineProcessor.ICommandLineSupport) { var commandLineOption = options as CommandLineProcessor.ICommandLineSupport; commandLineOption.ToCommandLineArguments(commandLineBuilder, target, null); } else { throw new Bam.Core.Exception("Compiler options does not support command line translation"); } foreach (var source in sourceFiles) { if (source.Contains(" ")) { commandLineBuilder.Add(System.String.Format("\"{0}\"", source)); } else { commandLineBuilder.Add(source); } } var compilerTool = target.Toolset.Tool(typeof(CSharp.ICSharpCompilerTool)); var exitCode = CommandLineProcessor.Processor.Execute(node, compilerTool, commandLineBuilder); success = (0 == exitCode); return null; }
public object Build( CSharp.Assembly moduleToBuild, out System.Boolean success) { var assemblyModule = moduleToBuild as Bam.Core.BaseModule; var node = assemblyModule.OwningNode; var target = node.Target; var options = assemblyModule.Options as CSharp.OptionCollection; var moduleName = node.ModuleName; string platformName; switch ((options as CSharp.IOptions).Platform) { case CSharp.EPlatform.AnyCpu: platformName = "AnyCPU"; break; case CSharp.EPlatform.X86: platformName = "x86"; break; case CSharp.EPlatform.X64: case CSharp.EPlatform.Itanium: platformName = "x64"; break; default: throw new Bam.Core.Exception("Unrecognized platform"); } ICSProject projectData = null; // TODO: want to remove this lock (this.solutionFile.ProjectDictionary) { if (this.solutionFile.ProjectDictionary.ContainsKey(moduleName)) { projectData = this.solutionFile.ProjectDictionary[moduleName] as ICSProject; } else { var solutionType = Bam.Core.State.Get("VSSolutionBuilder", "SolutionType") as System.Type; var SolutionInstance = System.Activator.CreateInstance(solutionType); var ProjectExtensionProperty = solutionType.GetProperty("ProjectExtension"); var projectExtension = ProjectExtensionProperty.GetGetMethod().Invoke(SolutionInstance, null) as string; var projectDir = node.GetModuleBuildDirectoryLocation().GetSinglePath(); var projectPathName = System.IO.Path.Combine(projectDir, moduleName); projectPathName += projectExtension; var projectType = VSSolutionBuilder.GetProjectClassType(); projectData = System.Activator.CreateInstance(projectType, new object[] { moduleName, projectPathName, node.Package.Identifier, assemblyModule.ProxyPath }) as ICSProject; this.solutionFile.ProjectDictionary.Add(moduleName, projectData); } } { if (!projectData.Platforms.Contains(platformName)) { projectData.Platforms.Add(platformName); } } // solution folder { var groups = moduleToBuild.GetType().GetCustomAttributes(typeof(Bam.Core.ModuleGroupAttribute), true); if (groups.Length > 0) { projectData.GroupName = (groups as Bam.Core.ModuleGroupAttribute[])[0].GroupName; } } if (node.ExternalDependents != null) { foreach (var dependentNode in node.ExternalDependents) { if (dependentNode.ModuleName == moduleName) { continue; } // TODO: want to remove this lock (this.solutionFile.ProjectDictionary) { if (this.solutionFile.ProjectDictionary.ContainsKey(dependentNode.ModuleName)) { var dependentProject = this.solutionFile.ProjectDictionary[dependentNode.ModuleName]; projectData.DependentProjects.Add(dependentProject); } } } } // references // TODO: convert to var foreach (Bam.Core.Location location in (options as CSharp.IOptions).References) { var reference = location.GetSinglePath(); projectData.References.Add(reference); } var configurationName = VSSolutionBuilder.GetConfigurationNameFromTarget(target, platformName); ProjectConfiguration configuration; lock (projectData.Configurations) { if (!projectData.Configurations.Contains(configurationName)) { // TODO: fix me? configuration = new ProjectConfiguration(configurationName, projectData); configuration.CharacterSet = EProjectCharacterSet.NotSet; projectData.Configurations.Add((Bam.Core.BaseTarget)target, configuration); } else { configuration = projectData.Configurations[configurationName]; projectData.Configurations.AddExistingForTarget((Bam.Core.BaseTarget)target, configuration); } } var fields = moduleToBuild.GetType().GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic); foreach (var field in fields) { // C# files { var sourceFileAttributes = field.GetCustomAttributes(typeof(Bam.Core.SourceFilesAttribute), false); if (null != sourceFileAttributes && sourceFileAttributes.Length > 0) { var sourceField = field.GetValue(moduleToBuild); if (sourceField is Bam.Core.Location) { var file = sourceField as Bam.Core.Location; var absolutePath = file.GetSinglePath(); if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Source file '{0}' does not exist", absolutePath); } ProjectFile sourceFile; lock (projectData.SourceFiles) { if (!projectData.SourceFiles.Contains(absolutePath)) { sourceFile = new ProjectFile(absolutePath); sourceFile.FileConfigurations = new ProjectFileConfigurationCollection(); projectData.SourceFiles.Add(sourceFile); } else { sourceFile = projectData.SourceFiles[absolutePath]; } } } else if (sourceField is Bam.Core.FileCollection) { var sourceCollection = sourceField as Bam.Core.FileCollection; // TODO: convert to var foreach (Bam.Core.Location location in sourceCollection) { var absolutePath = location.GetSinglePath(); if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Source file '{0}' does not exist", absolutePath); } ProjectFile sourceFile; lock (projectData.SourceFiles) { if (!projectData.SourceFiles.Contains(absolutePath)) { sourceFile = new ProjectFile(absolutePath); sourceFile.FileConfigurations = new ProjectFileConfigurationCollection(); projectData.SourceFiles.Add(sourceFile); } else { sourceFile = projectData.SourceFiles[absolutePath]; } } } } else { throw new Bam.Core.Exception("Field '{0}' of '{1}' should be of type Bam.Core.File or Bam.Core.FileCollection, not '{2}'", field.Name, node.ModuleName, sourceField.GetType().ToString()); } } } // WPF application definition .xaml file { var xamlFileAttributes = field.GetCustomAttributes(typeof(CSharp.ApplicationDefinitionAttribute), false); if (null != xamlFileAttributes && xamlFileAttributes.Length > 0) { var sourceField = field.GetValue(moduleToBuild); if (sourceField is Bam.Core.Location) { var file = sourceField as Bam.Core.Location; var absolutePath = file.GetSinglePath(); if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Application definition file '{0}' does not exist", absolutePath); } #if false // TODO: in theory, this file should be generated in VS, but it doesn't seem to string csPath = absolutePath + ".cs"; if (!System.IO.File.Exists(csPath)) { throw new Bam.Core.Exception("Associated source file '{0}' to application definition file '{1}' does not exist", csPath, absolutePath); } #endif projectData.ApplicationDefinition = new ProjectFile(absolutePath); } else if (sourceField is Bam.Core.FileCollection) { var sourceCollection = sourceField as Bam.Core.FileCollection; if (sourceCollection.Count != 1) { throw new Bam.Core.Exception("There can be only one application definition"); } // TODO: convert to var foreach (string absolutePath in sourceCollection) { if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Application definition file '{0}' does not exist", absolutePath); } #if false // TODO: in theory, this file should be generated in VS, but it doesn't seem to string csPath = absolutePath + ".cs"; if (!System.IO.File.Exists(csPath)) { throw new Bam.Core.Exception("Associated source file '{0}' to application definition file '{1}' does not exist", csPath, absolutePath)); } #endif projectData.ApplicationDefinition = new ProjectFile(absolutePath); } } else { throw new Bam.Core.Exception("Field '{0}' of '{1}' should be of type Bam.Core.File or Bam.Core.FileCollection, not '{2}'", field.Name, node.ModuleName, sourceField.GetType().ToString()); } } } // WPF page .xaml files { var xamlFileAttributes = field.GetCustomAttributes(typeof(CSharp.PagesAttribute), false); if (null != xamlFileAttributes && xamlFileAttributes.Length > 0) { var sourceField = field.GetValue(moduleToBuild); if (sourceField is Bam.Core.Location) { var file = sourceField as Bam.Core.Location; var absolutePath = file.GetSinglePath(); if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Page file '{0}' does not exist", absolutePath); } lock (projectData.Pages) { if (!projectData.Pages.Contains(absolutePath)) { projectData.Pages.Add(new ProjectFile(absolutePath)); } } } else if (sourceField is Bam.Core.FileCollection) { var sourceCollection = sourceField as Bam.Core.FileCollection; // TODO: convert to var foreach (string absolutePath in sourceCollection) { if (!System.IO.File.Exists(absolutePath)) { throw new Bam.Core.Exception("Page file '{0}' does not exist", absolutePath); } var csPath = absolutePath + ".cs"; if (!System.IO.File.Exists(csPath)) { throw new Bam.Core.Exception("Associated source file '{0}' to page file '{1}' does not exist", csPath, absolutePath); } lock (projectData.Pages) { if (!projectData.Pages.Contains(absolutePath)) { projectData.Pages.Add(new ProjectFile(absolutePath)); } } } } else { throw new Bam.Core.Exception("Field '{0}' of '{1}' should be of type Bam.Core.File or Bam.Core.FileCollection, not '{2}'", field.Name, node.ModuleName, sourceField.GetType().ToString()); } } } } configuration.Type = EProjectConfigurationType.Application; var toolName = "VCSCompiler"; var vcsCompiler = configuration.GetTool(toolName); if (null == vcsCompiler) { vcsCompiler = new ProjectTool(toolName); configuration.AddToolIfMissing(vcsCompiler); configuration.OutputDirectory = moduleToBuild.Locations[CSharp.Assembly.OutputDir]; if (options is VisualStudioProcessor.IVisualStudioSupport) { var visualStudioProjectOption = options as VisualStudioProcessor.IVisualStudioSupport; var settingsDictionary = visualStudioProjectOption.ToVisualStudioProjectAttributes(target); foreach (var setting in settingsDictionary) { vcsCompiler[setting.Key] = setting.Value; } } else { throw new Bam.Core.Exception("Assembly options does not support VisualStudio project translation"); } } success = true; return projectData; }
public override void Request(StreamWriter writer, string indent, string name, params Call[] calls) { writer.WriteLine(indent + "public abstract class {0}<T> : RPC.Request<{0}.Value, Response.{0}.Value, T> where T : Output", name); writer.WriteLine(indent + "{"); writer.WriteLine(indent + "\tprotected {0}(Func<Protocol.Format> acquire, Action<Protocol.Format> release) : base(acquire, release)", name); writer.WriteLine(indent + "\t{"); List <string> list = new List <string>(); List <string> list2 = new List <string>(); for (int i = 0; i < calls.Length; i++) { Call call = calls[i]; list.Add("T"); if (call.RequestType.HasValue) { list.Add(CSharp.GetType(call.RequestType.Value, call.RequestTypeEx)); } if (call.ResponseType.HasValue) { list.Add(CSharp.GetType(call.ResponseType.Value, call.ResponseTypeEx)); } string text = string.Format("{0}.{1}{2}", name, this.RequestWrap(call.RequestType.HasValue, call.ResponseType.HasValue), (list.Count == 0) ? "" : string.Format("<{0}>", string.Join(", ", list))); list.Clear(); list.Add(call.Place.ToString()); if (call.RequestType.HasValue) { list.Add(string.Format("{0}.InputWrap.{1}", name, call.Name)); } if (call.ResponseType.HasValue) { list.Add(string.Format("{0}.VerifyWrap.{1}", name, call.Name)); list.Add(string.Format("{0}.OutputWrap.{1}", name, call.Name)); } writer.WriteLine(indent + "\t\t{0} = new {1}(this, {2});", call.Name, text, string.Join(", ", list)); list.Clear(); list2.Add(string.Format("public readonly {0} {1};", text, call.Name)); } writer.WriteLine(indent + "\t}"); foreach (string item in list2) { writer.WriteLine(indent + "\t" + item); } writer.WriteLine(indent + "}"); writer.WriteLine(indent + "public static partial class {0}", name); writer.WriteLine(indent + "{"); writer.WriteLine(indent + "\tpublic static class InputWrap"); writer.WriteLine(indent + "\t{"); for (int j = 0; j < calls.Length; j++) { Call call2 = calls[j]; if (call2.RequestType.HasValue) { writer.WriteLine(indent + "\t\tpublic static readonly Func<{0}, {1}.Value> {2} = request => new {1}.Value {{{2} = request}};", CSharp.GetType(call2.RequestType.Value, call2.RequestTypeEx), name, call2.Name); } } writer.WriteLine(indent + "\t}"); writer.WriteLine(indent + "}"); writer.WriteLine(indent + "public static partial class {0}", name); writer.WriteLine(indent + "{"); writer.WriteLine(indent + "\tpublic static class VerifyWrap"); writer.WriteLine(indent + "\t{"); for (int k = 0; k < calls.Length; k++) { Call call3 = calls[k]; if (call3.ResponseType.HasValue) { writer.WriteLine(indent + "\t\tpublic static readonly Func<Response.{0}.Value, bool> {1} = response => response.{1} != null;", name, call3.Name); } } writer.WriteLine(indent + "\t}"); writer.WriteLine(indent + "}"); writer.WriteLine(indent + "public static partial class {0}", name); writer.WriteLine(indent + "{"); writer.WriteLine(indent + "\tpublic static class OutputWrap"); writer.WriteLine(indent + "\t{"); for (int l = 0; l < calls.Length; l++) { Call call4 = calls[l]; if (call4.ResponseType.HasValue) { writer.WriteLine(indent + "\t\tpublic static readonly Func<Response.{0}.Value, {1}> {2} = response => response.{2}{3};", name, CSharp.GetType(call4.ResponseType.Value, call4.ResponseTypeEx), call4.Name, (call4.ResponseType.Value == Type.String || call4.ResponseType.Value == Type.Other) ? "" : ".Value"); } } writer.WriteLine(indent + "\t}"); writer.WriteLine(indent + "}"); this.RequestWrap(writer, indent, name, true, true); this.RequestWrap(writer, indent, name, true, false); this.RequestWrap(writer, indent, name, false, true); this.RequestWrap(writer, indent, name, false, false); }