internal static void Publish(PackageManifest manifest, string registry)
        {
            try
            {
                CopySamples(manifest);

                manifest.OnAfterDeserialize();
                string PackageFolder = Path.Combine(AssetDatabaseUtilities.GetRelativeToProjectRoot(Paths.PackagesFolder), manifest.package_name);

                NPM.Publish(PackageFolder, registry);
            }
            finally
            {
                EmptySamplesDirectory(manifest);
            }
        }
Пример #2
0
        public bool Repair(PackageFile file, bool force = false)
        {
            var upk    = file.CreateSourcePackage();
            var reader = new SourceReader(Log, upk, this);

            // Install NPM packages if package.json exists
            if (NPM.NeedsInstall(upk))
            {
                new NPM(Log).Install(upk);
            }

            if (force || !reader.CacheExists ||
                reader.HasAnythingChangedSince(reader.CacheTime, false))
            {
                Log.Verbose("Generating cache for " + file.Name);
                using (new FileLock(file.CacheDirectory))
                    reader.ExportCache(file.CacheDirectory);
                return(true);
            }

            return(false);
        }
Пример #3
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, _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();
            }
        }