Ejemplo n.º 1
0
 protected ExternalProject(Guid projectGuid, string projectFile, string projectName, TurtleParameters parameters)
     : base(projectFile, projectName, parameters)
 {
     _projectGuid       = projectGuid;
     _buildItems        = new List <ProjectItem>();
     ProjectType        = "External";
     _projectReferences = new SortedFileList();
     _projectReferences.BaseDirectory = ProjectPath;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Project"/> class.
        /// </summary>
        /// <param name="projectFile">The project file.</param>
        /// <param name="projectName">Name of the project.</param>
        /// <param name="parameters">The parameters.</param>
        public Project(string projectFile, string projectName, TurtleParameters parameters)
        {
            if (string.IsNullOrEmpty(projectFile))
            {
                throw new ArgumentNullException("projectFile");
            }
            else if (string.IsNullOrEmpty(projectName))
            {
                throw new ArgumentNullException("projectFile");
            }
            else if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            _projectFile = projectFile;
            ProjectName  = projectName;
            _parameters  = parameters;

            _contentFiles = new SortedFileList();
            _scriptFiles  = new SortedFileList();
            _contentFiles.BaseDirectory = ProjectPath;
            _scriptFiles.BaseDirectory  = ProjectPath;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates the specified package
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="definition">The definition.</param>
        /// <returns></returns>
        public static TPack Create(string fileName, Pack definition)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }
            else if (definition == null)
            {
                throw new ArgumentNullException("definition");
            }

            AssuredStreamCreateArgs args = new AssuredStreamCreateArgs();

            if (definition.StrongNameKey != null)
            {
                args.StrongNameKey = definition.StrongNameKey;
            }

            SortedFileList added = new SortedFileList();

            added.BaseDirectory = "c:\\" + Guid.NewGuid();
            foreach (PackContainer container in definition.Containers)
            {
                foreach (PackFile file in container.Files)
                {
                    if (!QQnPath.IsRelativeSubPath(file.StreamName) || added.Contains(file.StreamName))
                    {
                        string name = Path.GetFileNameWithoutExtension(file.StreamName);
                        string ext  = Path.GetExtension(file.StreamName);

                        string attempt = "_/" + name + ext;
                        int    n       = 0;
                        do
                        {
                            if (!added.Contains(attempt))
                            {
                                file.StreamName = attempt;
                                break;
                            }

                            attempt = string.Format("_/{0}.{1}.{2}", name, n++, ext);
                        }while (true);
                    }

                    if (file.StreamName.Contains("\\"))
                    {
                        file.StreamName = file.StreamName.Replace('\\', '/');
                    }
                }
            }

            args.FileType = PackageFileType;

            MultipleStreamCreateArgs msca = new MultipleStreamCreateArgs();

            msca.MaximumNumberOfStreams = 4;
            msca.VerificationMode       = VerificationMode.None;

            using (FileStream fs = File.Create(fileName, 32768))
                using (AssuredStream assurance = new AssuredStream(fs, args))
                    using (MultipleStreamWriter msw = new MultipleStreamWriter(assurance, msca))
                    {
                        MultipleStreamArgs msa = new MultipleStreamArgs();
                        msa.StreamType = 0x10;
                        msa.Assured    = true;
                        msa.GZipped    = true;
                        using (XmlWriter xw = new XmlTextWriter(msw.CreateStream(msa), Encoding.UTF8))
                        {
                            xw.WriteStartDocument();
                            xw.WriteStartElement("TurtlePackage", "http://schemas.qqn.nl/2007/TurtlePackage");
                            Tokenizer.TryWriteXml(xw, definition);
                            xw.WriteEndDocument();
                        }

                        msa            = new MultipleStreamArgs();
                        msa.StreamType = 0x11;

                        using (XmlWriter xw = new XmlTextWriter(msw.CreateStream(msa), Encoding.UTF8))
                        {
                            // TODO: Write tblog file
                        }


                        // Last stream: We add a zip file
                        msa            = new MultipleStreamArgs();
                        msa.StreamType = ZipFileId;  // Defined
                        msa.Assured    = false;      // Use the whole file assurance for the zip
                        msa.GZipped    = false;      // Don't compress again

                        using (Stream ms = msw.CreateStream(msa))
                            using (ZipFile zipFile = ZipFile.Create(ms))
                            {
                                zipFile.BeginUpdate();
                                zipFile.UseZip64 = UseZip64.Dynamic;

                                SetName setName = new SetName();

                                zipFile.NameTransform = setName;

                                foreach (PackContainer container in definition.Containers)
                                {
                                    foreach (PackFile file in container.Files)
                                    {
                                        setName.NextName = file.StreamName;

                                        Debug.Assert(File.Exists(file.FullName));

                                        zipFile.Add(file.FullName);
                                    }
                                }

                                zipFile.CommitUpdate();
                            }
                    }

            return(TPack.OpenFrom(fileName, VerificationMode.None));
        }
Ejemplo n.º 4
0
        private void ParseProjectOutput()
        {
            ProjectOutputList           items          = ProjectOutput;
            SortedFileList <bool>       localCopyItems = new SortedFileList <bool>();
            SortedFileList <TargetType> keys           = new SortedFileList <TargetType>();

            ProjectOutput.BaseDirectory  = ProjectPath;
            localCopyItems.BaseDirectory = ProjectPath;
            keys.BaseDirectory           = ProjectPath;

            SortedList <string, bool> copyKeys = new SortedList <string, bool>();

            foreach (string v in GetParameters("SharedItems", Parameters.SharedItems, ""))
            {
                if (!keys.ContainsKey(v))
                {
                    keys.Add(v, TargetType.SharedItem);
                }
            }

            foreach (string v in GetParameters("LocalItems", Parameters.LocalItems, ""))
            {
                if (!keys.ContainsKey(v))
                {
                    keys.Add(v, TargetType.Item);
                }
            }

            foreach (string v in GetParameters("CopyItems", Parameters.LocalItems, "None;Compile;Content;EmbeddedResource"))
            {
                if (!copyKeys.ContainsKey(v))
                {
                    copyKeys.Add(v, true);
                }
            }

            string primaryTarget = QQnPath.Combine(OutputPath, TargetName + TargetExt);
            string itemTarget    = primaryTarget;

            items.Add(new TargetItem(itemTarget, QQnPath.Combine(IntermediateOutputPath, TargetName + TargetExt), TargetType.Item));

            if (BuildProperties.ContainsKey("_SGenDllCreated") && GetProperty("_SGenDllCreated") == "true" && BuildProperties.ContainsKey("_SGenDllName"))
            {
                string dllName = GetProperty("_SGenDllName");
                itemTarget = QQnPath.Combine(OutputPath, dllName);
                items.Add(new TargetItem(itemTarget, QQnPath.Combine(IntermediateOutputPath, dllName), TargetType.Item));
            }

            if (BuildProperties.ContainsKey("_DebugSymbolsProduced") && GetProperty("_DebugSymbolsProduced") == "true")
            {
                string pdbName = GetProperty("TargetName") + ".pdb";
                DebugSrc   = pdbName;
                itemTarget = QQnPath.Combine(OutputPath, pdbName);
                items.Add(new TargetItem(itemTarget, QQnPath.Combine(IntermediateOutputPath, pdbName), TargetType.Item));
            }

            foreach (ProjectItem pi in BuildItems)
            {
                if (string.IsNullOrEmpty(pi.Include))
                {
                    continue;
                }

                TargetType type = TargetType.None;
                switch (pi.Name)
                {
                // TODO: Rewrite to a per-language infrastructure
                case "IntermediateAssembly":
                case "AddModules":
                case "DocFileItem":
                case "IntermediateSatelliteAssembliesWithTargetPath":
                    type = TargetType.Item;

                    break;

                case "ContentWithTargetPath":
                case "AllItemsFullPathWithTargetPath":
                case "ReferenceCopyLocal":
                    string condition;
                    if (pi.TryGetMetaData("CopyToOutputDirectory", out condition))
                    {
                        switch (condition)
                        {
                        case "Always":
                        case "PreserveNewest":
                            type = TargetType.SharedCopy;
                            break;

                        default:
                            break;
                        }
                    }
                    if (type == TargetType.None)
                    {
                        goto default;
                    }
                    break;

                case "ReferenceComWrappersToCopyLocal":
                case "ResolvedIsolatedComModules":
                case "_DeploymentLooseManifestFile":
                case "ReferenceCopyLocalPaths":
                case "NativeReferenceFile":
                    string fusionName = pi.GetMetadata("FusionName");
                    if (!string.IsNullOrEmpty(fusionName))
                    {
                        References.Add(new AssemblyReference(fusionName, pi, this));
                    }

                    type = TargetType.SharedItem;
                    break;

                default:
                    if (!keys.TryGetValue(pi.Name, out type))
                    {
                        type = TargetType.None;
                    }
                    break;
                }

                if (type != TargetType.None)
                {
                    string target = CalculateTarget(pi);

                    if (!items.ContainsKey(target))
                    {
                        items.Add(new TargetItem(EnsureRelativePath(target), EnsureRelativePath(pi.Include), type, pi));
                    }
                }

                if (copyKeys.ContainsKey(pi.Name))
                {
                    string copyCondition;
                    if (pi.TryGetMetaData("CopyToOutputDirectory", out copyCondition))
                    {
                        switch (copyCondition)
                        {
                        case "Always":
                        case "PreserveNewest":
                        {
                            localCopyItems[pi.Include] = true;
                        }
                        break;
                        }
                    }
                }
            }

            foreach (TargetItem ti in items.Values)
            {
                if (ti.Type == TargetType.SharedCopy)
                {
                    if (localCopyItems.ContainsKey(ti.Include))
                    {
                        ti.Type = TargetType.Copy;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private SortedFileList <ExternalProject> CreateExternalProjectsList()
        {
            SortedFileList <ExternalProject> externalProjects = new SortedFileList <ExternalProject>();

            using (StreamReader sr = File.OpenText(ProjectFile))
            {
                string line;

                while (null != (line = sr.ReadLine()))
                {
                    if (line.StartsWith("Project("))
                    {
                        IList <string> words = Tokenizer.GetCommandlineWords(line);

                        if (words.Count < 5 || words[1] != "=")
                        {
                            continue;
                        }

                        Guid   projectType = new Guid(words[0].Substring(8).TrimEnd(')').Trim('\"'));
                        string projectName = FilterWord(words[2]);
                        string projectFile = QQnPath.Combine(ProjectPath, FilterWord(words[3]));
                        Guid   projectGuid = new Guid(FilterWord(words[4]));

                        if (projectType != solutionItem && File.Exists(projectFile))
                        {
                            if (QQnPath.ExtensionEquals(projectFile, ".vcproj"))
                            {
                                externalProjects.Add(projectFile, new VCBuildProject(projectGuid, projectFile, projectName, Parameters));
                            }
                        }
                    }
                }
            }

            if (BuildProperties == null)
            {
                Refresh();
            }

            // The property CurrentSolutionConfigurationContents contains the 'real' configuration of external projects
            string configData;

            if (BuildProperties.TryGetValue("CurrentSolutionConfigurationContents", out configData))
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(configData);

                foreach (ExternalProject ep in externalProjects)
                {
                    XmlNode node = doc.SelectSingleNode("//ProjectConfiguration[@Project='" + ep.ProjectGuid.ToString("B").ToUpperInvariant() + "']");

                    if (node != null)
                    {
                        ep.AddBuildConfiguration(node.InnerText);
                    }
                }
            }

            return(externalProjects);
        }