Ejemplo n.º 1
0
        ISharedObjectSymbolicLinkPolicy.Symlink(
            SharedObjectSymbolicLink sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.PreBuiltTool tool,
            ConsoleApplication target)
        {
            var meta = new MakeFileBuilder.MakeFileMeta(sender);
            var rule = meta.AddRule();

            // since this is not a referenced type, need to specify a variable name for the MakeFile
            var variableName = new System.Text.StringBuilder();

            variableName.Append(target.GetType().Name);                    // this is what it's building the symlink for
            variableName.Append("_");
            variableName.Append(sender.Macros["SymlinkUsage"].ToString()); // intended usage

            rule.AddTarget(sender.GeneratedPaths[SharedObjectSymbolicLink.Key], variableName: variableName.ToString());
            rule.AddPrerequisite(target, C.ConsoleApplication.Key);

            var commandLineArgs = new Bam.Core.StringArray();

            commandLineArgs.Add("-s");
            commandLineArgs.Add("-f");

            var command = new System.Text.StringBuilder();

            command.AppendFormat("{0} {1} $(notdir $<) $@ {2}",
                                 CommandLineProcessor.Processor.StringifyTool(tool),
                                 commandLineArgs.ToString(' '),
                                 CommandLineProcessor.Processor.TerminatingArgs(tool));
            rule.AddShellCommand(command.ToString());
        }
Ejemplo n.º 2
0
        ISharedObjectSymbolicLinkPolicy.Symlink(
            SharedObjectSymbolicLink sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.PreBuiltTool tool,
            ConsoleApplication target)
        {
            var commandLine = new Bam.Core.StringArray();

            commandLine.Add("-s");
            commandLine.Add("-f");
            var sourceFile = sender.CreateTokenizedString("@filename($(0))", target.GeneratedPaths[ConsoleApplication.Key]);

            lock (sourceFile)
            {
                if (!sourceFile.IsParsed)
                {
                    sourceFile.Parse();
                }
            }
            commandLine.Add(sourceFile.ToStringQuoteIfNecessary());
            var destination = sender.CreateTokenizedString("@dir($(0))/$(1)", target.GeneratedPaths[ConsoleApplication.Key], target.Macros[sender.Macros["SymlinkUsage"].ToString()]);

            lock (destination)
            {
                if (!destination.IsParsed)
                {
                    destination.Parse();
                }
            }
            commandLine.Add(destination.ToStringQuoteIfNecessary());
            CommandLineProcessor.Processor.Execute(context, tool, commandLine);
        }