Example #1
0
        internal void Finish(BackendCompiler backend)
        {
            if (this.Prereqs != null && this.Prereqs.HasElements)
            {
                this.Xml.Add(this.Prereqs);
            }
            else // single prerequisite is required.
            {
                this.Xml.Add(new XElement(AppxManifest.AppxNamespace + "Prerequisites",
                                          new XElement(AppxManifest.AppxNamespace + "OSMinVersion", "6.2.1"),
                                          new XElement(AppxManifest.AppxNamespace + "OSMaxVersionTested", "6.2.1")
                                          )
                             );
            }

            if (this.dependencies != null && this.dependencies.HasElements)
            {
                this.Xml.Add(this.dependencies);
            }

            if (this.capabilities != null && this.capabilities.HasElements)
            {
                this.Xml.Add(this.capabilities);
            }

            if (this.extensions != null && this.extensions.HasElements)
            {
                this.Xml.Add(this.extensions);
            }

            if (this.applications != null && this.applications.HasElements)
            {
                this.Xml.Add(this.applications);
            }
        }
Example #2
0
        /// <summary>
        /// Compiles the added files into a target output appropriate for the output path extension.
        /// </summary>
        /// <param name="type">Package type to generate.</param>
        /// <param name="architecture">Package architecture to generate.</param>
        /// <param name="languages">Package languages to generate.</param>
        /// <param name="outputPath">Path to generate output. Output path file extension determines the output type.</param>
        public void Compile(PackageType type, PackageArchitecture architecture, CultureInfo[] languages, string outputPath)
        {
            FrontendCompiler frontend = new FrontendCompiler(architecture, this.referenceAssemblies);

            frontend.Messages += this.Messages;

            foreach (KeyValuePair <string, string> define in this.PreprocessorDefines)
            {
                frontend.Substitutions.Add(define.Key, define.Value);
            }

            foreach (Swix root in this.roots)
            {
                frontend.AddRoot(root);
            }

            foreach (string path in this.sourceFiles)
            {
                frontend.Parse(path);
            }

            if (frontend.EncounteredError)
            {
                return;
            }

            frontend.Resolve();
            if (frontend.EncounteredError)
            {
                return;
            }

            frontend.Harvest();
            if (frontend.EncounteredError)
            {
                return;
            }

            Intermediate[] intermediates = frontend.GetIntermediates();

            CompilerFileManager fileManager = this.FileManager ?? new CompilerFileManager();

            fileManager.Architecture = architecture;
            fileManager.Language     = languages.Length == 0 ? null : languages[0];
            fileManager.OutputPath   = outputPath;
            foreach (string searchPath in this.SearchPaths)
            {
                fileManager.SearchPaths.Add(searchPath);
            }

            using (BackendCompiler backend = BackendCompiler.Create(type, outputPath))
            {
                backend.Messages    += this.Messages;
                backend.Architecture = architecture;
                backend.FileManager  = fileManager;
                backend.Languages    = languages;

                backend.Generate(intermediates, outputPath);
            }
        }
        /// <summary>
        /// Finishes the manifest applcation XML.
        /// </summary>
        /// <param name="backend">Compiler backend used for sending messages.</param>
        public void Finish(BackendCompiler backend)
        {
            // Visual elements is required.
            XElement xVisualElements = new XElement(AppxManifest.AppxNamespace + "VisualElements");

            this.Xml.Add(xVisualElements);

            if (this.Tile != null)
            {
                Application      application = (Application)this.Item;
                AppxLexicon.Tile tile        = (AppxLexicon.Tile) this.Tile.Item;

                // Display name is required.
                if (!String.IsNullOrEmpty(application.DisplayName))
                {
                    xVisualElements.Add(new XAttribute("DisplayName", application.DisplayName));
                }
                else
                {
                    backend.OnMessage(new CompilerMessageEventArgs(CompilerMessage.RequiredAttribute("Application", "DisplayName"), this.Item));
                }

                // Description is required.
                if (!String.IsNullOrEmpty(application.Description))
                {
                    xVisualElements.Add(new XAttribute("Description", application.Description));
                }
                else
                {
                    backend.OnMessage(new CompilerMessageEventArgs(CompilerMessage.RequiredAttribute("Application", "Description"), this.Item));
                }

                // Image is required.
                string logo = tile.Image == null ? null : tile.Image.NonqualifiedName;
                if (!String.IsNullOrEmpty(logo))
                {
                    xVisualElements.Add(new XAttribute("Logo", logo));
                }
                else
                {
                    backend.OnMessage(new CompilerMessageEventArgs(CompilerMessage.RequiredAttribute("Tile", "Image"), this.Item));
                }

                // Small image is required.
                string smallLogo = tile.SmallImage == null ? null : tile.SmallImage.NonqualifiedName;
                if (!String.IsNullOrEmpty(smallLogo))
                {
                    xVisualElements.Add(new XAttribute("SmallLogo", smallLogo));
                }
                else
                {
                    backend.OnMessage(new CompilerMessageEventArgs(CompilerMessage.RequiredAttribute("Tile", "SmallImage"), this.Item));
                }

                // Foreground is required.
                xVisualElements.Add(new XAttribute("ForegroundText", tile.Foreground));

                // Background is required.
                string color = AppxManifest.GetColor(tile.Background);
                if (!String.IsNullOrEmpty(color))
                {
                    xVisualElements.Add(new XAttribute("BackgroundColor", color));
                }
                else
                {
                    backend.OnMessage(new CompilerMessageEventArgs(CompilerMessage.InvalidAttributeValue("Tile", "Background", tile.Background), tile));
                }

                // Toast capable is optional.
                bool?toast = AppxLexicon.Application.GetToastCapable(application);
                if (toast.HasValue && toast.Value)
                {
                    xVisualElements.Add(new XAttribute("ToastCapable", true));
                }

                // Default tile is optional.
                string wideLogo = (tile.WideImage == null) ? null : tile.WideImage.NonqualifiedName;
                if (!String.IsNullOrEmpty(wideLogo) || !String.IsNullOrEmpty(tile.ShortName) || tile.ShowName != AppxLexicon.TileShowName.Invalid)
                {
                    XElement xDefautTile = new XElement(AppxManifest.AppxNamespace + "DefaultTile");

                    if (!String.IsNullOrEmpty(tile.ShortName))
                    {
                        xDefautTile.Add(new XAttribute("ShortName", tile.ShortName));
                    }

                    if (tile.ShowName != AppxLexicon.TileShowName.Invalid)
                    {
                        if (tile.ShowName != AppxLexicon.TileShowName.Invalid)
                        {
                            xDefautTile.Add(new XAttribute("ShowName", tile.ShowName));
                        }
                    }

                    if (!String.IsNullOrEmpty(wideLogo))
                    {
                        xDefautTile.Add(new XAttribute("WideLogo", wideLogo));
                    }

                    xVisualElements.Add(xDefautTile);
                }
            }
            else
            {
                backend.OnMessage(new CompilerMessageEventArgs(CompilerMessage.RequiredElement("Application", "Tile"), this.Item));
            }

            // Lock screen is optional.
            if (this.LockScreen != null && this.LockScreen.Xml != null && this.LockScreen.Xml.HasAttributes)
            {
                xVisualElements.Add(this.LockScreen.Xml);
            }

            // Splash screen is required.
            if (this.SplashScreen != null && this.SplashScreen.Xml != null && this.SplashScreen.Xml.HasAttributes)
            {
                xVisualElements.Add(this.SplashScreen.Xml);
            }
            else
            {
                backend.OnMessage(new CompilerMessageEventArgs(CompilerMessage.RequiredElement("Application", "SplashScreen"), this.Item));
            }

            // Orientation preferences are optional.
            if (this.initialRotationPreferences != null && this.initialRotationPreferences.HasElements)
            {
                xVisualElements.Add(initialRotationPreferences);
            }

            // Extensions are optional.
            if (this.extensions != null && this.extensions.HasElements)
            {
                this.Xml.Add(this.extensions);
            }

            // Content URI rules are optional.
            if (this.contentUriRules != null && this.contentUriRules.HasElements)
            {
                this.Xml.Add(this.contentUriRules);
            }
        }
Example #4
0
 public void SetBackend(BackendCompiler compiler)
 {
     backendCompiler = compiler;
 }
Example #5
0
 public CompilerBuilder SetBackend(BackendCompiler backend)
 {
     compiler.SetBackend(backend);
     return(this);
 }
Example #6
0
 /// <summary>
 /// Compiles the added files into a target output appropriate for the output path extension.
 /// </summary>
 /// <param name="type">Package type to generate.</param>
 /// <param name="architecture">Package architecture to generate.</param>
 /// <param name="languages">Package languages to generate.</param>
 /// <param name="outputPath">Path to generate output. Output path file extension determines the output type.</param>
 public void Compile(PackageType type, PackageArchitecture architecture, CultureInfo[] languages, string outputPath)
 {
     CoreCompile(architecture, languages, outputPath, () => BackendCompiler.Create(type, outputPath));
 }