convertPaths( CollatedObject module, Bam.Core.TokenizedString inSourcePath, Bam.Core.TokenizedString inPublishingPath, out string resolvedSourcePath, out string resolvedDestinationDir) { resolvedSourcePath = inSourcePath.ToString(); if (module is CollatedDirectory) { // Windows XCOPY requires the directory name to be added to the destination regardless if (module.Macros.Contains("RenameLeaf")) { resolvedDestinationDir = System.String.Format("{0}{1}{2}{1}", inPublishingPath.ToString(), System.IO.Path.DirectorySeparatorChar, module.Macros["RenameLeaf"].ToString()); } else { resolvedDestinationDir = System.String.Format("{0}{1}{2}{1}", inPublishingPath.ToString(), System.IO.Path.DirectorySeparatorChar, System.IO.Path.GetFileName(inSourcePath.ToString())); } } else { resolvedDestinationDir = inPublishingPath.ToString(); } }
IZipToolPolicy.Zip( ZipModule sender, Bam.Core.ExecutionContext context, Bam.Core.TokenizedString zipOutputPath, Bam.Core.TokenizedString zipInputPath) { var encapsulating = sender.GetEncapsulatingReferencedModule(); var workspace = Bam.Core.Graph.Instance.MetaData as XcodeBuilder.WorkspaceMeta; var target = workspace.EnsureTargetExists(encapsulating); target.EnsureOutputFileReferenceExists( zipOutputPath, XcodeBuilder.FileReference.EFileType.ZipArchive, XcodeBuilder.Target.EProductType.Utility); var configuration = target.GetConfiguration(encapsulating); configuration.SetProductName(Bam.Core.TokenizedString.CreateVerbatim("PythonZip")); var commands = new Bam.Core.StringArray(); var args = new Bam.Core.StringArray(); args.Add(System.String.Format("cd {0} &&", Bam.Core.IOWrapper.EscapeSpacesInPath(zipInputPath.ToString()))); args.Add(CommandLineProcessor.Processor.StringifyTool(sender.Tool as Bam.Core.ICommandLineTool)); (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(args); args.Add(System.String.Format("{0}", Bam.Core.IOWrapper.EscapeSpacesInPath(zipOutputPath.ToString()))); args.Add("*"); args.Add("|| true"); // because zip returns 12 (nothing to do) upon success args.Add(CommandLineProcessor.Processor.TerminatingArgs(sender.Tool as Bam.Core.ICommandLineTool)); commands.Add(args.ToString(' ')); target.AddPreBuildCommands(commands, configuration); }
IArchivingPolicy.Archive( StaticLibrary sender, Bam.Core.ExecutionContext context, Bam.Core.TokenizedString libraryPath, System.Collections.ObjectModel.ReadOnlyCollection <Bam.Core.Module> objectFiles, System.Collections.ObjectModel.ReadOnlyCollection <Bam.Core.Module> headers) { if (sender.ReasonToExecute.Reason == Bam.Core.ExecuteReasoning.EReason.DeferredEvaluation) { if (!DeferredEvaluationRequiresBuild(sender, objectFiles)) { return; } } var commandLine = new Bam.Core.StringArray(); (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(commandLine); var libraryFileDir = System.IO.Path.GetDirectoryName(libraryPath.ToString()); Bam.Core.IOWrapper.CreateDirectoryIfNotExists(libraryFileDir); foreach (var input in objectFiles) { if (!(input as C.ObjectFileBase).PerformCompilation) { continue; } commandLine.Add(input.GeneratedPaths[C.ObjectFile.Key].ToString()); } CommandLineProcessor.Processor.Execute(context, sender.Tool as Bam.Core.ICommandLineTool, commandLine); }
IGeneratedSourcePolicy.GenerateSource( GeneratedSourceModule sender, Bam.Core.ExecutionContext context, Bam.Core.ICommandLineTool compiler, Bam.Core.TokenizedString generatedFilePath) { var encapsulating = sender.GetEncapsulatingReferencedModule(); var workspace = Bam.Core.Graph.Instance.MetaData as XcodeBuilder.WorkspaceMeta; var target = workspace.EnsureTargetExists(encapsulating); var configuration = target.GetConfiguration(encapsulating); var command = new System.Text.StringBuilder(); // recode the executable path for Xcode var xcodePath = encapsulating.CreateTokenizedString("$(packagebuilddir)/$(config)").Parse(); xcodePath += "/" + System.IO.Path.GetFileName(compiler.Executable.Parse()); command.AppendFormat(xcodePath); // TODO: change this to a configuration directory really command.AppendFormat(" {0}", Bam.Core.TokenizedString.Create("$(buildroot)", null).Parse()); command.AppendFormat(" {0}", "Generated"); var commands = new Bam.Core.StringArray(); commands.Add(command.ToString()); target.AddPreBuildCommands(commands, configuration); var compilerTarget = workspace.EnsureTargetExists(compiler as Bam.Core.Module); target.Requires(compilerTarget); }
IStripToolPolicy.Strip( StripModule sender, Bam.Core.ExecutionContext context, Bam.Core.TokenizedString originalPath, Bam.Core.TokenizedString copiedPath) { var meta = new MakeFileBuilder.MakeFileMeta(sender); var rule = meta.AddRule(); var sourceFilename = System.IO.Path.GetFileName(originalPath.Parse()); meta.CommonMetaData.Directories.AddUnique(sender.CreateTokenizedString("@dir($(0))", copiedPath).Parse()); rule.AddTarget(copiedPath, variableName: "strip_" + sourceFilename); var commandLine = new Bam.Core.StringArray(); (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(commandLine); rule.AddShellCommand(System.String.Format("{0} {1} {2} -o {3} {4}", CommandLineProcessor.Processor.StringifyTool(sender.Tool as Bam.Core.ICommandLineTool), commandLine.ToString(' '), originalPath.Parse(), copiedPath.Parse(), CommandLineProcessor.Processor.TerminatingArgs(sender.Tool as Bam.Core.ICommandLineTool))); }
SetOutputPath( Bam.Core.TokenizedString path) { var macros = new Bam.Core.MacroList(); // TODO: ideally, $(ProjectDir) should replace the following directory separator as well, // but it does not seem to be a show stopper if it doesn't macros.Add("packagebuilddir", Bam.Core.TokenizedString.CreateVerbatim("$(ProjectDir)")); macros.Add("modulename", Bam.Core.TokenizedString.CreateVerbatim("$(ProjectName)")); var outDir = path.UncachedParse(new Bam.Core.Array <Bam.Core.MacroList>(macros)); outDir = System.IO.Path.GetDirectoryName(outDir); outDir += "\\"; this.OutputDirectory = outDir; var targetNameTS = this.Module.CreateTokenizedString("@basename($(0))", path); targetNameTS.Parse(); var targetName = targetNameTS.ToString(); if (!string.IsNullOrEmpty(targetName)) { var filenameTS = this.Module.CreateTokenizedString("@filename($(0))", path); filenameTS.Parse(); var filename = filenameTS.ToString(); var ext = filename.Replace(targetName, string.Empty); this.TargetName = targetName; this.TargetExt = ext; } }
AddOtherFile( Bam.Core.TokenizedString other_path) { var otherGroup = this.Project.GetUniqueSettingsGroup(this.Module, VSSettingsGroup.ESettingsGroup.CustomBuild, other_path); this.Project.AddOtherFile(otherGroup); }
ICompilationPolicy.Compile( ObjectFile sender, Bam.Core.ExecutionContext context, Bam.Core.TokenizedString objectFilePath, Bam.Core.Module source) { var commandLineArgs = new Bam.Core.StringArray(); (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(commandLineArgs); var meta = new MakeFileBuilder.MakeFileMeta(sender); var rule = meta.AddRule(); rule.AddTarget(objectFilePath); rule.AddPrerequisite(source, C.SourceFile.Key); var tool = sender.Tool as Bam.Core.ICommandLineTool; var command = new System.Text.StringBuilder(); command.AppendFormat("{0} {1} $< {2}", CommandLineProcessor.Processor.StringifyTool(tool), commandLineArgs.ToString(' '), CommandLineProcessor.Processor.TerminatingArgs(tool)); rule.AddShellCommand(command.ToString()); var objectFileDir = System.IO.Path.GetDirectoryName(objectFilePath.ToString()); meta.CommonMetaData.Directories.AddUnique(objectFileDir); meta.CommonMetaData.ExtendEnvironmentVariables(tool.EnvironmentVariables); }
public Target( Bam.Core.TokenizedString nameOrOutput, bool isPhony, string variableName, Bam.Core.Module module, int count) { this.Path = nameOrOutput; this.IsPhony = isPhony; if (isPhony) { return; } if (count > 0) { return; } if (Bam.Core.Graph.Instance.IsReferencedModule(module) || !System.String.IsNullOrEmpty(variableName)) { // make the target names unique across configurations if (System.String.IsNullOrEmpty(variableName)) { this.VariableName = System.String.Format("{0}_{1}", module.GetType().Name, module.BuildEnvironment.Configuration.ToString()); } else { this.VariableName = System.String.Format("{0}_{1}", variableName, module.BuildEnvironment.Configuration.ToString()); } } }
protected override void EvaluateInternal() { this.ReasonToExecute = null; // assume it doesn't need updating until you find a reason for it to... Bam.Core.TokenizedString newest_output_file_path = null; System.DateTime newest_output_file_date = System.DateTime.MinValue; foreach (var output in this.InternalExpectedOutputFileDictionary) { var path = output.Value.ToString(); if (!System.IO.File.Exists(path)) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.FileDoesNotExist(output.Value); return; } var writeTime = System.IO.File.GetLastWriteTime(path); if (writeTime > newest_output_file_date) { newest_output_file_path = output.Value; newest_output_file_date = writeTime; } } foreach (var input in this.InputFiles) { var path = input.Value.ToString(); var writeTime = System.IO.File.GetLastWriteTime(path); if (writeTime > newest_output_file_date) { this.ReasonToExecute = Bam.Core.ExecuteReasoning.InputFileNewer(newest_output_file_path, input.Value); return; } } }
IExternalSourceGeneratorPolicy.GenerateSource( ExternalSourceGenerator sender, Bam.Core.ExecutionContext context, Bam.Core.TokenizedString executable, Bam.Core.TokenizedStringArray arguments, Bam.Core.TokenizedString output_directory, System.Collections.Generic.IReadOnlyDictionary <string, Bam.Core.TokenizedString> expected_output_files, System.Collections.Generic.IReadOnlyDictionary <string, Bam.Core.TokenizedString> input_files ) { Bam.Core.IOWrapper.CreateDirectoryIfNotExists(output_directory.ToString()); var program = executable.ToStringQuoteIfNecessary(); var linearised_args = arguments.ToString(' '); Bam.Core.Log.Info("Running: {0} {1}", program, linearised_args); Bam.Core.OSUtilities.RunExecutable(program, linearised_args); foreach (var expected_file in expected_output_files) { if (!System.IO.File.Exists(expected_file.Value.ToString())) { throw new Bam.Core.Exception( "Expected '{0}' to exist (key={1}), but it does not", expected_file.Value.ToString(), expected_file.Key ); } } }
IInstallNameToolPolicy.InstallName( InstallNameModule sender, Bam.Core.ExecutionContext context, Bam.Core.TokenizedString oldName, Bam.Core.TokenizedString newName) { var originalModule = (sender.Source as ICollatedObject).SourceModule; if (originalModule == null) { return; } var commandLine = new Bam.Core.StringArray(); (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(commandLine); var commands = new Bam.Core.StringArray(); // TODO: check what happens for prebuilt modules (there shouldn't be any metadata) commands.Add(System.String.Format("{0} {1} {2} {3} {4} {5}", CommandLineProcessor.Processor.StringifyTool(sender.Tool as Bam.Core.ICommandLineTool), commandLine.ToString(' '), oldName.ToString(), newName.ToString(), sender.Source.GeneratedPaths[CollatedObject.Key].ToString(), CommandLineProcessor.Processor.TerminatingArgs(sender.Tool as Bam.Core.ICommandLineTool))); var target = originalModule.MetaData as XcodeBuilder.Target; var configuration = target.GetConfiguration(originalModule); target.AddPostBuildCommands(commands, configuration); }
IExternalSourceGeneratorPolicy.GenerateSource( ExternalSourceGenerator sender, Bam.Core.ExecutionContext context, Bam.Core.TokenizedString executable, Bam.Core.TokenizedStringArray arguments, Bam.Core.TokenizedString output_directory, System.Collections.Generic.IReadOnlyDictionary <string, Bam.Core.TokenizedString> expected_output_files, System.Collections.Generic.IReadOnlyDictionary <string, Bam.Core.TokenizedString> input_files ) { var encapsulating = sender.GetEncapsulatingReferencedModule(); var solution = Bam.Core.Graph.Instance.MetaData as VSSolutionBuilder.VSSolution; var project = solution.EnsureProjectExists(encapsulating); var config = project.GetConfiguration(encapsulating); var args = new Bam.Core.StringArray(); args.Add(System.String.Format("{0} {1}", executable.ToStringQuoteIfNecessary(), arguments.ToString(' '))); foreach (var input in input_files.Values) { config.AddOtherFile(input); var customBuild = config.GetSettingsGroup( VSSolutionBuilder.VSSettingsGroup.ESettingsGroup.CustomBuild, include: input, uniqueToProject: true ); customBuild.AddSetting("Command", args.ToString(' '), condition: config.ConditionText); customBuild.AddSetting("Message", System.String.Format("Generating outputs from {0}", input.ToString()), condition: config.ConditionText); customBuild.AddSetting("Outputs", expected_output_files.Values, condition: config.ConditionText); customBuild.AddSetting("AdditionalInputs", input_files.Values, condition: config.ConditionText); } }
convertPaths( CollatedObject module, Bam.Core.TokenizedString inSourcePath, Bam.Core.TokenizedString inPublishingPath, out string resolvedSourcePath, out string resolvedDestinationDir) { if (module is CollatedDirectory) { // Posix cp only requires the destination to be added when there is a rename if (module.Macros.Contains("RenameLeaf")) { resolvedSourcePath = System.String.Format("{0}{1}*", inSourcePath.ToString(), System.IO.Path.DirectorySeparatorChar); resolvedDestinationDir = System.String.Format("{0}{1}{2}{1}", inPublishingPath.ToString(), System.IO.Path.DirectorySeparatorChar, module.Macros["RenameLeaf"].ToString()); } else { resolvedSourcePath = inSourcePath.ToString(); resolvedDestinationDir = inPublishingPath.ToString(); } } else { resolvedSourcePath = inSourcePath.ToString(); resolvedDestinationDir = inPublishingPath.ToString(); } }
IZipToolPolicy.Zip( ZipModule sender, Bam.Core.ExecutionContext context, Bam.Core.TokenizedString zipOutputPath, Bam.Core.TokenizedString zipInputPath) { var zipDir = System.IO.Path.GetDirectoryName(zipOutputPath.ToString()); Bam.Core.IOWrapper.CreateDirectoryIfNotExists(zipDir); var commandLine = new Bam.Core.StringArray(); (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(commandLine); if (sender.Tool is ZipPosix) { commandLine.Add("-o"); commandLine.Add(Bam.Core.IOWrapper.EscapeSpacesInPath(zipOutputPath.ToString())); } else { commandLine.Add(zipOutputPath.ToStringQuoteIfNecessary()); } commandLine.Add("*"); CommandLineProcessor.Processor.Execute( context, sender.Tool as Bam.Core.ICommandLineTool, commandLine, zipInputPath.ToString() ); }
public Target( Bam.Core.TokenizedString nameOrOutput, bool isPhony, string variableName, Bam.Core.Module module, int ruleIndex) { this.Path = nameOrOutput; this.IsPhony = isPhony; this.IsPrerequisiteofAll = Bam.Core.Graph.Instance.IsReferencedModule(module) || !System.String.IsNullOrEmpty(variableName); if (isPhony) { return; } if (ruleIndex > 0) { return; } if (this.IsPrerequisiteofAll) { // make the target names unique across configurations if (System.String.IsNullOrEmpty(variableName)) { this.VariableName = System.String.Format("{0}_{1}", module.GetType().Name, module.BuildEnvironment.Configuration.ToString()); } else { variableName = System.String.Format("{0}_{1}", variableName, module.BuildEnvironment.Configuration.ToString()); MakeFileMeta.MakeVariableNameUnique(ref variableName); this.VariableName = variableName; } } }
IArchivingPolicy.Archive( StaticLibrary sender, Bam.Core.ExecutionContext context, Bam.Core.TokenizedString libraryPath, System.Collections.ObjectModel.ReadOnlyCollection <Bam.Core.Module> objectFiles, System.Collections.ObjectModel.ReadOnlyCollection <Bam.Core.Module> headers) { var commandLineArgs = new Bam.Core.StringArray(); (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(commandLineArgs); var meta = new MakeFileBuilder.MakeFileMeta(sender); var rule = meta.AddRule(); rule.AddTarget(libraryPath); foreach (var input in objectFiles) { rule.AddPrerequisite(input, C.ObjectFile.Key); } var tool = sender.Tool as Bam.Core.ICommandLineTool; var command = new System.Text.StringBuilder(); command.AppendFormat("{0} {1} $^ {2}", CommandLineProcessor.Processor.StringifyTool(tool), commandLineArgs.ToString(' '), CommandLineProcessor.Processor.TerminatingArgs(tool)); rule.AddShellCommand(command.ToString()); var libraryFileDir = System.IO.Path.GetDirectoryName(libraryPath.ToString()); meta.CommonMetaData.Directories.AddUnique(libraryFileDir); meta.CommonMetaData.ExtendEnvironmentVariables(tool.EnvironmentVariables); }
IZipToolPolicy.Zip( ZipModule sender, Bam.Core.ExecutionContext context, Bam.Core.TokenizedString zipOutputPath, Bam.Core.TokenizedString zipInputPath) { var meta = new MakeFileBuilder.MakeFileMeta(sender); var rule = meta.AddRule(); var dir = sender.CreateTokenizedString("@dir($(0))", zipOutputPath); dir.Parse(); meta.CommonMetaData.AddDirectory(dir.ToString()); rule.AddTarget(zipOutputPath); var commandLine = new Bam.Core.StringArray(); (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(commandLine); var args = new Bam.Core.StringArray(); args.Add(System.String.Format("cd {0};", zipInputPath.ToString())); args.Add( System.String.Format("{0} {1} -o {2} {3} {4}", CommandLineProcessor.Processor.StringifyTool(sender.Tool as Bam.Core.ICommandLineTool), commandLine.ToString(' '), zipOutputPath.ToString(), "*", CommandLineProcessor.Processor.TerminatingArgs(sender.Tool as Bam.Core.ICommandLineTool) ) ); rule.AddShellCommand(args.ToString(' ')); }
GetSettingsGroup( VSSettingsGroup.ESettingsGroup group, Bam.Core.TokenizedString include = null, bool uniqueToProject = false) { lock (this.SettingGroups) { foreach (var settings in this.SettingGroups) { if (null == include) { if ((null == settings.Include) && (settings.Group == group)) { return(settings); } } else { // ignore group, as files can mutate between them during the buildprocess (e.g. headers into custom builds) // TODO: can this be a TokenizedString hash compare? if ((null != include) && (settings.Include.ToString() == include.ToString())) { return(settings); } } } var newGroup = uniqueToProject ? this.Project.GetUniqueSettingsGroup(this.Module, group, include) : new VSSettingsGroup(this.Project, this.Module, group, include); this.SettingGroups.Add(newGroup); return(newGroup); } }
IGeneratedSourcePolicy.GenerateSource( GeneratedSourceModule sender, Bam.Core.ExecutionContext context, Bam.Core.ICommandLineTool compiler, Bam.Core.TokenizedString generatedFilePath) { var meta = new MakeFileBuilder.MakeFileMeta(sender); var rule = meta.AddRule(); rule.AddTarget(generatedFilePath); var buildTool = (compiler as Bam.Core.Module).MetaData as MakeFileBuilder.MakeFileMeta; rule.AddOrderOnlyDependency(System.String.Format("$({0})", buildTool.Rules[0].FirstTarget.VariableName)); // TODO: change this to a configuration directory really var output_dir = Bam.Core.IOWrapper.EncloseSpaceContainingPathWithDoubleQuotes(Bam.Core.Graph.Instance.BuildRoot); var commandLineArgs = new Bam.Core.StringArray(); commandLineArgs.Add(output_dir); commandLineArgs.Add("Generated"); var command = new System.Text.StringBuilder(); command.AppendFormat("{0} {1} $^", compiler.Executable.ToStringQuoteIfNecessary(), commandLineArgs.ToString(' ')); rule.AddShellCommand(command.ToString()); }
IAssemblerPolicy.Assemble( AssembledObjectFile sender, Bam.Core.ExecutionContext context, Bam.Core.TokenizedString objectFilePath, Bam.Core.Module source) { if (!sender.PerformCompilation) { return; } var meta = new MakeFileBuilder.MakeFileMeta(sender); var rule = meta.AddRule(); rule.AddTarget(objectFilePath); rule.AddPrerequisite(source, C.SourceFile.Key); var outputPath = objectFilePath.Parse(); var args = new Bam.Core.StringArray(); args.Add(CommandLineProcessor.Processor.StringifyTool(sender.Tool as Bam.Core.ICommandLineTool)); (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(args); args.Add("$<"); rule.AddShellCommand(args.ToString(' ')); meta.CommonMetaData.AddDirectory(System.IO.Path.GetDirectoryName(outputPath)); }
ICompilationPolicy.Compile( ObjectFile sender, Bam.Core.ExecutionContext context, Bam.Core.TokenizedString objectFilePath, Bam.Core.Module source) { if (!sender.PerformCompilation) { return; } if (sender.ReasonToExecute.Reason == Bam.Core.ExecuteReasoning.EReason.DeferredEvaluation) { if (!DeferredEvaluationRequiresBuild(sender)) { return; } } var objectFileDir = System.IO.Path.GetDirectoryName(objectFilePath.ToString()); Bam.Core.IOWrapper.CreateDirectoryIfNotExists(objectFileDir); var commandLine = new Bam.Core.StringArray(); (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(commandLine); commandLine.Add(source.GeneratedPaths[SourceFile.Key].ParseAndQuoteIfNecessary()); CommandLineProcessor.Processor.Execute(context, sender.Tool as Bam.Core.ICommandLineTool, commandLine); }
IArchivingPolicy.Archive( StaticLibrary sender, Bam.Core.ExecutionContext context, Bam.Core.TokenizedString libraryPath, System.Collections.ObjectModel.ReadOnlyCollection <Bam.Core.Module> objectFiles, System.Collections.ObjectModel.ReadOnlyCollection <Bam.Core.Module> headers) { var commandLine = new Bam.Core.StringArray(); (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(commandLine); var libraryFileDir = System.IO.Path.GetDirectoryName(libraryPath.ToString()); if (!System.IO.Directory.Exists(libraryFileDir)) { System.IO.Directory.CreateDirectory(libraryFileDir); } foreach (var input in objectFiles) { commandLine.Add(input.GeneratedPaths[C.ObjectFile.Key].ToString()); } CommandLineProcessor.Processor.Execute(context, sender.Tool as Bam.Core.ICommandLineTool, commandLine); }
IAssemblerPolicy.Assemble( AssembledObjectFile sender, Bam.Core.ExecutionContext context, Bam.Core.TokenizedString objectFilePath, Bam.Core.Module source) { var encapsulating = sender.GetEncapsulatingReferencedModule(); var solution = Bam.Core.Graph.Instance.MetaData as VSSolutionBuilder.VSSolution; var project = solution.EnsureProjectExists(encapsulating); var config = project.GetConfiguration(encapsulating); var output = objectFilePath.Parse(); var args = new Bam.Core.StringArray(); args.Add(CommandLineProcessor.Processor.StringifyTool(sender.Tool as Bam.Core.ICommandLineTool)); (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(args); args.Add("%(FullPath)"); var customBuild = config.GetSettingsGroup(VSSolutionBuilder.VSSettingsGroup.ESettingsGroup.CustomBuild, include: sender.InputPath, uniqueToProject: true); customBuild.AddSetting("Command", args.ToString(' '), condition: config.ConditionText); customBuild.AddSetting("Message", System.String.Format("Assembling {0}", System.IO.Path.GetFileName(sender.InputPath.Parse())), condition: config.ConditionText); customBuild.AddSetting("Outputs", output, condition: config.ConditionText); sender.MetaData = customBuild; }
IObjCopyToolPolicy.ObjCopy( ObjCopyModule sender, Bam.Core.ExecutionContext context, Bam.Core.TokenizedString originalPath, Bam.Core.TokenizedString copiedPath) { var mode = (sender.Settings as IObjCopyToolSettings).Mode; // if linking debug data, add to the strip var meta = (EObjCopyToolMode.AddGNUDebugLink == mode) ? sender.SourceModule.MetaData as MakeFileBuilder.MakeFileMeta : new MakeFileBuilder.MakeFileMeta(sender); var rule = (EObjCopyToolMode.AddGNUDebugLink == mode) ? meta.Rules[0] :meta.AddRule(); if (EObjCopyToolMode.AddGNUDebugLink == mode) { rule.AddOrderOnlyDependency(copiedPath.Parse()); } else { meta.CommonMetaData.AddDirectory(sender.CreateTokenizedString("@dir($(0))", copiedPath).Parse()); var sourceFilename = System.IO.Path.GetFileName(originalPath.Parse()); rule.AddTarget(copiedPath, variableName: "objcopy_" + sourceFilename); rule.AddPrerequisite(originalPath); } var commandLine = new Bam.Core.StringArray(); (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(commandLine); rule.AddShellCommand(System.String.Format("{0} {1} {2}", CommandLineProcessor.Processor.StringifyTool(sender.Tool as Bam.Core.ICommandLineTool), commandLine.ToString(' '), CommandLineProcessor.Processor.TerminatingArgs(sender.Tool as Bam.Core.ICommandLineTool))); }
IGeneratedSourcePolicy.GenerateSource( GeneratedSourceModule sender, Bam.Core.ExecutionContext context, Bam.Core.ICommandLineTool compiler, Bam.Core.TokenizedString generatedFilePath) { var meta = new MakeFileBuilder.MakeFileMeta(sender); var rule = meta.AddRule(); rule.AddTarget(generatedFilePath); var buildTool = (compiler as Bam.Core.Module).MetaData as MakeFileBuilder.MakeFileMeta; rule.AddOrderOnlyDependency(System.String.Format("$({0})", buildTool.Rules[0].Targets[0].VariableName)); var commandLineArgs = new Bam.Core.StringArray(); // TODO: change this to a configuration directory really commandLineArgs.Add(Bam.Core.TokenizedString.Create("$(buildroot)", null).Parse()); commandLineArgs.Add("Generated"); var command = new System.Text.StringBuilder(); command.AppendFormat("{0} {1} $^", compiler.Executable.ParseAndQuoteIfNecessary(), commandLineArgs.ToString(' ')); rule.AddShellCommand(command.ToString()); }
CreateGroupHierarchy( Bam.Core.TokenizedString path) { Group group = null; lock (this.Project) { var found = this.Project.GroupMap.Where(item => item.Key == path.Parse()).FirstOrDefault(); if (!found.Equals(default(System.Collections.Generic.KeyValuePair <string, Group>))) { return(found.Value); } var basename = this.Module.CreateTokenizedString("@basename($(0))", path).Parse(); group = new Group(basename); this.Project.Groups.Add(group); this.Project.GroupMap.Add(path.Parse(), group); if (path.Parse().Contains(System.IO.Path.DirectorySeparatorChar)) { var parent = this.Module.CreateTokenizedString("@dir($(0))", path); var parentGroup = this.CreateGroupHierarchy(parent); parentGroup.AddChild(group); } } return(group); }
ITarPolicy.CreateTarBall( TarBall sender, Bam.Core.ExecutionContext context, Bam.Core.ICommandLineTool compiler, Bam.Core.TokenizedString scriptPath, Bam.Core.TokenizedString outputPath) { var tarPath = outputPath.ToString(); var tarDir = System.IO.Path.GetDirectoryName(tarPath); if (!System.IO.Directory.Exists(tarDir)) { System.IO.Directory.CreateDirectory(tarDir); } var commandLine = new Bam.Core.StringArray(); (sender.Settings as CommandLineProcessor.IConvertToCommandLine).Convert(commandLine); commandLine.Add("-c"); commandLine.Add("-v"); commandLine.Add("-T"); commandLine.Add(scriptPath.Parse()); commandLine.Add("-f"); commandLine.Add(tarPath); CommandLineProcessor.Processor.Execute(context, compiler, commandLine); }
GetUniqueSettingsGroup( Bam.Core.Module module, VSSettingsGroup.ESettingsGroup group, Bam.Core.TokenizedString include = null) { lock (this.ProjectSettings) { foreach (var settings in this.ProjectSettings) { if (null == include) { if ((null == settings.Include) && (settings.Group == group)) { return(settings); } } else { // ignore group, as files can mutate between them during the buildprocess (e.g. headers into custom builds) if (settings.Include.Parse() == include.Parse()) { return(settings); } } } var newGroup = new VSSettingsGroup(module, group, include); this.ProjectSettings.Add(newGroup); return(newGroup); } }
public Path( Bam.Core.TokenizedString source, Bam.Core.TokenizedString destination = null) { this.SourcePath = source; this.DestinationPath = destination; }