Exemplo n.º 1
0
        public override BuildResult Run(BuildContext context)
        {
            var manifest           = context.BuildManifest;
            var buildConfiguration = BuildContextInternals.GetBuildConfiguration(context);
            var profile            = context.GetComponentOrDefault <DotsRuntimeBuildProfile>();
            var rootAssembly       = context.GetComponentOrDefault <DotsRuntimeRootAssembly>();
            var targetName         = rootAssembly.MakeBeeTargetName(context.BuildConfigurationName);
            var scenes             = context.GetComponentOrDefault <SceneList>();
            var firstScene         = scenes.GetScenePathsForBuild().FirstOrDefault();

            s_AssemblyCache.BaseAssemblies = rootAssembly.RootAssembly.asset;
            s_AssemblyCache.PlatformName   = profile.Target.UnityPlatformName;

            // Record any log errors/exceptions to be able to stop the build if any
            ExportConfigurationLogHandler logHandler = new ExportConfigurationLogHandler();

            logHandler.Hook();

            using (var tmpWorld = new World(ConfigurationScene.Guid.ToString()))
            {
                var dataDirInfo =
                    WorldExport.GetOrCreateDataDirectoryFrom(rootAssembly.StagingDirectory.Combine(targetName));
                var logDirectory = WorldExport.GetOrCreateLogDirectoryFrom(targetName);
                var subScenePath = WorldExport
                                   .GetOrCreateSubSceneDirectoryFrom(rootAssembly.StagingDirectory.Combine(targetName)).ToString();
                var outputDir = BuildStepGenerateBeeFiles.GetFinalOutputDirectory(context, targetName);

                var hasFilter = context.TryGetComponent <ConversionSystemFilterSettings>(out var conversionFilter);

                // Run configuration systems
                ConfigurationSystemGroup configSystemGroup = tmpWorld.GetOrCreateSystem <ConfigurationSystemGroup>();
                var systems = TypeCache.GetTypesDerivedFrom(typeof(ConfigurationSystemBase));
                foreach (var type in systems)
                {
                    if (hasFilter && !conversionFilter.ShouldRunConversionSystem(type))
                    {
                        continue;
                    }

                    ConfigurationSystemBase baseSys = (ConfigurationSystemBase)tmpWorld.GetOrCreateSystem(type);
                    baseSys.BuildContext     = context;
                    baseSys.AssemblyCache    = s_AssemblyCache;
                    baseSys.LogDirectoryPath = logDirectory.FullName;
                    configSystemGroup.AddSystemToUpdateList(baseSys);
                }

                configSystemGroup.SortSystems();
                configSystemGroup.Update();

                // Export configuration scene
                var writeEntitySceneSettings = new WriteEntitySceneSettings()
                {
                    Codec              = Codec.LZ4,
                    IsDotsRuntime      = true,
                    OutputPath         = subScenePath,
                    BuildAssemblyCache = s_AssemblyCache
                };
                var(decompressedSize, compressedSize) = EditorEntityScenes.WriteEntitySceneSection(
                    tmpWorld.EntityManager, ConfigurationScene.Guid, "0", null, writeEntitySceneSettings,
                    out var objectRefCount, out var objRefs, default);
Exemplo n.º 2
0
        public override BuildResult Run(BuildContext context)
        {
            var profile      = context.GetComponentOrDefault <DotsRuntimeBuildProfile>();
            var rootAssembly = context.GetComponentOrDefault <DotsRuntimeRootAssembly>();
            var targetName   = rootAssembly.MakeBeeTargetName(context.BuildConfigurationName);
            var workingDir   = DotsRuntimeRootAssembly.BeeRootDirectory;
            var outputDir    = new DirectoryInfo(BuildStepGenerateBeeFiles.GetFinalOutputDirectory(context, targetName));

            var result = BeeTools.Run(targetName, workingDir, context.BuildProgress);

            WorldExport.GetOrCreateLogDirectoryFrom(targetName).GetFile("BuildLog.txt").WriteAllText(result.Output);
            workingDir.GetFile("runbuild" + ShellScriptExtension()).UpdateAllText(result.Command);

            if (result.Failed)
            {
                return(context.Failure(result.Error));
            }

            if (!string.IsNullOrEmpty(rootAssembly.ProjectName))
            {
                var outputTargetFile = outputDir.GetFile(rootAssembly.ProjectName + profile.Target.ExecutableExtension);
                context.SetBuildArtifact(new DotsRuntimeBuildArtifact {
                    OutputTargetFile = outputTargetFile
                });
            }

            return(context.Success());
        }