示例#1
0
文件: Command.cs 项目: mortend/uno
        protected void WriteProductInfo()
        {
            WriteLine(UnoVersion.LongHeader);
            WriteLine(UnoVersion.Copyright);

            WriteHead("Product", 10, 0);
            WriteRow("Commit", UnoVersion.CommitSha);
            WriteRow("Version", UnoVersion.FileVersion.FileVersion);

            WriteHead("Environment", 10, 0);
            WriteRow("OSVersion", Environment.OSVersion.VersionString);
            WriteRow("Version", Environment.Version);

            // Mono version
            if (MonoInfo.IsRunningMono)
            {
                WriteHead("Mono", 10, 0);
                WriteRow("Version", MonoInfo.GetVersion());
            }
        }
示例#2
0
        public BackendResult Build()
        {
            if (Log.HasErrors)
            {
                return(null);
            }

            PrintRow("Packages", _input.Packages);
            PrintRow("Output dir", _env.OutputDirectory);

            _file.Delete();
            _env.Define(_target.Identifier, "TARGET_" + _target.Identifier,
                        _backend.Name, _backend.ShaderBackend.Name);

            if (_compilerOptions.Debug)
            {
                _env.Define("DEBUG");
            }
            if (_options.Configuration != BuildConfiguration.Debug)
            {
                _env.Define(_options.Configuration.ToString().ToUpperInvariant());
            }
            if (_options.Configuration == BuildConfiguration.Preview)
            {
                _env.Define("REFLECTION", "SIMULATOR", "STACKTRACE");
            }

            foreach (var def in StuffFile.DefaultDefines)
            {
                _env.Define("HOST_" + def);
            }
            foreach (var def in _options.Defines)
            {
                _env.Define(def);
            }
            foreach (var def in (_project.GetString(_target.Identifier + ".Defines") ?? "").Split('\n'))
            {
                if (!string.IsNullOrEmpty(def))
                {
                    _env.Define(def);
                }
            }

            _target.Initialize(_env);

            foreach (var def in _options.Undefines)
            {
                _env.Undefine(def);
            }

            if (!_env.Test(_project.Source, _project.BuildCondition))
            {
                if (Log.IsVerbose)
                {
                    Log.Skip();
                }
                Log.WriteLine("BuildCondition in project file is not satisfied -- stopping build");
                Log.DisableSkip();
                StopAnim();
                return(null);
            }

            foreach (var p in _project.GetProperties(Log))
            {
                _env.Set("Project." + p.Key, p.Value);
            }
            foreach (var p in _config.Flatten())
            {
                _env.Set("Config." + p.Key, GetConfigValue(p.Key, p.Value));
            }
            foreach (var e in _options.Settings)
            {
                _env.Set(e.Key, GetCommandLineValue(e.Value), Disambiguation.Override);
            }

            var unoExe = _config.GetFullPath("UnoExe", false);

            if (unoExe != null)
            {
                Log.Warning(".unoconfig: 'UnoExe' is deprecated -- replace with 'Uno.Exe'");
            }
            else
            {
                unoExe = _config.GetFullPath("Uno.Exe");
            }

            _env.Set("uno", PlatformDetection.IsWindows
                ? unoExe.QuoteSpace()
                : MonoInfo.GetPath().QuoteSpace() + " " + unoExe.QuoteSpace());

            if (Log.HasErrors)
            {
                return(null);
            }

            using (Log.StartProfiler(typeof(UXProcessor)))
                UXProcessor.Build(_compiler.Disk, _input.Packages);

            if (Log.HasErrors)
            {
                return(null);
            }

            try
            {
                _compiler.Load();
            }
            finally
            {
                StopAnim();
            }

            if (Log.HasErrors)
            {
                return(null);
            }

            var defines = _compiler.Data.Extensions.Defines;
            var stuff   = GetDirtyStuff(_env, defines, _input.Packages);

            if (stuff.Count > 0)
            {
                using (Log.StartAnimation("Installing dependencies"))
                {
                    foreach (var f in stuff)
                    {
                        if (!Installer.Install(Log, f, 0, defines))
                        {
                            Log.Error(new Source(f), null, "Failed to install dependencies");
                        }
                    }
                }
            }

            if (Log.HasErrors)
            {
                return(null);
            }

            using (Log.StartAnimation("Compiling syntax tree"))
                _compiler.Compile();

            if (Log.HasErrors)
            {
                return(null);
            }

            _anim = Log.StartAnimation("Generating code and data");

            try
            {
                return(_compiler.Generate(_target.Configure));
            }
            finally
            {
                // Add flag to avoid repeating warnings when this package is reused in following builds (uno doctor).
                _compiler.Input.Package.Flags |= SourcePackageFlags.Verified;

                _file.Product      = _env.GetString("Product");
                _file.BuildCommand = _env.GetString("Commands.Build");
                _file.RunCommand   = _env.GetString("Commands.Run");
                _file.UnoVersion   = UnoVersion.InformationalVersion;

                if (!Log.HasErrors)
                {
                    _file.Save(GetHashCode());
                    _target.DeleteOutdated(_compiler.Disk, _env);
                }

                StopAnim();
            }
        }