Exemplo n.º 1
0
        public IEnumerable <TargetRelativePath> GetAllResultsIn(TargetRelativePath targetDir)
        {
            Contract.Requires(targetDir != null);
            Contract.Ensures(Contract.Result <IEnumerable <TargetRelativePath> >() != null);

            return(null); // dummy
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructs the builder
 /// </summary>
 /// <param name="slnBuilder">Sub task building the solution file, used as a dependency</param>
 /// <param name="slnPath">Path of the generated solution file</param>
 /// <param name="version">MSBuild version to use</param>
 /// <param name="targetRoot">Target directory</param>
 /// <param name="msbuildFactory">Factory to get the MSBuild implementation to use</param>
 public MSBuildRunner(SlnBuilder slnBuilder, TargetRelativePath slnPath, MSBuildVersion version,
                      [TargetRoot] IFileSystemDirectory targetRoot, IMSBuildFactory msbuildFactory)
 {
     this.slnBuilder = slnBuilder;
     this.slnPath    = slnPath;
     this.targetRoot = targetRoot;
     msbuild         = msbuildFactory.CreateMSBuild(version);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Constructs the builder
 /// </summary>
 /// <param name="slnBuilder">Sub task building the solution file, used as a dependency</param>
 /// <param name="slnPath">Path of the generated solution file</param>
 /// <param name="targetRoot">Target directory</param>
 /// <param name="msbuild">The MSBuild implementation to use</param>
 public MSBuildRunner(SlnBuilder slnBuilder, TargetRelativePath slnPath,
                      [TargetRoot] IFileSystemDirectory targetRoot, IMSBuild msbuild)
 {
     this.slnBuilder = slnBuilder;
     this.slnPath    = slnPath;
     this.targetRoot = targetRoot;
     this.msbuild    = msbuild;
 }
Exemplo n.º 4
0
        public void Compile(SuiteRelativePath scriptPath, TargetRelativePath targetPath, string version, Goal targetGoal)
        {
            var platform = targetGoal.Has("x64") ? "x64" : "x86";

            Run(suiteRoot,
                "/dVERSION=" + version,
                "/dPLATFORM=" + platform,
                "/dGOAL=" + targetGoal.Name,
                "/o" + Path.GetDirectoryName(Path.Combine(suiteRoot.GetRelativePath(targetRoot), targetPath)),
                scriptPath);
        }
Exemplo n.º 5
0
        public void Compile(SuiteRelativePath scriptPath, TargetRelativePath targetPath, string version, Goal targetGoal)
        {
            var platform = targetGoal.Has("x64") ? "x64" : "x86";

            Run(suiteRoot,
                "/dVERSION="+version,
                "/dPLATFORM="+platform,
                "/dGOAL="+targetGoal.Name,
                "/o"+Path.GetDirectoryName(Path.Combine(suiteRoot.GetRelativePath(targetRoot), targetPath)),
                scriptPath);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets all the result files under the given subdirectory of target root
        /// </summary>
        /// <param name="targetDir">Subdirectory of target</param>
        /// <returns>An enumeration of target relative paths all pointing to files
        /// generated under the current build context to the given subdirectory or one of
        /// its children.</returns>
        public IEnumerable <TargetRelativePath> GetAllResultsIn(TargetRelativePath targetDir)
        {
            var prefix = (string)targetDir;

            if (prefix[prefix.Length - 1] != Path.DirectorySeparatorChar)
            {
                prefix += Path.DirectorySeparatorChar;
            }

            return(partialResults.Values.SelectMany(ps => ps.Where(p => ((string)p).StartsWith(prefix))));
        }
Exemplo n.º 7
0
 private bool IsValidReference(TargetRelativePath reference)
 {
     if (IsGACReference(reference) || IsSolutionReference(reference))
     {
         return(true);
     }
     else
     {
         var extension = Path.GetExtension(reference);
         if (extension != null)
         {
             return(allowedExtensions.Contains(extension.ToLowerInvariant()));
         }
         else
         {
             return(false);
         }
     }
 }
        private TargetRelativePath GenerateAddonSupportFile(string solutionName)
        {
            string contents = AddonSupportData();
            var path = new TargetRelativePath("", solutionName + ".yaml");
            bool writeFile = true;

            if (targetRoot.Exists(path.RelativePath))
            {
                using (var reader = targetRoot.ReadTextFile(path.RelativePath))
                {
                    string existingContents = reader.ReadToEnd();
                    writeFile = existingContents != contents;
                }
            }

            if (writeFile)
            {
                using (var writer = targetRoot.CreateTextFile(path.RelativePath))
                    writer.WriteLine(contents);
            }

            return path;
        }
Exemplo n.º 9
0
        private TargetRelativePath GenerateAddonSupportFile(string solutionName)
        {
            string contents  = AddonSupportData();
            var    path      = new TargetRelativePath("", solutionName + ".yaml");
            bool   writeFile = true;

            if (targetRoot.Exists(path.RelativePath))
            {
                using (var reader = targetRoot.ReadTextFile(path.RelativePath))
                {
                    string existingContents = reader.ReadToEnd();
                    writeFile = existingContents != contents;
                }
            }

            if (writeFile)
            {
                using (var writer = targetRoot.CreateTextFile(path.RelativePath))
                    writer.WriteLine(contents);
            }

            return(path);
        }
Exemplo n.º 10
0
 private static bool IsSolutionReference(TargetRelativePath refPath)
 {
     return(((string)refPath).StartsWith("SLN!"));
 }
Exemplo n.º 11
0
        public IEnumerable<TargetRelativePath> GetAllResultsIn(TargetRelativePath targetDir)
        {
            Contract.Requires(targetDir != null);
            Contract.Ensures(Contract.Result<IEnumerable<TargetRelativePath>>() != null);

            return null; // dummy
        }
Exemplo n.º 12
0
 private void Copy(TargetRelativePath sourcePath, string relativePath)
 {
     using (var source = targetRoot.ReadBinaryFile(sourcePath))
         using (var target = targetDirectory.CreateBinaryFileWithDirectories(relativePath))
             StreamOperations.Copy(source, target);
 }
Exemplo n.º 13
0
 private static bool IsGACReference(TargetRelativePath refPath)
 {
     return ((string) refPath).StartsWith("GAC!");
 }
Exemplo n.º 14
0
 private static bool IsSolutionReference(TargetRelativePath refPath)
 {
     return ((string)refPath).StartsWith("SLN!");
 }
Exemplo n.º 15
0
 private bool IsValidReference(TargetRelativePath reference)
 {
     if (IsGACReference(reference) || IsSolutionReference(reference))
         return true;
     else
     {
         var extension = Path.GetExtension(reference);
         if (extension != null)
         {
             return allowedExtensions.Contains(extension.ToLowerInvariant());
         }
         else
         {
             return false;
         }
     }
 }
Exemplo n.º 16
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)
        {
            // Collecting all the files already existing in 'targetdir/modulename' directories
            var targetDirs      = new HashSet <string>(slnBuilder.Projects.Select(GetTargetDir));
            var existingFiles   = new Dictionary <TargetRelativePath, DateTime>();
            var expectedOutputs =
                new HashSet <TargetRelativePath>(slnBuilder.Projects.SelectMany(GetExpectedProjectOutputs).Union(GetDependencyResults(context)));

            foreach (var targetDir in targetDirs)
            {
                var moduleTargetDir = targetRoot.GetChildDirectory(targetDir);
                if (moduleTargetDir != null)
                {
                    foreach (var fileName in moduleTargetDir.Files)
                    {
                        existingFiles.Add(new TargetRelativePath(targetDir, fileName), moduleTargetDir.GetLastModifiedDate(fileName));
                    }
                }
            }

            msbuild.Run(targetRoot, slnPath);

            // Collecting all the files in 'targetdir/modulename' directories as results
            var outputs = new HashSet <TargetRelativePath>();

            foreach (var targetDir in targetDirs)
            {
                var moduleTargetDir = targetRoot.GetChildDirectory(targetDir);
                if (moduleTargetDir != null)
                {
                    moduleTargetDir.InvalidateCacheFileData();

                    foreach (var fileName in moduleTargetDir.Files)
                    {
                        var relativePath = new TargetRelativePath(targetDir, fileName);
                        var lastModified = moduleTargetDir.GetLastModifiedDate(fileName);

                        bool isNew = false;
                        if (expectedOutputs.Contains(relativePath))
                        {
                            isNew = true;
                        }
                        else
                        {
                            DateTime previousLastModified;
                            if (existingFiles.TryGetValue(relativePath, out previousLastModified))
                            {
                                if (lastModified != previousLastModified)
                                {
                                    isNew = true;
                                }
                            }
                            else
                            {
                                isNew = true;
                            }
                        }

                        if (isNew)
                        {
                            outputs.Add(relativePath);
                        }
                    }
                }
            }

            foreach (var targetDir in targetDirs)
            {
                outputs.ExceptWith(context.GetAllResultsIn(new TargetRelativePath(targetDir, String.Empty)));
            }

            return(outputs);
        }
Exemplo n.º 17
0
 public MSBuildRunner CreateMSBuildRunner(SlnBuilder slnBuilder, TargetRelativePath slnPath, MSBuildVersion version)
 {
     return(store.Add(baseImpl.CreateMSBuildRunner(slnBuilder, slnPath, version)));
 }
Exemplo n.º 18
0
        /// <summary>
        /// Gets all the result files under the given subdirectory of target root
        /// </summary>
        /// <param name="targetDir">Subdirectory of target</param>
        /// <returns>An enumeration of target relative paths all pointing to files 
        /// generated under the current build context to the given subdirectory or one of 
        /// its children.</returns>
        public IEnumerable<TargetRelativePath> GetAllResultsIn(TargetRelativePath targetDir)
        {
            var prefix = (string)targetDir;
            if (prefix[prefix.Length - 1] != Path.DirectorySeparatorChar)
                prefix += Path.DirectorySeparatorChar;

            return partialResults.Values.SelectMany(ps => ps.Where(p => ((string)p).StartsWith(prefix)));
        }
Exemplo n.º 19
0
 private static bool IsGACReference(TargetRelativePath refPath)
 {
     return(((string)refPath).StartsWith("GAC!"));
 }
Exemplo n.º 20
0
 public MSBuildRunner CreateMSBuildRunner(SlnBuilder slnBuilder, TargetRelativePath slnPath, MSBuildVersion version)
 {
     return store.Add(baseImpl.CreateMSBuildRunner(slnBuilder, slnPath, version));
 }