Esempio n. 1
0
 public void DumpStats(IUserOutput output)
 {
     output.Message("Builder store statistics");
     output.Indent();
     output.Message("Total number of created builders: {0}", addCount);
     output.Message("Number of unique builders: {0}", instances.Count);
     output.Unindent();
 }
 public override void Dump(IUserOutput output)
 {
     output.Message("Project {0}.{1}'s properties:", project.Module.Name, project.Name);
     output.Indent();
     try
     {
         foreach (var prop in properties)
         {
             output.Message(prop);
         }
     }
     finally
     {
         output.Unindent();
     }
 }
Esempio n. 3
0
 public override void Dump(IUserOutput output)
 {
     output.Message("Project {0}.{1}'s properties:", project.Module.Name, project.Name);
     output.Indent();
     try
     {
         foreach (var prop in properties)
         {
             output.Message(prop);
         }
     }
     finally
     {
         output.Unindent();
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Runs this builder
        /// </summary>
        /// <param name="context">Current build context</param>
        /// <returns>Returns a set of generated files, in target relative paths</returns>
        public override ISet <TargetRelativePath> Run(IBuildContext context)
        {
            if (reference == null)
            {
                throw new InvalidOperationException("FS repository reference was not set on the builder");
            }

            if (reference != null && resolutionContext == null)
            {
                ResolveReference();
            }

            if (output != null)
            {
                output.Message(String.Format("Resolving reference {0}", reference.Uri));
            }

            log.DebugFormat("Resolving reference {0} using {1}", reference.Uri, resolvedPath);

            var depsRoot = targetRoot.CreateDirectory("deps");
            var depDir   = depsRoot.CreateDirectory(resolutionContext.DependencyName);

            string fileName = resolutionContext.FileName + "." + resolutionContext.Extension;

            if (fileName == "*.*")
            {
                return(DeployDirectoryContents(depDir, Path.GetDirectoryName(resolvedPath), ""));
            }
            else
            {
                return(DeploySingleFile(depDir, fileName));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Tries to get the command given by its name and prints its help string to the output
        /// </summary>
        /// <param name="cmdName">Name of the command</param>
        private void PrintCommandHelp(string cmdName)
        {
            var cmd = commandFactory.CreateCommand(cmdName);

            if (cmd == null)
            {
                throw new InvalidCommandParameterException(
                          "help",
                          string.Format("The given command ({0}) does no exist", cmdName));
            }
            else
            {
                output.Message(cmd.Help);
                output.Message(GlobalParameters);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Formatted message output
        /// </summary>
        /// <param name="output">Output interface to be used</param>
        /// <param name="format">Format string, used by <see cref="string.Format(string,object)"/></param>
        /// <param name="args">Parameters of the string formatting</param>
        public static void Message(this IUserOutput output, string format, params object[] args)
        {
            Contract.Requires(output != null);
            Contract.Requires(format != null);
            Contract.Requires(args != null);

            output.Message(string.Format(format, args));
        }
Esempio n. 7
0
        public bool Run(Suite suite, string[] parameters)
        {
            var data = new {
                products = suite.Products.Select(p => p.Name).ToArray(),
                goals    = suite.Goals.Select(g => g.Name).ToArray()
            };

            output.Message(JsonConvert.SerializeObject(data));

            return(true);
        }
Esempio n. 8
0
        private void RunWithProjects(CommandTarget target, bool dumpMode, bool dumpDepsMode)
        {
            log.InfoFormat("Building...");

            var context = buildContextFactory.CreateBuildContext();

            var projects = target.Projects.ToList();

            IBuilder rootBuilder = coreBuilderFactory.Merge(
                projectBuilders
                .Select(pb => pb.Create(projects))
                .Where(b => b != null).ToArray(),
                new ProjectBuilderTag("Top level project builders", projects));

            if (rootBuilder != null)
            {
                context.AddBuilder(rootBuilder);

                var productTarget = target as ProductTarget;
                if (productTarget != null)
                {
                    rootBuilder = AddProductBuildStep(context, productTarget.Product, rootBuilder);
                }

                if (dumpMode)
                {
                    context.Dump(name => targetRoot.CreateBinaryFile("builders." + name + ".dot"), rootBuilder);
                }
                else if (dumpDepsMode)
                {
                    context.DumpDependencies(rootBuilder, output);
                }
                else
                {
                    var result = context.Run(rootBuilder);

                    if (result.Count > 0)
                    {
                        var outputs = context.GetResults(rootBuilder);
                        foreach (var outputPath in outputs)
                        {
                            log.DebugFormat("Generated output for build: {0}", outputPath);
                        }
                    }
                    else
                    {
                        log.Warn("Build produced no results");
                    }
                }
            }

            output.Message("Build completed.");
        }
Esempio n. 9
0
        /// <summary>
        /// Runs the command
        /// </summary>
        /// <param name="suite">The current suite model the command is applied to</param>
        /// <param name="parameters">Parameters given to the command (in unprocessed form)</param>
        /// <returns>Returns <c>true</c> if the command succeeded</returns>
        public bool Run(Suite suite, string[] parameters)
        {
            var fileSystem = new ExtendedPhysicalFileSystem(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
            var updater    = new AppUpdaterBuilder(NUGET_PACKAGE_ID)
                             .FileSystemAccessedThrough(fileSystem)
                             .Build();

            output.Message("Checking for updates (current version: {0})...", updater.CurrentVersion);
            var check = updater.CheckForUpdate();

            if (check.UpdateAvailable)
            {
                output.Message("..found update: {0}", check.UpdatePackage.Version);
                output.Message("..preparing update..");
                var preparedUpdate = PrepareUpdate(updater, fileSystem, check.UpdatePackage);

                output.Message("..applying update..");
                updater.ApplyPreparedUpdate(preparedUpdate);

                output.Message("Update completed.");
                output.Warning("You should rebuild your suites with the updated bari before using them!");
            }
            else
            {
                output.Message("No updates available.");
            }
            return(true);
        }
Esempio n. 10
0
 public override void Dump(IUserOutput output)
 {
     output.Message(String.Format("Subtask {0}", subtask));
     output.Indent();
     try
     {
         subtask.Dependencies.Dump(output);
     }
     finally
     {
         output.Unindent();
     }
 }
Esempio n. 11
0
 public override void Dump(IUserOutput output)
 {
     output.Message(String.Format("Subtask {0}", subtask));
     output.Indent();
     try
     {
         subtask.Dependencies.Dump(output);
     }
     finally
     {
         output.Unindent();
     }
 }
Esempio n. 12
0
        /// <summary>
        /// Runs the main bari process
        /// </summary>
        public bool Run()
        {
            if (!parameters.QuietMode)
            {
                output.Message("bari version {0}\n", Assembly.GetAssembly(typeof(MainProcess)).GetName().Version.ToString());
            }

            var cmdPrereq = commandFactory.CreateCommandPrerequisites(parameters.Command);

            Suite suite;

            if (cmdPrereq == null || cmdPrereq.RequiresSuite)
            {
                suite = loader.Load(parameters.Suite);
                binding.Bind <Suite>().ToConstant(suite);

                explorer.RunAll(suite);
                suite.CheckForWarnings(output);
            }
            else
            {
                suite = new Suite(new LocalFileSystemDirectory(Path.GetTempPath()));
            }

            var cmd = commandFactory.CreateCommand(parameters.Command);

            if (cmd != null)
            {
                binding.Bind <ICommand>().ToConstant(cmd).WhenTargetHas <CurrentAttribute>();

                try
                {
                    return(cmd.Run(suite, parameters.CommandParameters));
                }
                finally
                {
#if DEBUG
                    if (!parameters.QuietMode)
                    {
                        builderStore.DumpStats(output);
                    }
#endif
                }
            }
            else
            {
                throw new InvalidCommandException(parameters.Command, "Unknown command");
            }
        }
Esempio n. 13
0
 public override void Dump(IUserOutput output)
 {
     output.Message(String.Format("Multiple dependencies ({0} subdeps)", dependencies.Count));
     output.Indent();
     try
     {
         foreach (var dep in dependencies)
         {
             dep.Dump(output);
         }
     }
     finally
     {
         output.Unindent();
     }
 }
Esempio n. 14
0
 public override void Dump(IUserOutput output)
 {
     output.Message(String.Format("Multiple dependencies ({0} subdeps)", dependencies.Count));
     output.Indent();
     try
     {
         foreach (var dep in dependencies)
         {
             dep.Dump(output);
         }
     }
     finally
     {
         output.Unindent();
     }
 }
Esempio n. 15
0
        /// <summary>
        /// Runs this builder
        /// </summary>
        /// <param name="context"> </param>
        /// <returns>Returns a set of generated files, in target relative paths</returns>
        public override ISet<TargetRelativePath> Run(IBuildContext context)
        {
            if (output != null)
                output.Message(String.Format("Resolving reference {0}", reference.Uri));

            string pkgName = reference.Uri.Host;
            string pkgVersion = reference.Uri.AbsolutePath.TrimStart('/');            

            var depsRoot = targetRoot.CreateDirectory("deps");
            var depDir = depsRoot.CreateDirectory(pkgName);

            var files = nuget.InstallPackage(pkgName, pkgVersion, depDir, "", dllsOnly: reference.Type == ReferenceType.Build, maxProfile: GetMaxProfile());
            var relativeRoot = Path.Combine(targetRoot.GetRelativePath(depDir), files.Item1);
            return new HashSet<TargetRelativePath>(
                from path in files.Item2
                let relativePath = path.Substring(files.Item1.Length).TrimStart(Path.DirectorySeparatorChar)
                select new TargetRelativePath(relativeRoot, relativePath));
        }
Esempio n. 16
0
        /// <summary>
        /// Runs this builder
        /// </summary>
        /// <param name="context">Current build context</param>
        /// <returns>Returns a set of generated files, in target relative paths</returns>
        public override ISet <TargetRelativePath> Run(IBuildContext context)
        {
            if (output != null)
            {
                output.Message(String.Format("Resolving reference {0}", reference.Uri));
            }

            var depsRoot   = targetRoot.CreateDirectory("deps");
            var sourcePath = reference.Uri.OriginalString.Substring(7).Replace('/', Path.DirectorySeparatorChar).TrimEnd(Path.DirectorySeparatorChar);
            var fileName   = Path.GetFileName(sourcePath);

            using (var source = new FileStream(sourcePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                using (var target = depsRoot.CreateBinaryFile(sourcePath))
                {
                    StreamOperations.Copy(source, target);
                }

            return(new HashSet <TargetRelativePath>(new[]
            {
                new TargetRelativePath(targetRoot.GetRelativePath(depsRoot), fileName)
            }));
        }
Esempio n. 17
0
        /// <summary>
        /// Runs this builder
        /// </summary>
        /// <param name="context">Current build context</param>
        /// <returns>Returns a set of generated files, in target relative paths</returns>
        public ISet <TargetRelativePath> Run(IBuildContext context)
        {
            if (output != null)
            {
                output.Message(String.Format("Resolving reference {0}", reference.Uri));
            }

            log.DebugFormat("Resolving reference {0} using {1}", reference.Uri, resolvedPath);

            var depsRoot = targetRoot.CreateDirectory("deps");
            var depDir   = depsRoot.CreateDirectory(resolutionContext.DependencyName);

            string fileName = resolutionContext.FileName + "." + resolutionContext.Extension;

            if (fileName == "*.*")
            {
                return(DeployDirectoryContents(depDir));
            }
            else
            {
                return(DeploySingleFile(depDir, fileName));
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Runs the main bari process
        /// </summary>
        public bool Run()
        {
            output.Message("bari version {0}\n", Assembly.GetAssembly(typeof(MainProcess)).GetName().Version.ToString());

            var suite = loader.Load(parameters.Suite);

            binding.Bind <Suite>().ToConstant(suite);

            explorer.RunAll(suite);
            suite.CheckForWarnings(output);

            var cmd = commandFactory.CreateCommand(parameters.Command);

            if (cmd != null)
            {
                binding.Bind <ICommand>().ToConstant(cmd).WhenTargetHas <CurrentAttribute>();
                return(cmd.Run(suite, parameters.CommandParameters));
            }
            else
            {
                throw new InvalidCommandException(parameters.Command, "Unknown command");
            }
        }
Esempio n. 19
0
        private void RunWithProjects(CommandTarget target, bool dumpMode)
        {
            log.InfoFormat("Building...");

            var context = buildContextFactory.CreateBuildContext();

            var projects = target.Projects.ToList();

            IBuilder rootBuilder = projectBuilders.Select(pb => pb.AddToContext(context, projects))
                                   .Where(b => b != null).ToArray().Merge();

            rootBuilder.AddToContext(context);

            if (dumpMode)
            {
                using (var builderGraph = targetRoot.CreateBinaryFile("builders.dot"))
                    context.Dump(builderGraph, rootBuilder);
            }
            else
            {
                context.Run(rootBuilder);

                var outputs = context.GetResults(rootBuilder);
                foreach (var outputPath in outputs)
                {
                    log.DebugFormat("Generated output for build: {0}", outputPath);
                }

                var productTarget = target as ProductTarget;
                if (productTarget != null)
                {
                    MergeOutputForProduct(productTarget.Product, outputs);
                }
            }

            output.Message("Build completed.");
        }
Esempio n. 20
0
 public override void Dump(IUserOutput output)
 {
     output.Message("no dependencies");
 }
Esempio n. 21
0
 public override void Dump(IUserOutput output)
 {
     output.Message(String.Format("Script source `{0}`", buildScript.Name));
 }
Esempio n. 22
0
 public override void Dump(IUserOutput output)
 {
     output.Message("Builder UID {0}", builder.Uid);
 }
Esempio n. 23
0
 public override void Dump(IUserOutput output)
 {
     output.Message("Builder UID {0}", builder.Uid);
 }
Esempio n. 24
0
 public override void Dump(IUserOutput output)
 {
     output.Message(String.Format("Script source `{0}`", buildScript.Name));
 }
Esempio n. 25
0
 public override void Dump(IUserOutput output)
 {
     output.Message("Reference {0}", reference.Uri);
 }
 public override void Dump(IUserOutput output)
 {
     output.Message(string.Format("FS repo: `{0}`", path));
 }
Esempio n. 27
0
 public override void Dump(IUserOutput output)
 {
     output.Message(string.Format("FS repo: `{0}`", path));
 }
Esempio n. 28
0
 public override void Dump(IUserOutput output)
 {
     output.Message("Reference {0}", reference.Uri);
 }
Esempio n. 29
0
 public override void Dump(IUserOutput output)
 {
     output.Message("no dependencies");
 }
Esempio n. 30
0
 public override void Dump(IUserOutput output)
 {
     output.Message(String.Format("Source set structure *{0}* ({1} files)", sourceSet.Type, sourceSet.Files.Count()));
 }
Esempio n. 31
0
        /// <summary>
        /// Runs the command
        /// </summary>
        /// <param name="suite">The current suite model the command is applied to</param>
        /// <param name="parameters">Parameters given to the command (in unprocessed form)</param>
        public bool Run(Suite suite, string[] parameters)
        {
            if (parameters.Length != 0)
            {
                throw new InvalidCommandParameterException("info",
                                                           "The 'info' command must be called without parameters!");
            }

            output.Message("*Suite name:* {0}\n", suite.Name);

            output.Message("*Modules:*");
            foreach (var module in suite.Modules)
            {
                PrintModuleDetails(module);
            }

            output.Message("*Products:*");
            foreach (var product in suite.Products)
            {
                PrintProductDetails(product);
            }

            return(true);
        }
Esempio n. 32
0
 public override void Dump(IUserOutput output)
 {
     output.Message(String.Format("Source set *{0}* ({1} files)", sourceSet.Type, sourceSet.Files.Count()));
 }
Esempio n. 33
0
 public override void Dump(IUserOutput output)
 {
     output.Message(String.Format("Project {0}.{1}'s parameter block {2}", project.Module.Name, project.Name, blockName));
 }
Esempio n. 34
0
 public override void Dump(IUserOutput output)
 {
     output.Message(String.Format("Project {0}.{1}'s parameter block {2}", project.Module.Name, project.Name, blockName));
 }