Пример #1
0
        internal static BuildFlags ParseBuildFlags(List <String> Args)
        {
            BuildFlags    Result      = BuildFlags.Build;
            List <String> ToBeRemoved = new List <String>();

            foreach (String Arg in Args)
            {
                switch (Arg.ToUpper())
                {
                case "--FLAGS":
                    Result |= BuildFlags.Flags;
                    break;

                case "--HELP":
                    Result |= BuildFlags.Help;
                    break;

                case "--PLAN":
                    Result |= BuildFlags.Plan;
                    break;

                default:
                    break;
                }
                if (Arg.StartsWith("--"))
                {
                    ToBeRemoved.Add(Arg);
                }
            }
            foreach (String Arg in ToBeRemoved)
            {
                Args.Remove(Arg);
            }
            return(Result);
        }
        public bool IsCompatibleWith(BuildTarget buildTarget, BuildFlags buildFlags)
        {
            bool result;

            if (this.IncludePlatforms == null && this.ExcludePlatforms == null)
            {
                result = true;
            }
            else
            {
                bool flag = (buildFlags & BuildFlags.BuildingForEditor) == BuildFlags.BuildingForEditor;
                if (flag)
                {
                    result = this.IsCompatibleWithEditor();
                }
                else
                {
                    if (flag)
                    {
                        buildTarget = BuildTarget.NoTarget;
                    }
                    if (this.ExcludePlatforms != null)
                    {
                        result = this.ExcludePlatforms.All((CustomScriptAssemblyPlatform p) => p.BuildTarget != buildTarget);
                    }
                    else
                    {
                        result = this.IncludePlatforms.Any((CustomScriptAssemblyPlatform p) => p.BuildTarget == buildTarget);
                    }
                }
            }
            return(result);
        }
 public LuminBuild(UnrealTargetConfiguration InConfig, string InLuminPackageName, string InMpkPath, BuildFlags InFlags)
 {
     Configuration    = InConfig;
     LuminPackageName = InLuminPackageName;
     SourceMpkPath    = InMpkPath;
     Flags            = InFlags;
 }
Пример #4
0
        /// <summary>
        /// Constructor taking optional params
        /// </summary>
        /// <param name="InType"></param>
        /// <param name="InPlatform"></param>
        /// <param name="InConfiguration"></param>
        /// <param name="InCommandLine"></param>
        /// <param name="InOptions"></param>
        public UnrealSessionRole(UnrealTargetRole InType, UnrealTargetPlatform InPlatform, UnrealTargetConfiguration InConfiguration, string InCommandLine = null, IConfigOption <UnrealAppConfig> InOptions = null)
        {
            RoleType = InType;

            Platform      = InPlatform;
            Configuration = InConfiguration;

            if (string.IsNullOrEmpty(InCommandLine))
            {
                CommandLine = "";
            }
            else
            {
                CommandLine = InCommandLine;
            }

            RequiredBuildFlags = BuildFlags.None;

            if (Globals.Params.ParseParam("dev") && !RoleType.UsesEditor())
            {
                RequiredBuildFlags |= BuildFlags.CanReplaceExecutable;
            }

            if (Globals.Params.ParseParam("bulk") && InPlatform == UnrealTargetPlatform.Android)
            {
                RequiredBuildFlags |= BuildFlags.Bulk;
            }

            Options      = InOptions;
            FilesToCopy  = new List <UnrealFileToCopy>();
            RoleModifier = ERoleModifier.None;
        }
Пример #5
0
        public bool CompileScripts(EditorScriptCompilationOptions definesOptions, BuildTargetGroup platformGroup, BuildTarget platform)
        {
            ScriptAssemblySettings scriptAssemblySettings = this.CreateScriptAssemblySettings(platformGroup, platform, definesOptions);
            BuildFlags             buildFlags             = BuildFlags.None;

            if ((definesOptions & EditorScriptCompilationOptions.BuildingForEditor) == EditorScriptCompilationOptions.BuildingForEditor)
            {
                buildFlags |= BuildFlags.BuildingForEditor;
            }
            if ((definesOptions & EditorScriptCompilationOptions.BuildingDevelopmentBuild) == EditorScriptCompilationOptions.BuildingDevelopmentBuild)
            {
                buildFlags |= BuildFlags.BuildingDevelopmentBuild;
            }
            EditorBuildRules.TargetAssembly[] array = null;
            bool result = this.CompileScripts(scriptAssemblySettings, EditorCompilation.EditorTempPath, buildFlags, ref array);

            if (array != null)
            {
                EditorBuildRules.TargetAssembly[] array2 = array;
                for (int i = 0; i < array2.Length; i++)
                {
                    EditorBuildRules.TargetAssembly targetAssembly       = array2[i];
                    CustomScriptAssembly            customScriptAssembly = this.customScriptAssemblies.Single((CustomScriptAssembly a) => a.Name == Path.GetFileNameWithoutExtension(targetAssembly.Filename));
                    string text = customScriptAssembly.FilePath;
                    if (text.StartsWith(this.projectDirectory))
                    {
                        text = text.Substring(this.projectDirectory.Length);
                    }
                    Debug.LogWarning(string.Format("Script assembly '{0}' has not been compiled. Folder containing assembly definition file '{1}' contains script files for different script languages. Folder must only contain script files for one script language.", targetAssembly.Filename, text));
                }
            }
            return(result);
        }
Пример #6
0
        private static bool BuildSdk(BuildFlags Flags)
        {
            PrintColorMessage("Copying Plugin SDK...", ConsoleColor.Cyan);

            if (!Build.CopyTextFiles())
            {
                return(false);
            }
            if (!Build.CopyPluginSdkHeaders())
            {
                return(false);
            }
            if (!Build.CopyVersionHeader())
            {
                return(false);
            }
            if (!Build.FixupResourceHeader())
            {
                return(false);
            }
            if (!Build.CopyLibFiles(Flags))
            {
                return(false);
            }

            return(true);
        }
Пример #7
0
 public CompilationTask(ScriptAssembly[] scriptAssemblies, string buildOutputDirectory, BuildFlags buildFlags, int maxConcurrentCompilers)
 {
     this.pendingAssemblies      = new HashSet <ScriptAssembly>(scriptAssemblies);
     this.CompileErrors          = false;
     this.buildOutputDirectory   = buildOutputDirectory;
     this.buildFlags             = buildFlags;
     this.maxConcurrentCompilers = maxConcurrentCompilers;
 }
 public IOSBuild(UnrealTargetConfiguration InConfig, string InPackageName, string InIPAPath, Dictionary <string, string> InFilesToInstall, BuildFlags InFlags)
 {
     Configuration  = InConfig;
     PackageName    = InPackageName;
     SourceIPAPath  = InIPAPath;
     FilesToInstall = InFilesToInstall;
     Flags          = InFlags;
 }
 public AndroidBuild(UnrealTargetConfiguration InConfig, string InAndroidPackageName, string InApkPath, Dictionary <string, string> InFilesToInstall, BuildFlags InFlags)
 {
     Configuration      = InConfig;
     AndroidPackageName = InAndroidPackageName;
     SourceApkPath      = InApkPath;
     FilesToInstall     = InFilesToInstall;
     Flags = InFlags;
 }
Пример #10
0
        public MonoIsland ToMonoIsland(BuildFlags buildFlags, string buildOutputDirectory)
        {
            bool editor                = (buildFlags & BuildFlags.BuildingForEditor) == BuildFlags.BuildingForEditor;
            bool development_player    = (buildFlags & BuildFlags.BuildingDevelopmentBuild) == BuildFlags.BuildingDevelopmentBuild;
            IEnumerable <string> first = from a in this.ScriptAssemblyReferences
                                         select Path.Combine(a.OutputDirectory, a.Filename);

            string[] references = first.Concat(this.References).ToArray <string>();
            string   output     = Path.Combine(buildOutputDirectory, this.Filename);

            return(new MonoIsland(this.BuildTarget, editor, development_player, this.ApiCompatibilityLevel, this.Files, references, this.Defines, output));
        }
Пример #11
0
        private ScriptAssembly[] GetAllScriptAssemblies(BuildFlags buildFlags, EditorScriptCompilationOptions options, PrecompiledAssembly[] unityAssembliesArg, PrecompiledAssembly[] precompiledAssembliesArg)
        {
            EditorBuildRules.CompilationAssemblies assemblies = new EditorBuildRules.CompilationAssemblies
            {
                UnityAssemblies          = unityAssembliesArg,
                PrecompiledAssemblies    = precompiledAssembliesArg,
                CustomTargetAssemblies   = this.customTargetAssemblies,
                EditorAssemblyReferences = ModuleUtils.GetAdditionalReferencesForUserScripts()
            };
            ScriptAssemblySettings settings = this.CreateEditorScriptAssemblySettings(options);

            return(EditorBuildRules.GetAllScriptAssemblies(this.allScripts, this.projectDirectory, buildFlags, settings, assemblies));
        }
        public static IEnumerable <IOSBuild> CreateFromPath(string InProjectName, string InPath)
        {
            string BuildPath = InPath;

            List <IOSBuild> DiscoveredBuilds = new List <IOSBuild>();

            DirectoryInfo Di = new DirectoryInfo(BuildPath);

            // find all install batchfiles
            FileInfo[] InstallFiles = Di.GetFiles("*.ipa");

            foreach (FileInfo Fi in InstallFiles)
            {
                var UnrealConfig = UnrealHelpers.GetConfigurationFromExecutableName(InProjectName, Fi.Name);

                Log.Verbose("Pulling package data from {0}", Fi.FullName);

                string AbsPath = Fi.Directory.FullName;

                // IOS builds are always packaged, and can always replace the command line and executable as we cache the unzip'd IPA
                BuildFlags Flags = BuildFlags.Packaged | BuildFlags.CanReplaceCommandLine | BuildFlags.CanReplaceExecutable;

                if (AbsPath.Contains("Bulk"))
                {
                    Flags |= BuildFlags.Bulk;
                }
                else
                {
                    Flags |= BuildFlags.NotBulk;
                }

                string SourceIPAPath = Fi.FullName;
                string PackageName   = GetBundleIdentifier(SourceIPAPath);

                if (String.IsNullOrEmpty(PackageName))
                {
                    continue;
                }

                Dictionary <string, string> FilesToInstall = new Dictionary <string, string>();

                IOSBuild NewBuild = new IOSBuild(UnrealConfig, PackageName, SourceIPAPath, FilesToInstall, Flags);

                DiscoveredBuilds.Add(NewBuild);

                Log.Verbose("Found {0} {1} build at {2}", UnrealConfig, ((Flags & BuildFlags.Bulk) == BuildFlags.Bulk) ? "(bulk)" : "(not bulk)", AbsPath);
            }

            return(DiscoveredBuilds);
        }
        /// <summary>
        /// Constructor taking optional params
        /// </summary>
        /// <param name="InType"></param>
        /// <param name="InPlatform"></param>
        /// <param name="InConfiguration"></param>
        /// <param name="InCommandLine"></param>
        /// <param name="InOptions"></param>
        public UnrealSessionRole(UnrealTargetRole InType, UnrealTargetPlatform?InPlatform, UnrealTargetConfiguration InConfiguration, string InCommandLine = null, IConfigOption <UnrealAppConfig> InOptions = null)
        {
            RoleType = InType;

            Platform      = InPlatform;
            Configuration = InConfiguration;
            MapOverride   = string.Empty;

            if (string.IsNullOrEmpty(InCommandLine))
            {
                CommandLine = string.Empty;
            }
            else
            {
                CommandLine = InCommandLine;
            }

            RequiredBuildFlags = BuildFlags.None;

            if (Globals.Params.ParseParam("dev") && !RoleType.UsesEditor())
            {
                RequiredBuildFlags |= BuildFlags.CanReplaceExecutable;
            }

            //@todo: for bulk/packaged builds, we should mark the platform as capable of these as we're catching global and not test specific flags
            // where we may be running parallel tests on multiple platforms
            if (InPlatform == UnrealTargetPlatform.Android || InPlatform == UnrealTargetPlatform.IOS)
            {
                if (Globals.Params.ParseParam("bulk"))
                {
                    RequiredBuildFlags |= BuildFlags.Bulk;
                }
                else
                {
                    RequiredBuildFlags |= BuildFlags.NotBulk;
                }
            }

            if (Globals.Params.ParseParam("packaged") && (InPlatform == UnrealTargetPlatform.Switch || InPlatform == UnrealTargetPlatform.XboxOne || InPlatform == UnrealTargetPlatform.PS4))
            {
                RequiredBuildFlags |= BuildFlags.Packaged;
            }


            Options           = InOptions;
            FilesToCopy       = new List <UnrealFileToCopy>();
            CommandLineParams = new GauntletCommandLine();
            RoleModifier      = ERoleModifier.None;
        }
 private static void UpdateBuildMask(int i, BuildFlags flag, bool state)
 {
     if (state)
     {
         BuildFlags[] buildMasks;
         int          num;
         (buildMasks = BuildMasks)[num = i] = (buildMasks[num] | flag);
     }
     else
     {
         BuildFlags[] buildMasks;
         int          num2;
         (buildMasks = BuildMasks)[num2 = i] = (BuildFlags)((int)buildMasks[num2] & (int)(byte)(~(uint)flag));
     }
 }
Пример #15
0
	public void Build(BuildFlags buildFlags)
	{
#if UNITY_EDITOR || !UNITY_FLASH
		// Sanitize tilePrefabs input, to avoid branches later
		if (data != null && spriteCollection != null)
		{
			if (data.tilePrefabs == null)
				data.tilePrefabs = new GameObject[SpriteCollectionInst.Count];
			else if (data.tilePrefabs.Length != SpriteCollectionInst.Count)
				System.Array.Resize(ref data.tilePrefabs, SpriteCollectionInst.Count);
			
			// Fix up data if necessary
			BuilderUtil.InitDataStore(this);
		}
		else
		{
			return;
		}

		// Sanitize sprite collection material ids
		if (SpriteCollectionInst)
			SpriteCollectionInst.InitMaterialIds();
			
		bool forceBuild = (buildFlags & BuildFlags.ForceBuild) != 0;

		// When invalid, everything needs to be rebuilt
		if (SpriteCollectionInst && SpriteCollectionInst.buildKey != spriteCollectionKey)
			forceBuild = true;

		// Remember active layers
		Dictionary<Layer, bool> layersActive = new Dictionary<Layer,bool>();
		if (layers != null)
		{
			for (int layerIdx = 0; layerIdx < layers.Length; ++layerIdx)
			{
				Layer layer = layers[layerIdx];
				if (layer != null && layer.gameObject != null)
				{
#if UNITY_3_5
					layersActive[layer] = layer.gameObject.active;
#else
					layersActive[layer] = layer.gameObject.activeSelf;
#endif
				}
			}
		}

		if (forceBuild) {
			ClearSpawnedInstances();
		}

		BuilderUtil.CreateRenderData(this, _inEditMode, layersActive);
		
		RenderMeshBuilder.Build(this, _inEditMode, forceBuild);
		
		if (!_inEditMode)
		{
#if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2)
			tk2dSpriteDefinition def = SpriteCollectionInst.FirstValidDefinition;
			if (def != null && def.physicsEngine == tk2dSpriteDefinition.PhysicsEngine.Physics2D) {
				ColliderBuilder2D.Build(this, forceBuild);
			}
			else 
#endif
			{
				ColliderBuilder3D.Build(this, forceBuild);
			}
			BuilderUtil.SpawnPrefabs(this, forceBuild);
		}
		
		// Clear dirty flag on everything
		foreach (var layer in layers)
			layer.ClearDirtyFlag();
		if (colorChannel != null)
			colorChannel.ClearDirtyFlag();
	
		// Update sprite collection key
		if (SpriteCollectionInst)
			spriteCollectionKey = SpriteCollectionInst.buildKey;
#endif
	}
 public static MonoIsland[] GetAllMonoIslandsExt(PrecompiledAssembly[] unityAssemblies, PrecompiledAssembly[] precompiledAssemblies, BuildFlags buildFlags)
 {
     return(EditorCompilationInterface.editorCompilation.GetAllMonoIslands(unityAssemblies, precompiledAssemblies, buildFlags));
 }
Пример #17
0
        internal bool CompileScripts(ScriptAssemblySettings scriptAssemblySettings, string tempBuildDirectory, BuildFlags buildflags, ref EditorBuildRules.TargetAssembly[] notCompiledTargetAssemblies)
        {
            this.DeleteUnusedAssemblies();
            this.allScripts.RemoveWhere((string path) => !File.Exists(Path.Combine(this.projectDirectory, path)));
            this.StopAllCompilation();
            if (!Directory.Exists(scriptAssemblySettings.OutputDirectory))
            {
                Directory.CreateDirectory(scriptAssemblySettings.OutputDirectory);
            }
            if (!Directory.Exists(tempBuildDirectory))
            {
                Directory.CreateDirectory(tempBuildDirectory);
            }
            IEnumerable <string> enumerable = (!this.areAllScriptsDirty) ? this.dirtyScripts.ToArray <string>() : this.allScripts.ToArray <string>();

            this.areAllScriptsDirty = false;
            this.dirtyScripts.Clear();
            bool result;

            if (!enumerable.Any <string>() && this.runScriptUpdaterAssemblies.Count == 0)
            {
                result = false;
            }
            else
            {
                EditorBuildRules.CompilationAssemblies assemblies = new EditorBuildRules.CompilationAssemblies
                {
                    UnityAssemblies          = this.unityAssemblies,
                    PrecompiledAssemblies    = this.precompiledAssemblies,
                    CustomTargetAssemblies   = this.customTargetAssemblies,
                    EditorAssemblyReferences = ModuleUtils.GetAdditionalReferencesForUserScripts()
                };
                EditorBuildRules.GenerateChangedScriptAssembliesArgs generateChangedScriptAssembliesArgs = new EditorBuildRules.GenerateChangedScriptAssembliesArgs
                {
                    AllSourceFiles       = this.allScripts,
                    DirtySourceFiles     = enumerable,
                    ProjectDirectory     = this.projectDirectory,
                    BuildFlags           = buildflags,
                    Settings             = scriptAssemblySettings,
                    Assemblies           = assemblies,
                    RunUpdaterAssemblies = this.runScriptUpdaterAssemblies
                };
                ScriptAssembly[] array = EditorBuildRules.GenerateChangedScriptAssemblies(generateChangedScriptAssembliesArgs);
                notCompiledTargetAssemblies = generateChangedScriptAssembliesArgs.NotCompiledTargetAssemblies.ToArray <EditorBuildRules.TargetAssembly>();
                if (!array.Any <ScriptAssembly>())
                {
                    result = false;
                }
                else
                {
                    this.compilationTask = new CompilationTask(array, tempBuildDirectory, buildflags, SystemInfo.processorCount);
                    this.compilationTask.OnCompilationStarted += delegate(ScriptAssembly assembly, int phase)
                    {
                        Console.WriteLine("- Starting compile {0}", Path.Combine(scriptAssemblySettings.OutputDirectory, assembly.Filename));
                    };
                    IEnumerable <MonoIsland> compilingMonoIslands = from i in this.GetAllMonoIslands()
                                                                    where 0 < i._files.Length
                                                                    select i;
                    this.compilationTask.OnCompilationFinished += delegate(ScriptAssembly assembly, List <CompilerMessage> messages)
                    {
                        Console.WriteLine("- Finished compile {0}", Path.Combine(scriptAssemblySettings.OutputDirectory, assembly.Filename));
                        if (this.runScriptUpdaterAssemblies.Contains(assembly.Filename))
                        {
                            this.runScriptUpdaterAssemblies.Remove(assembly.Filename);
                        }
                        if (!messages.Any((CompilerMessage m) => m.type == CompilerMessageType.Error))
                        {
                            string engineAssemblyPath = InternalEditorUtility.GetEngineAssemblyPath();
                            string unityUNet          = EditorApplication.applicationContentsPath + "/UnityExtensions/Unity/Networking/UnityEngine.Networking.dll";
                            if (!Weaver.WeaveUnetFromEditor(compilingMonoIslands, Path.Combine(tempBuildDirectory, assembly.Filename), Path.Combine(EditorCompilation.EditorTempPath, assembly.Filename), engineAssemblyPath, unityUNet, (buildflags & BuildFlags.BuildingForEditor) != BuildFlags.None))
                            {
                                messages.Add(new CompilerMessage
                                {
                                    message = "UNet Weaver failed",
                                    type    = CompilerMessageType.Error,
                                    file    = assembly.FullPath,
                                    line    = -1,
                                    column  = -1
                                });
                                this.StopAllCompilation();
                            }
                            else
                            {
                                EditorCompilation.CopyAssembly(Path.Combine(tempBuildDirectory, assembly.Filename), assembly.FullPath);
                            }
                        }
                    };
                    this.compilationTask.Poll();
                    result = true;
                }
            }
            return(result);
        }
Пример #18
0
    public void Build(BuildFlags buildFlags)
    {
        if (spriteCollection != null)
            _spriteCollectionInst = spriteCollection.inst;

        #if UNITY_EDITOR || !UNITY_FLASH
        // Sanitize tilePrefabs input, to avoid branches later
        if (data != null)
        {
            if (data.tilePrefabs == null)
                data.tilePrefabs = new Object[SpriteCollectionInst.Count];
            else if (data.tilePrefabs.Length != SpriteCollectionInst.Count)
                System.Array.Resize(ref data.tilePrefabs, SpriteCollectionInst.Count);

            // Fix up data if necessary
            BuilderUtil.InitDataStore(this);
        }
        else
        {
            return;
        }

        // Sanitize sprite collection material ids
        if (SpriteCollectionInst)
            SpriteCollectionInst.InitMaterialIds();

        bool editMode = (buildFlags & BuildFlags.EditMode) != 0;
        bool forceBuild = (buildFlags & BuildFlags.ForceBuild) != 0;

        // When invalid, everything needs to be rebuilt
        if (SpriteCollectionInst && SpriteCollectionInst.buildKey != spriteCollectionKey)
            forceBuild = true;

        if (forceBuild)
            ClearSpawnedInstances();

        BuilderUtil.CreateRenderData(this, editMode);

        RenderMeshBuilder.Build(this, editMode, forceBuild);

        if (!editMode)
        {
            ColliderBuilder.Build(this);
            BuilderUtil.SpawnPrefabs(this);
        }

        // Clear dirty flag on everything
        foreach (var layer in layers)
            layer.ClearDirtyFlag();
        if (colorChannel != null)
            colorChannel.ClearDirtyFlag();

        // One random number to detect undo
        buildKey = Random.Range(0, int.MaxValue);

        // Update sprite collection key
        if (SpriteCollectionInst)
            spriteCollectionKey = SpriteCollectionInst.buildKey;
        #endif
    }
Пример #19
0
        /// <summary>
        /// Given a platform, a build config, and true/false for client, returns the path to the binary for that config. E.g.
        /// Win64, Shipping, false = Binaries\Win64\FooServer-Win64-Shipping.exe
        /// </summary>
        /// <param name="TargetPlatform"></param>
        /// <param name="BuildConfig"></param>
        /// <param name="IsClient"></param>
        /// <returns></returns>
        virtual public string GetRelativeExecutablePath(UnrealTargetRole TargetType, UnrealTargetPlatform TargetPlatform, UnrealTargetConfiguration TargetConfiguration)
        {
            string ExePath;

            if (TargetType.UsesEditor())
            {
                ExePath = string.Format("Engine/Binaries/{0}/UE4Editor{1}", BuildHostPlatform.Current.Platform, Platform.GetExeExtension(TargetPlatform));
            }
            else
            {
                string BuildType = "";

                if (TargetType == UnrealTargetRole.Client)
                {
                    if (!UsesSharedBuildType)
                    {
                        BuildType = "Client";
                    }
                }
                else if (TargetType == UnrealTargetRole.Server)
                {
                    if (!UsesSharedBuildType)
                    {
                        BuildType = "Server";
                    }
                }

                bool IsRunningDev = Globals.Params.ParseParam("dev");

                // Turn FooGame into Foo
                string ExeBase = ProjectName.Replace("Game", "");

                if (TargetPlatform == UnrealTargetPlatform.Android)
                {
                    // use the archive results for android.
                    //var AndroidSource = new AndroidBuild(ProjectName, GetPlatformPath(TargetType, TargetPlatform), TargetConfiguration);

                    // We always (currently..) need to be able to replace the command line
                    BuildFlags Flags = BuildFlags.CanReplaceCommandLine;
                    if (IsRunningDev)
                    {
                        Flags |= BuildFlags.CanReplaceExecutable;
                    }
                    if (Globals.Params.ParseParam("bulk"))
                    {
                        Flags |= BuildFlags.Bulk;
                    }
                    else if (Globals.Params.ParseParam("notbulk"))
                    {
                        Flags |= BuildFlags.NotBulk;
                    }

                    var Build = GetMatchingBuilds(TargetType, TargetPlatform, TargetConfiguration, Flags).FirstOrDefault();

                    if (Build != null)
                    {
                        AndroidBuild AndroidBuild = Build as AndroidBuild;
                        ExePath = AndroidBuild.SourceApkPath;
                    }
                    else
                    {
                        throw new AutomationException("No suitable build for {0} found at {1}", TargetPlatform, string.Join(",", BuildPaths));
                    }

                    //ExePath = AndroidSource.SourceApkPath;
                }
                else
                {
                    string ExeFileName = string.Format("{0}{1}", ExeBase, BuildType);

                    if (TargetConfiguration != UnrealTargetConfiguration.Development)
                    {
                        ExeFileName += string.Format("-{0}-{1}", TargetPlatform.ToString(), TargetConfiguration.ToString());
                    }

                    ExeFileName += Platform.GetExeExtension(TargetPlatform);

                    string BasePath      = GetPlatformPath(TargetType, TargetPlatform);
                    string ProjectBinary = string.Format("{0}\\Binaries\\{1}\\{2}", ProjectName, TargetPlatform.ToString(), ExeFileName);
                    string StubBinary    = Path.Combine(BasePath, ExeFileName);
                    string DevBinary     = Path.Combine(Environment.CurrentDirectory, ProjectBinary);

                    string NonCodeProjectName   = "UE4Game" + Platform.GetExeExtension(TargetPlatform);
                    string NonCodeProjectBinary = Path.Combine(BasePath, "Engine", "Binaries", TargetPlatform.ToString());
                    NonCodeProjectBinary = Path.Combine(NonCodeProjectBinary, NonCodeProjectName);

                    // check the project binaries folder
                    if (File.Exists(Path.Combine(BasePath, ProjectBinary)))
                    {
                        ExePath = ProjectBinary;
                    }
                    else if (File.Exists(StubBinary))
                    {
                        ExePath = Path.Combine(BasePath, ExeFileName);
                    }
                    else if (IsRunningDev && File.Exists(DevBinary))
                    {
                        ExePath = DevBinary;
                    }
                    else if (File.Exists(NonCodeProjectBinary))
                    {
                        ExePath = NonCodeProjectBinary;
                    }
                    else
                    {
                        List <string> CheckedFiles = new List <String>()
                        {
                            Path.Combine(BasePath, ProjectBinary), StubBinary, NonCodeProjectBinary
                        };
                        if (IsRunningDev)
                        {
                            CheckedFiles.Add(DevBinary);
                        }

                        throw new AutomationException("Executable not found, upstream compile job may have failed.  Could not find executable {0} within {1}, binaries checked: {2}", ExeFileName, BasePath, String.Join(" - ", CheckedFiles));
                    }
                }
            }

            return(Utils.SystemHelpers.CorrectDirectorySeparators(ExePath));
        }
Пример #20
0
        public static void BuildAppxPackage(string BuildOutputFolder, string BuildLongVersion, BuildFlags Flags)
        {
            string sdkRootPath = string.Empty;

            string[] cleanupAppxArray =
            {
                BuildOutputFolder + "\\AppxManifest32.xml",
                BuildOutputFolder + "\\AppxManifest64.xml",
                BuildOutputFolder + "\\package32.map",
                BuildOutputFolder + "\\package64.map",
                BuildOutputFolder + "\\bundle.map",
                BuildOutputFolder + "\\ProcessHacker-44.png",
                BuildOutputFolder + "\\ProcessHacker-50.png",
                BuildOutputFolder + "\\ProcessHacker-150.png"
            };

            Program.PrintColorMessage("Building processhacker-build-package.appxbundle...", ConsoleColor.Cyan);

            using (var view32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
            {
                using (var kitsroot = view32.OpenSubKey("Software\\Microsoft\\Windows Kits\\Installed Roots", false))
                {
                    sdkRootPath = (string)kitsroot.GetValue("WdkBinRootVersioned", string.Empty);
                }
            }

            if (string.IsNullOrEmpty(sdkRootPath))
            {
                Program.PrintColorMessage("[Skipped] Windows SDK", ConsoleColor.Red);
                return;
            }

            string makeAppxExePath = Environment.ExpandEnvironmentVariables(sdkRootPath + "\\x64\\MakeAppx.exe");
            string signToolExePath = Environment.ExpandEnvironmentVariables(sdkRootPath + "\\x64\\SignTool.exe");

            try
            {
                //Win32.ImageResizeFile(44, "ProcessHacker\\resources\\ProcessHacker.png", BuildOutputFolder + "\\ProcessHacker-44.png");
                //Win32.ImageResizeFile(50, "ProcessHacker\\resources\\ProcessHacker.png", BuildOutputFolder + "\\ProcessHacker-50.png");
                //Win32.ImageResizeFile(150, "ProcessHacker\\resources\\ProcessHacker.png", BuildOutputFolder + "\\ProcessHacker-150.png");

                if ((Flags & BuildFlags.Build32bit) == BuildFlags.Build32bit)
                {
                    // create the package manifest
                    string appxManifestString = Properties.Resources.AppxManifest;
                    appxManifestString = appxManifestString.Replace("PH_APPX_ARCH", "x86");
                    appxManifestString = appxManifestString.Replace("PH_APPX_VERSION", BuildLongVersion);
                    File.WriteAllText(BuildOutputFolder + "\\AppxManifest32.xml", appxManifestString);

                    // create the package mapping file
                    StringBuilder packageMap32 = new StringBuilder(0x100);
                    packageMap32.AppendLine("[Files]");
                    packageMap32.AppendLine("\"" + BuildOutputFolder + "\\AppxManifest32.xml\" \"AppxManifest.xml\"");
                    packageMap32.AppendLine("\"" + BuildOutputFolder + "\\ProcessHacker-44.png\" \"Assets\\ProcessHacker-44.png\"");
                    packageMap32.AppendLine("\"" + BuildOutputFolder + "\\ProcessHacker-50.png\" \"Assets\\ProcessHacker-50.png\"");
                    packageMap32.AppendLine("\"" + BuildOutputFolder + "\\ProcessHacker-150.png\" \"Assets\\ProcessHacker-150.png\"");

                    var filesToAdd = Directory.GetFiles("bin\\Release32", "*", SearchOption.AllDirectories);
                    foreach (string filePath in filesToAdd)
                    {
                        // Ignore junk files
                        if (filePath.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase) ||
                            filePath.EndsWith(".iobj", StringComparison.OrdinalIgnoreCase) ||
                            filePath.EndsWith(".ipdb", StringComparison.OrdinalIgnoreCase) ||
                            filePath.EndsWith(".exp", StringComparison.OrdinalIgnoreCase) ||
                            filePath.EndsWith(".lib", StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }

                        packageMap32.AppendLine("\"" + filePath + "\" \"" + filePath.Substring("bin\\Release32\\".Length) + "\"");
                    }
                    File.WriteAllText(BuildOutputFolder + "\\package32.map", packageMap32.ToString());

                    // create the package
                    var error = Win32.ShellExecute(
                        makeAppxExePath,
                        "pack /o /f " + BuildOutputFolder + "\\package32.map /p " +
                        BuildOutputFolder + "\\processhacker-build-package-x32.appx"
                        );
                    Program.PrintColorMessage(Environment.NewLine + error, ConsoleColor.Gray, true, Flags);

                    // sign the package
                    error = Win32.ShellExecute(
                        signToolExePath,
                        "sign /v /fd SHA256 /a /f " + BuildOutputFolder + "\\processhacker-appx.pfx /td SHA256 " +
                        BuildOutputFolder + "\\processhacker-build-package-x32.appx"
                        );
                    Program.PrintColorMessage(Environment.NewLine + error, ConsoleColor.Gray, true, Flags);
                }

                if ((Flags & BuildFlags.Build64bit) == BuildFlags.Build64bit)
                {
                    // create the package manifest
                    string appxManifestString = Properties.Resources.AppxManifest;
                    appxManifestString = appxManifestString.Replace("PH_APPX_ARCH", "x64");
                    appxManifestString = appxManifestString.Replace("PH_APPX_VERSION", BuildLongVersion);
                    File.WriteAllText(BuildOutputFolder + "\\AppxManifest64.xml", appxManifestString);

                    StringBuilder packageMap64 = new StringBuilder(0x100);
                    packageMap64.AppendLine("[Files]");
                    packageMap64.AppendLine("\"" + BuildOutputFolder + "\\AppxManifest64.xml\" \"AppxManifest.xml\"");
                    packageMap64.AppendLine("\"" + BuildOutputFolder + "\\ProcessHacker-44.png\" \"Assets\\ProcessHacker-44.png\"");
                    packageMap64.AppendLine("\"" + BuildOutputFolder + "\\ProcessHacker-50.png\" \"Assets\\ProcessHacker-50.png\"");
                    packageMap64.AppendLine("\"" + BuildOutputFolder + "\\ProcessHacker-150.png\" \"Assets\\ProcessHacker-150.png\"");

                    var filesToAdd = Directory.GetFiles("bin\\Release64", "*", SearchOption.AllDirectories);
                    foreach (string filePath in filesToAdd)
                    {
                        // Ignore junk files
                        if (filePath.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase) ||
                            filePath.EndsWith(".iobj", StringComparison.OrdinalIgnoreCase) ||
                            filePath.EndsWith(".ipdb", StringComparison.OrdinalIgnoreCase) ||
                            filePath.EndsWith(".exp", StringComparison.OrdinalIgnoreCase) ||
                            filePath.EndsWith(".lib", StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }

                        packageMap64.AppendLine("\"" + filePath + "\" \"" + filePath.Substring("bin\\Release64\\".Length) + "\"");
                    }
                    File.WriteAllText(BuildOutputFolder + "\\package64.map", packageMap64.ToString());

                    // create the package
                    var error = Win32.ShellExecute(
                        makeAppxExePath,
                        "pack /o /f " + BuildOutputFolder + "\\package64.map /p " +
                        BuildOutputFolder + "\\processhacker-build-package-x64.appx"
                        );
                    Program.PrintColorMessage(Environment.NewLine + error, ConsoleColor.Gray, true, Flags);

                    // sign the package
                    error = Win32.ShellExecute(
                        signToolExePath,
                        "sign /v /fd SHA256 /a /f " + BuildOutputFolder + "\\processhacker-appx.pfx /td SHA256 " +
                        BuildOutputFolder + "\\processhacker-build-package-x64.appx"
                        );
                    Program.PrintColorMessage(Environment.NewLine + error, ConsoleColor.Gray, true, Flags);
                }

                {
                    // create the appx bundle map
                    StringBuilder bundleMap = new StringBuilder(0x100);
                    bundleMap.AppendLine("[Files]");
                    bundleMap.AppendLine("\"" + BuildOutputFolder + "\\processhacker-build-package-x32.appx\" \"processhacker-build-package-x32.appx\"");
                    bundleMap.AppendLine("\"" + BuildOutputFolder + "\\processhacker-build-package-x64.appx\" \"processhacker-build-package-x64.appx\"");
                    File.WriteAllText(BuildOutputFolder + "\\bundle.map", bundleMap.ToString());

                    if (File.Exists(BuildOutputFolder + "\\processhacker-build-package.appxbundle"))
                    {
                        File.Delete(BuildOutputFolder + "\\processhacker-build-package.appxbundle");
                    }

                    // create the appx bundle package
                    var error = Win32.ShellExecute(
                        makeAppxExePath,
                        "bundle /f " + BuildOutputFolder + "\\bundle.map /p " +
                        BuildOutputFolder + "\\processhacker-build-package.appxbundle"
                        );
                    Program.PrintColorMessage(Environment.NewLine + error, ConsoleColor.Gray, true, Flags);

                    // sign the appx bundle package
                    error = Win32.ShellExecute(
                        signToolExePath,
                        "sign /v /fd SHA256 /a /f " + BuildOutputFolder + "\\processhacker-appx.pfx /td SHA256 " +
                        BuildOutputFolder + "\\processhacker-build-package.appxbundle"
                        );
                    Program.PrintColorMessage(Environment.NewLine + error, ConsoleColor.Gray, true, Flags);
                }

                foreach (string file in cleanupAppxArray)
                {
                    if (File.Exists(file))
                    {
                        File.Delete(file);
                    }
                }
            }
            catch (Exception ex)
            {
                Program.PrintColorMessage("[ERROR] " + ex, ConsoleColor.Red);
            }
        }
Пример #21
0
    public void Build(BuildFlags buildFlags)
    {
#if UNITY_EDITOR
        // Sanitize tilePrefabs input, to avoid branches later
        if (data != null && spriteCollection != null)
        {
            if (data.tilePrefabs == null)
            {
                data.tilePrefabs = new GameObject[SpriteCollectionInst.Count];
            }
            else if (data.tilePrefabs.Length != SpriteCollectionInst.Count)
            {
                System.Array.Resize(ref data.tilePrefabs, SpriteCollectionInst.Count);
            }

            // Fix up data if necessary
            BuilderUtil.InitDataStore(this);
        }
        else
        {
            return;
        }

        // Sanitize sprite collection material ids
        if (SpriteCollectionInst)
        {
            SpriteCollectionInst.InitMaterialIds();
        }

        bool forceBuild = (buildFlags & BuildFlags.ForceBuild) != 0;

        // When invalid, everything needs to be rebuilt
        if (SpriteCollectionInst && SpriteCollectionInst.buildKey != spriteCollectionKey)
        {
            forceBuild = true;
        }

        // Remember active layers
        Dictionary <Layer, bool> layersActive = new Dictionary <Layer, bool>();
        if (layers != null)
        {
            for (int layerIdx = 0; layerIdx < layers.Length; ++layerIdx)
            {
                Layer layer = layers[layerIdx];
                if (layer != null && layer.gameObject != null)
                {
#if UNITY_3_5
                    layersActive[layer] = layer.gameObject.active;
#else
                    layersActive[layer] = layer.gameObject.activeSelf;
#endif
                }
            }
        }

        if (forceBuild)
        {
            ClearSpawnedInstances();
        }

        BuilderUtil.CreateRenderData(this, _inEditMode, layersActive);

        RenderMeshBuilder.Build(this, _inEditMode, forceBuild);

        if (!_inEditMode)
        {
#if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2)
            tk2dSpriteDefinition def = SpriteCollectionInst.FirstValidDefinition;
            if (def != null && def.physicsEngine == tk2dSpriteDefinition.PhysicsEngine.Physics2D)
            {
#if !STRIP_PHYSICS_2D
                ColliderBuilder2D.Build(this, forceBuild);
#endif
            }
            else
#endif
            {
#if !STRIP_PHYSICS_3D
                ColliderBuilder3D.Build(this, forceBuild);
#endif
            }
            BuilderUtil.SpawnPrefabs(this, forceBuild);
        }

        // Clear dirty flag on everything
        foreach (var layer in layers)
        {
            layer.ClearDirtyFlag();
        }
        if (colorChannel != null)
        {
            colorChannel.ClearDirtyFlag();
        }

        // Update sprite collection key
        if (SpriteCollectionInst)
        {
            spriteCollectionKey = SpriteCollectionInst.buildKey;
        }
#endif
    }
Пример #22
0
    public void Build(BuildFlags buildFlags)
    {
        if (spriteCollection != null)
        {
            _spriteCollectionInst = spriteCollection.inst;
        }


#if UNITY_EDITOR || !UNITY_FLASH
        // Sanitize tilePrefabs input, to avoid branches later
        if (data != null && spriteCollection != null)
        {
            if (data.tilePrefabs == null)
            {
                data.tilePrefabs = new Object[SpriteCollectionInst.Count];
            }
            else if (data.tilePrefabs.Length != SpriteCollectionInst.Count)
            {
                System.Array.Resize(ref data.tilePrefabs, SpriteCollectionInst.Count);
            }

            // Fix up data if necessary
            BuilderUtil.InitDataStore(this);
        }
        else
        {
            return;
        }

        // Sanitize sprite collection material ids
        if (SpriteCollectionInst)
        {
            SpriteCollectionInst.InitMaterialIds();
        }

        bool forceBuild = (buildFlags & BuildFlags.ForceBuild) != 0;

        // When invalid, everything needs to be rebuilt
        if (SpriteCollectionInst && SpriteCollectionInst.buildKey != spriteCollectionKey)
        {
            forceBuild = true;
        }

        // Remember active layers
        Dictionary <Layer, bool> layersActive = new Dictionary <Layer, bool>();
        if (layers != null)
        {
            for (int layerIdx = 0; layerIdx < layers.Length; ++layerIdx)
            {
                Layer layer = layers[layerIdx];
                if (layer != null && layer.gameObject != null)
                {
#if UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9
                    layersActive[layer] = layer.gameObject.active;
#else
                    layersActive[layer] = layer.gameObject.activeSelf;
#endif
                }
            }
        }

        if (forceBuild)
        {
            ClearSpawnedInstances();
        }

        BuilderUtil.CreateRenderData(this, _inEditMode, layersActive);

        RenderMeshBuilder.Build(this, _inEditMode, forceBuild);

        if (!_inEditMode)
        {
            ColliderBuilder.Build(this, forceBuild);
            BuilderUtil.SpawnPrefabs(this, forceBuild);
        }

        // Clear dirty flag on everything
        foreach (var layer in layers)
        {
            layer.ClearDirtyFlag();
        }
        if (colorChannel != null)
        {
            colorChannel.ClearDirtyFlag();
        }

        // Update sprite collection key
        if (SpriteCollectionInst)
        {
            spriteCollectionKey = SpriteCollectionInst.buildKey;
        }
#endif
    }
 public void Build(BuildFlags buildFlags)
 {
     if ((this.data != null) && (this.spriteCollection != null))
     {
         if (this.data.tilePrefabs == null)
         {
             this.data.tilePrefabs = new GameObject[this.SpriteCollectionInst.Count];
         }
         else if (this.data.tilePrefabs.Length != this.SpriteCollectionInst.Count)
         {
             Array.Resize<GameObject>(ref this.data.tilePrefabs, this.SpriteCollectionInst.Count);
         }
         BuilderUtil.InitDataStore(this);
         if (this.SpriteCollectionInst != null)
         {
             this.SpriteCollectionInst.InitMaterialIds();
         }
         bool forceBuild = (buildFlags & BuildFlags.ForceBuild) != BuildFlags.Default;
         if ((this.SpriteCollectionInst != null) && (this.SpriteCollectionInst.buildKey != this.spriteCollectionKey))
         {
             forceBuild = true;
         }
         Dictionary<Layer, bool> layersActive = new Dictionary<Layer, bool>();
         if (this.layers != null)
         {
             for (int i = 0; i < this.layers.Length; i++)
             {
                 Layer layer = this.layers[i];
                 if ((layer != null) && (layer.gameObject != null))
                 {
                     layersActive[layer] = layer.gameObject.activeSelf;
                 }
             }
         }
         if (forceBuild)
         {
             this.ClearSpawnedInstances();
         }
         BuilderUtil.CreateRenderData(this, this._inEditMode, layersActive);
         RenderMeshBuilder.Build(this, this._inEditMode, forceBuild);
         if (!this._inEditMode)
         {
             tk2dSpriteDefinition firstValidDefinition = this.SpriteCollectionInst.FirstValidDefinition;
             if ((firstValidDefinition != null) && (firstValidDefinition.physicsEngine == tk2dSpriteDefinition.PhysicsEngine.Physics2D))
             {
                 ColliderBuilder2D.Build(this, forceBuild);
             }
             else
             {
                 ColliderBuilder3D.Build(this, forceBuild);
             }
             BuilderUtil.SpawnPrefabs(this, forceBuild);
         }
         foreach (Layer layer2 in this.layers)
         {
             layer2.ClearDirtyFlag();
         }
         if (this.colorChannel != null)
         {
             this.colorChannel.ClearDirtyFlag();
         }
         if (this.SpriteCollectionInst != null)
         {
             this.spriteCollectionKey = this.SpriteCollectionInst.buildKey;
         }
     }
 }
Пример #24
0
 private ScriptAssembly[] GetAllScriptAssemblies(BuildFlags buildFlags, EditorScriptCompilationOptions options)
 {
     return(this.GetAllScriptAssemblies(buildFlags, options, this.unityAssemblies, this.precompiledAssemblies));
 }
        public static IEnumerable <LuminBuild> CreateFromPath(string InProjectName, string InPath)
        {
            string BuildPath = InPath;

            List <LuminBuild> DiscoveredBuilds = new List <LuminBuild>();

            DirectoryInfo Di = new DirectoryInfo(BuildPath);

            if (Di.Exists)
            {
                // find all install batchfiles
                FileInfo[] InstallFiles = Di.GetFiles("Install_*");

                foreach (FileInfo Fi in InstallFiles)
                {
                    Log.Verbose("Pulling install data from {0}", Fi.FullName);

                    string AbsPath = Fi.Directory.FullName;

                    // read contents and replace linefeeds (regex doesn't stop on them :((
                    string BatContents = File.ReadAllText(Fi.FullName).Replace(Environment.NewLine, "\n");

                    // Replace .bat with .mpk and strip up to and including the first _, that is then our MPK name
                    string SourceMpkPath = Regex.Replace(Fi.Name, ".bat", ".mpk", RegexOptions.IgnoreCase);
                    SourceMpkPath = SourceMpkPath.Substring(SourceMpkPath.IndexOf("_") + 1);
                    SourceMpkPath = Path.Combine(AbsPath, SourceMpkPath);

                    Match  Info             = Regex.Match(BatContents, @"install\s+(-u+)\s""%~dp0\\(.+)""");
                    string LuminPackageName = Info.Groups[2].ToString();

                    if (string.IsNullOrEmpty(SourceMpkPath))
                    {
                        Log.Warning("No MPK found for build at {0}", Fi.FullName);
                        continue;
                    }

                    if (string.IsNullOrEmpty(LuminPackageName))
                    {
                        Log.Warning("No product name found for build at {0}", Fi.FullName);
                        continue;
                    }

                    UnrealTargetConfiguration UnrealConfig = UnrealHelpers.GetConfigurationFromExecutableName(InProjectName, Fi.Name);

                    // Lumin builds are always packaged, and we can always replace the command line
                    BuildFlags Flags = BuildFlags.Packaged | BuildFlags.CanReplaceCommandLine;

                    if (AbsPath.Contains("Bulk"))
                    {
                        Flags |= BuildFlags.Bulk;
                    }
                    else
                    {
                        Flags |= BuildFlags.NotBulk;
                    }

                    LuminBuild NewBuild = new LuminBuild(UnrealConfig, LuminPackageName, SourceMpkPath, Flags);

                    DiscoveredBuilds.Add(NewBuild);

                    Log.Verbose("Found {0} {1} build at {2}", UnrealConfig, ((Flags & BuildFlags.Bulk) == BuildFlags.Bulk) ? "(bulk)" : "(not bulk)", AbsPath);
                }
            }

            return(DiscoveredBuilds);
        }
Пример #26
0
        public MonoIsland[] GetAllMonoIslands(PrecompiledAssembly[] unityAssembliesArg, PrecompiledAssembly[] precompiledAssembliesArg, BuildFlags buildFlags)
        {
            EditorScriptCompilationOptions options = ((buildFlags & BuildFlags.BuildingForEditor) == BuildFlags.None) ? EditorScriptCompilationOptions.BuildingEmpty : EditorScriptCompilationOptions.BuildingForEditor;

            ScriptAssembly[] allScriptAssemblies = this.GetAllScriptAssemblies(buildFlags, options, unityAssembliesArg, precompiledAssembliesArg);
            MonoIsland[]     array = new MonoIsland[allScriptAssemblies.Length];
            for (int i = 0; i < allScriptAssemblies.Length; i++)
            {
                array[i] = allScriptAssemblies[i].ToMonoIsland(BuildFlags.BuildingForEditor, EditorCompilation.EditorTempPath);
            }
            return(array);
        }
Пример #27
0
        public static IEnumerable <AndroidBuild> CreateFromPath(string InProjectName, string InPath)
        {
            string BuildPath = InPath;

            List <AndroidBuild> DiscoveredBuilds = new List <AndroidBuild>();

            DirectoryInfo Di = new DirectoryInfo(BuildPath);


            // find all install batchfiles
            FileInfo[] InstallFiles = Di.GetFiles("Install_*");

            foreach (FileInfo Fi in InstallFiles)
            {
                bool PackageIs32Bit = Fi.FullName.Contains("armv7");

                UnrealTargetConfiguration UnrealConfig = UnrealHelpers.GetConfigurationFromExecutableName(InProjectName, Fi.FullName);
                UnrealTargetRole          UnrealRole   = UnrealHelpers.GetRoleFromExecutableName(InProjectName, Fi.FullName);

                if (UnrealConfig == UnrealTargetConfiguration.Unknown)
                {
                    Log.Info("Skipping unrecognized build {0}", Fi.FullName);
                    continue;
                }

                bool TestInstall  = Fi.Name.EndsWith("_TEST.bat", StringComparison.OrdinalIgnoreCase);
                bool PatchInstall = Fi.Name.EndsWith("_Patch.bat", StringComparison.OrdinalIgnoreCase);

                // filter out non-matching or test installation batch files
                // test installation scripts are intended to be manually invoked
                if (TestInstall || PatchInstall)
                {
                    if (TestInstall || PatchInstall)
                    {
                        Log.Verbose("Ignoring {0} installation batch file {1}", TestInstall ? "test" : "patch", Fi.Name);
                    }

                    continue;
                }

                Log.Verbose("Pulling install data from {0}", Fi.FullName);

                string AbsPath = Fi.Directory.FullName;

                // read contents and replace linefeeds (regex doesn't stop on them :((
                string BatContents = File.ReadAllText(Fi.FullName).Replace(Environment.NewLine, "\n");

                // Replace .bat with .apk and strip up to and including the first _, that is then our APK name
                var SourceApkMatch = Regex.Match(BatContents, @" install\s+(.+\.apk)");
                if (SourceApkMatch.Groups.Count <= 0)
                {
                    Log.Warning("Could not parse install command from {0}", Fi.FullName);
                    continue;
                }
                string SourceApkPath = Path.Combine(AbsPath, SourceApkMatch.Groups[1].ToString());

                // save com.companyname.product
                string AndroidPackageName = Regex.Match(BatContents, @"uninstall\s+(com\..+)").Groups[1].ToString();

                // pull all OBBs (probably just one..)
                var OBBMatches = Regex.Matches(BatContents, @"push\s+(.+?)\s+(.+)");

                // save them as a dict of full paths as keys and dest paths as values
                Dictionary <string, string> FilesToInstall = OBBMatches.Cast <Match>().ToDictionary(M => Path.Combine(AbsPath, M.Groups[1].ToString()), M => M.Groups[2].ToString());

                if (string.IsNullOrEmpty(SourceApkPath))
                {
                    Log.Warning("No APK found for build at {0}", Fi.FullName);
                    continue;
                }

                if (!File.Exists(SourceApkPath))
                {
                    Log.Warning("Resolved APK name but it doesn't exist {0}", SourceApkPath);
                    continue;
                }

                if (string.IsNullOrEmpty(AndroidPackageName))
                {
                    Log.Warning("No product name found for build at {0}", Fi.FullName);
                    continue;
                }

                // Android builds are always packaged, and we can always replace the command line
                BuildFlags Flags = BuildFlags.Packaged | BuildFlags.CanReplaceCommandLine;

                // if there's data then the pak files are in an obb and we can sub in a new exe
                if (FilesToInstall.Count() > 0)
                {
                    Flags |= BuildFlags.CanReplaceExecutable;
                }
                if (AbsPath.Contains("Bulk"))
                {
                    Flags |= BuildFlags.Bulk;
                }
                else
                {
                    Flags |= BuildFlags.NotBulk;
                }

                AndroidBuild NewBuild = new AndroidBuild(UnrealConfig, AndroidPackageName, SourceApkPath, FilesToInstall, Flags, PackageIs32Bit);

                DiscoveredBuilds.Add(NewBuild);

                Log.Verbose("Found {0} {1} build at {2}", UnrealConfig, ((Flags & BuildFlags.Bulk) == BuildFlags.Bulk) ? "(bulk)" : "(not bulk)", AbsPath);
            }

            // If we have both 32 and 64-bit builds, prefer 64-bit
            if (DiscoveredBuilds.Where(B => B.Is32Bit == false).Any())
            {
                DiscoveredBuilds = DiscoveredBuilds.Where(B => !B.Is32Bit).ToList();
            }

            return(DiscoveredBuilds);
        }
        public static IEnumerable <AndroidBuild> CreateFromPath(string InProjectName, string InPath)
        {
            string BuildPath = InPath;

            List <AndroidBuild> DiscoveredBuilds = new List <AndroidBuild>();

            DirectoryInfo Di = new DirectoryInfo(BuildPath);


            // find all install batchfiles
            FileInfo[] InstallFiles = Di.GetFiles("Install_*");

            foreach (FileInfo Fi in InstallFiles)
            {
                // todo
                if (Fi.FullName.Contains("armv7"))
                {
                    continue;
                }

                // Unreal naming. In test & shipping the platform name and config will be includedn
                string RegEx = "Install_(.+?)(client|game|server)-(Android)?-?(test|shipping)?-?(.+).bat";

                Match Info = Regex.Match(Fi.Name, RegEx, RegexOptions.IgnoreCase);

                bool TestInstall = Fi.Name.EndsWith("_TEST.bat", StringComparison.OrdinalIgnoreCase);

                // filter out non-matching or test installation batch files
                // test installation scripts are intended to be manually invoked
                if (Info.Success == false || TestInstall)
                {
                    if (TestInstall)
                    {
                        Log.Verbose("Ignoring test installation batch file {0}", Fi.Name);
                    }
                    continue;
                }

                string TargetName = Info.Groups[1].ToString();
                string TypeName   = Info.Groups[2].ToString();
                string ConfigName = Info.Groups[4].ToString();

                if (string.IsNullOrEmpty(ConfigName))
                {
                    ConfigName = "Development";
                }


                Log.Verbose("Pulling install data from {0}", Fi.FullName);

                string AbsPath = Fi.Directory.FullName;

                // read contents and replace linefeeds (regex doesn't stop on them :((
                string BatContents = File.ReadAllText(Fi.FullName).Replace(Environment.NewLine, "\n");

                // Replace .bat with .apk and strip up to and including the first _, that is then our APK name
                string SourceApkPath = Regex.Replace(Fi.Name, ".bat", ".apk", RegexOptions.IgnoreCase);
                SourceApkPath = SourceApkPath.Substring(SourceApkPath.IndexOf("_") + 1);
                SourceApkPath = Path.Combine(AbsPath, SourceApkPath);

                // save com.companyname.product
                string AndroidPackageName = Regex.Match(BatContents, @"uninstall\s+(com\..+)").Groups[1].ToString();

                // pull all OBBs (probably just one..)
                var OBBMatches = Regex.Matches(BatContents, @"push\s+(.+?)\s+(.+)");

                // save them as a dict of full paths as keys and dest paths as values
                Dictionary <string, string> FilesToInstall = OBBMatches.Cast <Match>().ToDictionary(M => Path.Combine(AbsPath, M.Groups[1].ToString()), M => M.Groups[2].ToString());

                if (string.IsNullOrEmpty(SourceApkPath))
                {
                    Log.Warning("No APK found for build at {0}", Fi.FullName);
                    continue;
                }

                if (string.IsNullOrEmpty(AndroidPackageName))
                {
                    Log.Warning("No product name found for build at {0}", Fi.FullName);
                    continue;
                }

                UnrealTargetConfiguration UnrealConfig;
                if (Enum.TryParse(ConfigName, true, out UnrealConfig) == false)
                {
                    Log.Warning("Could not determine Unreal Config type from '{0}'", ConfigName);
                    continue;
                }

                // Android builds are always packaged, and we can always replace the command line
                BuildFlags Flags = BuildFlags.Packaged | BuildFlags.CanReplaceCommandLine;

                // if there's data then the pak files are in an obb and we can sub in a new exe
                if (FilesToInstall.Count() > 0)
                {
                    Flags |= BuildFlags.CanReplaceExecutable;
                }
                if (AbsPath.Contains("Bulk"))
                {
                    Flags |= BuildFlags.Bulk;
                }

                AndroidBuild NewBuild = new AndroidBuild(UnrealConfig, AndroidPackageName, SourceApkPath, FilesToInstall, Flags);

                DiscoveredBuilds.Add(NewBuild);

                Log.Verbose("Found {0} {1} build at {2}", UnrealConfig, ((Flags & BuildFlags.Bulk) == BuildFlags.Bulk) ? "(bulk)" : "(not bulk)", AbsPath);
            }

            return(DiscoveredBuilds);
        }
Пример #29
0
        IEnumerable <IBuild> GetMatchingBuilds(UnrealTargetRole InRole, UnrealTargetPlatform?InPlatform, UnrealTargetConfiguration InConfiguration, BuildFlags InFlags)
        {
            if (DiscoveredBuilds == null)
            {
                return(new IBuild[0]);
            }

            // can't build without a platform
            if (InPlatform == null)
            {
                return(new IBuild[0]);
            }

            IEnumerable <IBuild> MatchingBuilds = DiscoveredBuilds.Where((B) =>
            {
                if (B.Platform == InPlatform &&
                    B.CanSupportRole(InRole) &&
                    B.Configuration == InConfiguration &&
                    (B.Flags & InFlags) == InFlags)
                {
                    return(true);
                }

                return(false);
            });

            if (MatchingBuilds.Count() > 0)
            {
                return(MatchingBuilds);
            }

            MatchingBuilds = DiscoveredBuilds.Where((B) =>
            {
                if ((InFlags & BuildFlags.CanReplaceExecutable) == BuildFlags.CanReplaceExecutable)
                {
                    if (B.Platform == InPlatform &&
                        B.CanSupportRole(InRole) &&
                        (B.Flags & InFlags) == InFlags)
                    {
                        Log.Warning("Build did not have configuration {0} for {1}, but selecting due to presence of -dev flag",
                                    InConfiguration, InPlatform);
                        return(true);
                    }
                }

                return(false);
            });

            return(MatchingBuilds);
        }
Пример #30
0
    public void Build(BuildFlags buildFlags)
    {
        if (spriteCollection != null)
        {
            _spriteCollectionInst = spriteCollection.inst;
        }


#if UNITY_EDITOR || !UNITY_FLASH
        // Sanitize tilePrefabs input, to avoid branches later
        if (data != null)
        {
            if (data.tilePrefabs == null)
            {
                data.tilePrefabs = new Object[SpriteCollectionInst.Count];
            }
            else if (data.tilePrefabs.Length != SpriteCollectionInst.Count)
            {
                System.Array.Resize(ref data.tilePrefabs, SpriteCollectionInst.Count);
            }

            // Fix up data if necessary
            BuilderUtil.InitDataStore(this);
        }
        else
        {
            return;
        }

        // Sanitize sprite collection material ids
        if (SpriteCollectionInst)
        {
            SpriteCollectionInst.InitMaterialIds();
        }

        bool forceBuild = (buildFlags & BuildFlags.ForceBuild) != 0;

        // When invalid, everything needs to be rebuilt
        if (SpriteCollectionInst && SpriteCollectionInst.buildKey != spriteCollectionKey)
        {
            forceBuild = true;
        }

        if (forceBuild)
        {
            ClearSpawnedInstances();
        }

        BuilderUtil.CreateRenderData(this, _inEditMode);

        RenderMeshBuilder.Build(this, _inEditMode, forceBuild);

        if (!_inEditMode)
        {
            ColliderBuilder.Build(this, forceBuild);
            BuilderUtil.SpawnPrefabs(this, forceBuild);
        }

        // Clear dirty flag on everything
        foreach (var layer in layers)
        {
            layer.ClearDirtyFlag();
        }
        if (colorChannel != null)
        {
            colorChannel.ClearDirtyFlag();
        }

        // Update sprite collection key
        if (SpriteCollectionInst)
        {
            spriteCollectionKey = SpriteCollectionInst.buildKey;
        }
#endif
    }
    public void Build(BuildFlags buildFlags)
    {
        // Sanitize tilePrefabs input, to avoid branches later
        if (data != null)
        {
            if (data.tilePrefabs == null)
            {
                data.tilePrefabs = new Object[spriteCollection.Count];
            }
            else if (data.tilePrefabs.Length != spriteCollection.Count)
            {
                System.Array.Resize(ref data.tilePrefabs, spriteCollection.Count);
            }

            // Fix up data if necessary
            BuilderUtil.InitDataStore(this);
        }
        else
        {
            return;
        }

        // Sanitize sprite collection material ids
        if (spriteCollection)
        {
            spriteCollection.InitMaterialIds();
        }


        bool editMode   = (buildFlags & BuildFlags.EditMode) != 0;
        bool forceBuild = (buildFlags & BuildFlags.ForceBuild) != 0;

        // When invalid, everything needs to be rebuilt
        if (spriteCollection && spriteCollection.buildKey != spriteCollectionKey)
        {
            forceBuild = true;
        }

        BuilderUtil.CreateRenderData(this, editMode);

        RenderMeshBuilder.Build(this, editMode, forceBuild);

        if (!editMode)
        {
            ColliderBuilder.Build(this);
            BuilderUtil.SpawnPrefabs(this);
        }

        // Clear dirty flag on everything
        foreach (var layer in layers)
        {
            layer.ClearDirtyFlag();
        }
        if (colorChannel != null)
        {
            colorChannel.ClearDirtyFlag();
        }

        // One random number to detect undo
        buildKey = Random.Range(0, int.MaxValue);

        // Update sprite collection key
        if (spriteCollection)
        {
            spriteCollectionKey = spriteCollection.buildKey;
        }
    }
Пример #32
0
        public static void PrintColorMessage(string Message, ConsoleColor Color, bool Newline = true, BuildFlags Flags = BuildFlags.BuildVerbose)
        {
            if ((Flags & BuildFlags.BuildVerbose) != BuildFlags.BuildVerbose)
            {
                return;
            }

            Console.ForegroundColor = Color;
            if (Newline)
            {
                Console.WriteLine(Message);
            }
            else
            {
                Console.Write(Message);
            }
            Console.ResetColor();
        }
Пример #33
0
        internal static void AddScriptAssemblyReferences(ref ScriptAssembly scriptAssembly, EditorBuildRules.TargetAssembly targetAssembly, ScriptAssemblySettings settings, BuildFlags buildFlags, EditorBuildRules.CompilationAssemblies assemblies, IDictionary <EditorBuildRules.TargetAssembly, ScriptAssembly> targetToScriptAssembly, string filenameSuffix)
        {
            List <ScriptAssembly> list  = new List <ScriptAssembly>();
            List <string>         list2 = new List <string>();
            bool flag  = (buildFlags & BuildFlags.BuildingForEditor) == BuildFlags.BuildingForEditor;
            bool flag2 = (targetAssembly.Flags & AssemblyFlags.EditorOnly) == AssemblyFlags.EditorOnly;

            if (assemblies.UnityAssemblies != null)
            {
                PrecompiledAssembly[] unityAssemblies = assemblies.UnityAssemblies;
                for (int i = 0; i < unityAssemblies.Length; i++)
                {
                    PrecompiledAssembly compiledAssembly = unityAssemblies[i];
                    if (flag || flag2)
                    {
                        if ((compiledAssembly.Flags & AssemblyFlags.UseForMono) != AssemblyFlags.None)
                        {
                            list2.Add(compiledAssembly.Path);
                        }
                    }
                    else if ((compiledAssembly.Flags & AssemblyFlags.EditorOnly) != AssemblyFlags.EditorOnly)
                    {
                        if (EditorBuildRules.IsCompiledAssemblyCompatibleWithTargetAssembly(compiledAssembly, targetAssembly, settings.BuildTarget, assemblies.CustomTargetAssemblies))
                        {
                            list2.Add(compiledAssembly.Path);
                        }
                    }
                }
            }
            foreach (EditorBuildRules.TargetAssembly current in targetAssembly.References)
            {
                ScriptAssembly item;
                if (targetToScriptAssembly.TryGetValue(current, out item))
                {
                    list.Add(item);
                }
                else
                {
                    string text = Path.Combine(settings.OutputDirectory, current.Filename);
                    if (!string.IsNullOrEmpty(filenameSuffix))
                    {
                        text = text.Replace(".dll", filenameSuffix + ".dll");
                    }
                    if (File.Exists(text))
                    {
                        list2.Add(text);
                    }
                }
            }
            if (assemblies.CustomTargetAssemblies != null && targetAssembly.Type == EditorBuildRules.TargetAssemblyType.Predefined)
            {
                EditorBuildRules.TargetAssembly[] customTargetAssemblies = assemblies.CustomTargetAssemblies;
                for (int j = 0; j < customTargetAssemblies.Length; j++)
                {
                    EditorBuildRules.TargetAssembly key = customTargetAssemblies[j];
                    ScriptAssembly item2;
                    if (targetToScriptAssembly.TryGetValue(key, out item2))
                    {
                        list.Add(item2);
                    }
                }
            }
            if (assemblies.PrecompiledAssemblies != null)
            {
                PrecompiledAssembly[] precompiledAssemblies = assemblies.PrecompiledAssemblies;
                for (int k = 0; k < precompiledAssemblies.Length; k++)
                {
                    PrecompiledAssembly compiledAssembly2 = precompiledAssemblies[k];
                    bool flag3 = (compiledAssembly2.Flags & AssemblyFlags.EditorOnly) == AssemblyFlags.EditorOnly;
                    if (!flag3 || flag2)
                    {
                        if (EditorBuildRules.IsCompiledAssemblyCompatibleWithTargetAssembly(compiledAssembly2, targetAssembly, settings.BuildTarget, assemblies.CustomTargetAssemblies))
                        {
                            list2.Add(compiledAssembly2.Path);
                        }
                    }
                }
            }
            if (flag && assemblies.EditorAssemblyReferences != null)
            {
                list2.AddRange(assemblies.EditorAssemblyReferences);
            }
            scriptAssembly.ScriptAssemblyReferences = list.ToArray();
            scriptAssembly.References = list2.ToArray();
        }