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, _backend.ShaderBackend.Name, _backend.BuildType.ToString()); if (!string.IsNullOrEmpty(_target.FormerName)) { _env.Define(_target.FormerName); } if (_options.Defines.Contains("HEADLESS")) { _env.Define("HEADLESS"); } if (_options.OptimizeLevel == 0) { _options.Defines.Add("O0"); // disables native optimizations } 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", "DesignMode"); } if (Log.EnableExperimental) { _options.Defines.Add("EXPERIMENTAL"); } foreach (var def in StuffFile.DefaultDefines) { _env.Define("HOST_" + def); } foreach (var def in _options.Defines) { _env.Define(def); } _target.Initialize(_env); foreach (var def in _options.Undefines) { _env.Undefine(def); } 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 'Assemblies.Uno'"); } else { unoExe = _config.GetFullPath("Assemblies.Uno"); } _env.Set("Uno", PlatformDetection.IsWindows ? unoExe.QuoteSpace() : GetMonoPath().QuoteSpace() + " " + unoExe.QuoteSpace()); foreach (var dll in _config.GetFullPathArray("Assemblies.Plugins")) { _compiler.Plugins.Load(dll); } if (Log.HasErrors) { return(null); } // Install NPM packages if package.json exists foreach (var p in _input.Packages) { if (p.IsProject && NPM.NeedsInstall(p)) { new NPM(Log).Install(p); } } 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")) { Stuff.Log.Configure(Log.IsVeryVerbose, Log.OutWriter, Log.ErrorWriter); foreach (var f in stuff) { if (!Installer.Install(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"); if (!Log.HasErrors) { _file.Save(GetHashCode()); _target.DeleteOutdated(_compiler.Disk, _env); } StopAnim(); } }
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(); } }