Пример #1
0
        public virtual bool Build()
        {
            string BuiltName     = GetBuiltNameForTarget(JobBuildTarget);
            string BuiltBaseName = BuiltName;

            if (BuiltBaseName.Contains("."))
            {
                BuiltBaseName = BuiltName.Substring(0, BuiltBaseName.LastIndexOf('.'));
            }

            string DataFolderName = BuiltBaseName + "_Data";

            if (File.Exists(BuiltName))
            {
                IgorRuntimeUtils.DeleteFile(BuiltName);
            }

            if (Directory.Exists(DataFolderName))
            {
                IgorRuntimeUtils.DeleteDirectory(DataFolderName);
            }

#if !UNITY_4_3
            BuiltName = System.IO.Path.Combine(System.IO.Path.GetFullPath("."), BuiltName);
#endif
            BuildPipeline.BuildPlayer(IgorUtils.GetLevels(), BuiltName, JobBuildTarget, IgorBuildCommon.GetBuildOptions());

            Log("Destination file is: " + BuiltName);

            List <string> BuiltFiles = new List <string>();

            if (Directory.Exists(DataFolderName))
            {
                if (IgorAssert.EnsureTrue(this, File.Exists(BuiltName), "The built file " + BuiltName + " doesn't exist.  Something went wrong during the build step.  Please check the logs!"))
                {
                    BuiltFiles.Add(BuiltName);
                }

                if (IgorAssert.EnsureTrue(this, Directory.Exists(DataFolderName), "The built data directory for the Windows build " + DataFolderName + " doesn't exist.  Something went wrong during the build step.  Please check the logs!"))
                {
                    BuiltFiles.Add(DataFolderName);
                }
            }
            else
            {
                if (IgorAssert.EnsureTrue(this, Directory.Exists(BuiltName), "The built app directory for the Mac build " + BuiltName + " doesn't exist.  Something went wrong during the build step.  Please check the logs!"))
                {
                    BuiltFiles.Add(BuiltName);
                }
            }

            IgorCore.SetNewModuleProducts(BuiltFiles);

            return(true);
        }
Пример #2
0
        public virtual bool InternalCleanupTestable(bool bRunningTestInEditor = false)
        {
            if (!bRunningTestInEditor || (TestRunnerInst.CurrentTest != null && TestRunnerInst.CurrentTest.bForceLoadToFirstSceneInEditor))
            {
                string FirstLevelName = IgorUtils.GetFirstLevelName();

                if (FirstLevelName != "")
                {
                    if (EditorApplication.currentScene != FirstLevelName)
                    {
                        EditorApplication.OpenScene(FirstLevelName);

                        return(false);
                    }
                }
            }

            MonsterStarter[] Starters = GameObject.FindObjectsOfType <MonsterStarter>();

            foreach (MonsterStarter CurrentStarter in Starters)
            {
                GameObject.DestroyImmediate(CurrentStarter.gameObject);
            }

            if (!bRunningTestInEditor)
            {
                string StreamingAssetsFolder = Path.Combine("Assets", Path.Combine("StreamingAssets", Path.Combine("Igor", Path.Combine("Monster", "Config"))));

                if (Directory.Exists(StreamingAssetsFolder))
                {
                    IgorRuntimeUtils.DeleteDirectory(StreamingAssetsFolder);
                }

                string LastValue = IgorJobConfig.GetStringParam(LastDisplayResolutionDialogFlag);

                switch (LastValue)
                {
                case "Disabled":
                    PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled;
                    break;

                case "Enabled":
                    PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Enabled;
                    break;

                case "HiddenByDefault":
                    PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.HiddenByDefault;
                    break;
                }
            }

            return(true);
        }
Пример #3
0
        public static bool ResignAPK(IIgorModule ModuleInst, string SourceAPK, string RepackagingDirectory, ref string FinalFilename, string KeystoreFilename,
                                     string KeystorePassword, string KeyAlias, string KeyAliasPassword)
        {
            if (Directory.Exists(RepackagingDirectory))
            {
                IgorRuntimeUtils.DeleteDirectory(RepackagingDirectory);
            }

            Directory.CreateDirectory(RepackagingDirectory);

            IgorZip.UnzipArchiveCrossPlatform(ModuleInst, SourceAPK, RepackagingDirectory);

            IgorRuntimeUtils.DeleteDirectory(Path.Combine(RepackagingDirectory, "META-INF"));

            string UnsignedAPK = Path.Combine(RepackagingDirectory, "Repackaged.unsigned.apk");

            List <string> APKContents = IgorRuntimeUtils.GetListOfFilesAndDirectoriesInDirectory(RepackagingDirectory);

            IgorZip.ZipFilesCrossPlatform(ModuleInst, APKContents, UnsignedAPK, false, RepackagingDirectory);

            string SignedAPK = Path.Combine(RepackagingDirectory, "Repackaged.signed.apk");

//			IgorCore.LogError(ModuleInst, "jarsigner command running from " + Path.GetFullPath(".") + " is\n" + "-verbose -keystore \"" + KeystoreFilename + "\" -storepass " + KeystorePassword +
//				" -keypass " + KeyAliasPassword + " -signedjar \"" + SignedAPK + "\" \"" + UnsignedAPK + "\" " + KeyAlias);

            if (IgorRuntimeUtils.RunProcessCrossPlatform(ModuleInst, "jarsigner", "jarsigner", "-verbose -sigalg SHA1withDSA -digestalg SHA1 -keystore \"" + KeystoreFilename + "\" -storepass " + KeystorePassword + " -keypass " +
                                                         KeyAliasPassword + " -signedjar \"" + SignedAPK + "\" \"" + UnsignedAPK + "\" " + KeyAlias, Path.GetFullPath("."), "Running jarsigner", true) != 0)
            {
                return(false);
            }

            string ZipAlignPath = GetZipAlignPath(ModuleInst);
            string AlignedAPK   = Path.Combine(RepackagingDirectory, "Repackaged.aligned.apk");

            if (IgorRuntimeUtils.RunProcessCrossPlatform(ModuleInst, ZipAlignPath, ZipAlignPath, "-v 4 \"" + SignedAPK + "\" \"" + AlignedAPK + "\"", Path.GetFullPath("."), "Running zipalign") != 0)
            {
                return(false);
            }

            FinalFilename = AlignedAPK;

            return(true);
        }
Пример #4
0
        public override string DrawJobInspectorAndGetEnabledParams(string CurrentParams)
        {
            string EnabledParams = CurrentParams;

            IgorConfigWindow        ConfigurationWindow = IgorConfigWindow.OpenOrGetConfigWindow();
            IgorPersistentJobConfig CurrentJob          = ConfigurationWindow.CurrentJobInst;
            string CurrentJobAsString = CurrentJob != null ? CurrentJob.JobName : string.Empty;
            string TargetDirectory    = kPlayerSettingsFolder + "/" + CurrentJobAsString;

            GUILayout.BeginHorizontal();
            {
                string SelectedProjectSettingsAsString = IgorRuntimeUtils.GetStringParam(EnabledParams, PlayerSettingFilesToOverrideFlag).Trim('"');

                if (!string.IsNullOrEmpty(SelectedProjectSettingsAsString))
                {
                    int OutResult = 0;
                    if (Int32.TryParse(SelectedProjectSettingsAsString, out OutResult))
                    {
                        SelectedProjectSettingsAsInt = OutResult;
                    }
                }

                int newValue = EditorGUILayout.MaskField(SelectedProjectSettingsAsInt, kProjectSettingFiles);

                if (newValue != SelectedProjectSettingsAsInt)
                {
                    SelectedProjectSettingsAsInt = newValue;
                    if (newValue != 0)
                    {
                        EnabledParams = IgorRuntimeUtils.SetStringParam(EnabledParams, PlayerSettingFilesToOverrideFlag, SelectedProjectSettingsAsInt.ToString());
                        EnabledParams = IgorRuntimeUtils.SetStringParam(EnabledParams, PlayerSettingsPathFlag, '"' + TargetDirectory + '"');
                    }
                    else
                    {
                        EnabledParams = IgorRuntimeUtils.ClearParam(EnabledParams, PlayerSettingFilesToOverrideFlag);
                        EnabledParams = IgorRuntimeUtils.ClearParam(EnabledParams, PlayerSettingsPathFlag);
                    }
                }
            }
            GUILayout.EndHorizontal();

            string FilesToSave = string.Empty;

            for (int i = 0; i < kProjectSettingFiles.Length; ++i)
            {
                if (((1 << i) & SelectedProjectSettingsAsInt) != 0)
                {
                    FilesToSave += ((string.IsNullOrEmpty(FilesToSave) ? string.Empty : ", ") + kProjectSettingFiles[i].Replace(".asset", string.Empty));
                }
            }

            GUILayout.Space(5f);
            GUILayout.Label("Files to save: " + FilesToSave);

            if (Directory.Exists(TargetDirectory))
            {
                GUILayout.Space(5f);
                string[] SourceFilesPaths = Directory.GetFiles(TargetDirectory);

                string ExistingOverrides = string.Empty;
                foreach (string SourceFilePath in SourceFilesPaths)
                {
                    ExistingOverrides += ((string.IsNullOrEmpty(ExistingOverrides) ? string.Empty : ", ") + Path.GetFileName(SourceFilePath).Replace(kIgorProjectSettingExtension, string.Empty));
                }

                GUILayout.Label("Existing overrides on disk: " + ExistingOverrides);
                GUILayout.Space(5f);
            }

            GUILayout.BeginHorizontal();
            {
                GUI.enabled = CurrentJob != null && SelectedProjectSettingsAsInt != 0;
                if (GUILayout.Button("Save", GUILayout.ExpandWidth(false)))
                {
                    if (!Directory.Exists(kPlayerSettingsFolder))
                    {
                        Directory.CreateDirectory(kPlayerSettingsFolder);
                    }

                    IgorRuntimeUtils.DeleteDirectory(TargetDirectory);
                    Directory.CreateDirectory(TargetDirectory);

                    string[] SourceFilesPaths = Directory.GetFiles("ProjectSettings");
                    foreach (string SourceFilePath in SourceFilesPaths)
                    {
                        if (!SourceFilePath.EndsWith(".meta"))
                        {
                            string FileName = Path.GetFileName(SourceFilePath);

                            int IndexInKnownAssetList = Array.IndexOf(kProjectSettingFiles, FileName, 0, kProjectSettingFiles.Length);
                            if (IndexInKnownAssetList != -1)
                            {
                                if ((((1 << IndexInKnownAssetList) & SelectedProjectSettingsAsInt) != 0) || SelectedProjectSettingsAsInt == -1)
                                {
                                    string DestFilePath = SourceFilePath.Replace("ProjectSettings\\", string.Empty);
                                    DestFilePath = TargetDirectory + "/" + Path.ChangeExtension(DestFilePath, kIgorProjectSettingExtension);
                                    IgorRuntimeUtils.CopyFile(SourceFilePath, DestFilePath);
                                }
                            }
                        }
                    }

                    AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
                }

                string Tooltip = Directory.Exists(TargetDirectory) ? string.Empty : "Expected PlayerSettings directory " + " doesn't exist.";

                GUI.enabled &= Directory.Exists(TargetDirectory);
                if (GUILayout.Button(new GUIContent("Load saved settings file", Tooltip), GUILayout.ExpandWidth(false)))
                {
                    CopyStoredPlayerSettingsOverCurrent(TargetDirectory);
                }

                GUI.enabled = true;
            }
            GUILayout.EndHorizontal();

            return(EnabledParams);
        }
Пример #5
0
        public virtual bool InternalBuildTestable(bool bRunningTestInEditor = false)
        {
            if (!bRunningTestInEditor)
            {
                if (!IgorSetScriptingDefines.ExtraModuleParams.Contains("MONSTER_TEST_RUNTIME"))
                {
                    IgorSetScriptingDefines.ExtraModuleParams += ";MONSTER_TEST_RUNTIME";
                }

                if (!IgorSetScriptingDefines.ExtraModuleParams.Contains("IGOR_RUNTIME"))
                {
                    IgorSetScriptingDefines.ExtraModuleParams += ";IGOR_RUNTIME";
                }

                IgorJobConfig.SetStringParam(LastDisplayResolutionDialogFlag, PlayerSettings.displayResolutionDialog.ToString());

                PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled;
            }

            if (!bRunningTestInEditor || (TestRunnerInst.CurrentTest != null && TestRunnerInst.CurrentTest.bForceLoadToFirstSceneInEditor))
            {
                string FirstLevelName = IgorUtils.GetFirstLevelName();

                if (FirstLevelName != "")
                {
                    if (EditorApplication.currentScene != FirstLevelName)
                    {
                        EditorApplication.OpenScene(FirstLevelName);

                        return(false);
                    }
                }
            }

            if (MonsterStarter.GetInstance() == null)
            {
                GameObject MonsterStarterInst = new GameObject("MonsterTestStarter");

                MonsterStarterInst.AddComponent <MonsterStarter>();

                EditorApplication.SaveScene();
            }

            if (!bRunningTestInEditor)
            {
                string StreamingAssetsFolder = Path.Combine("Assets", Path.Combine("StreamingAssets", Path.Combine("Igor", Path.Combine("Monster", "Config"))));

                if (Directory.Exists(StreamingAssetsFolder))
                {
                    MonsterDebug.LogError("Attempting to overwrite the " + StreamingAssetsFolder + ", but it already exists!");

                    IgorRuntimeUtils.DeleteDirectory(StreamingAssetsFolder);

                    Directory.CreateDirectory(StreamingAssetsFolder);
                }
                else
                {
                    Directory.CreateDirectory(StreamingAssetsFolder);
                }

                string ConfigRoot = Path.Combine(MonsterTestCore.MonsterLocalDirectoryRoot, "Config");

                if (Directory.Exists(ConfigRoot))
                {
                    IgorRuntimeUtils.DirectoryCopy(ConfigRoot, StreamingAssetsFolder, true);
                }
            }

            return(true);
        }
Пример #6
0
        public virtual void BuildLauncher(BuildTarget TargetTestPlatform)
        {
            MonsterDebug.Log("Building launcher for platform " + TargetTestPlatform);

            string MethodName = GetBuildMethodName(TargetTestPlatform);

            if (MethodName == "")
            {
                MonsterDebug.LogError("Test platform " + TargetTestPlatform + " is not supported yet.  Please add support for it!");
            }

            string MonsterLauncherProjectPath = Path.Combine(Application.temporaryCachePath, "MonsterLauncher");

            MonsterDebug.Log("Creating new project at " + MonsterLauncherProjectPath);

            if (Directory.Exists(MonsterLauncherProjectPath))
            {
                MonsterDebug.Log("Cleaning up old project first!");

                IgorRuntimeUtils.DeleteDirectory(MonsterLauncherProjectPath);
            }

            Directory.CreateDirectory(MonsterLauncherProjectPath);

            string LauncherProjectAssetsIgorFolder = Path.Combine(MonsterLauncherProjectPath, Path.Combine("Assets", "Igor"));

            Directory.CreateDirectory(LauncherProjectAssetsIgorFolder);

            MonsterDebug.Log("Copying project files.");

            IgorRuntimeUtils.DirectoryCopy(Path.Combine(Path.GetFullPath("."), Path.Combine("Assets", "Igor")), LauncherProjectAssetsIgorFolder, true);

            string OldLaunchersFolder = Path.Combine(LauncherProjectAssetsIgorFolder, Path.Combine("Monster", "Launchers"));

            IgorRuntimeUtils.DeleteDirectory(OldLaunchersFolder);

            MonsterDebug.Log("Copying Igor config.");

            string StreamingAssetsFolder = Path.Combine(MonsterLauncherProjectPath, Path.Combine("Assets", Path.Combine("StreamingAssets", "Igor")));

            Directory.CreateDirectory(StreamingAssetsFolder);

            if (File.Exists(IgorConfig.DefaultConfigPath))
            {
                IgorRuntimeUtils.CopyFile(IgorConfig.DefaultConfigPath, Path.Combine(StreamingAssetsFolder, IgorConfig.IgorConfigFilename));
            }

            string BuildLauncherOutput = "";
            string BuildLauncherError  = "";

            MonsterDebug.Log("Attempting to build launcher.");

            int ReturnCode = IgorRuntimeUtils.RunProcessCrossPlatform(EditorApplication.applicationPath + "/Contents/MacOS/Unity", EditorApplication.applicationPath,
                                                                      "-projectPath \"" + MonsterLauncherProjectPath + "\" -buildmachine -executeMethod " + MethodName + " -logfile Monster.log",
                                                                      MonsterLauncherProjectPath, ref BuildLauncherOutput, ref BuildLauncherError);

            if (ReturnCode != 0)
            {
                MonsterDebug.LogError("Something went wrong with the build!  Returned error code " + ReturnCode + "\n\nOutput:\n" + BuildLauncherOutput + "\n\nError:\n" + BuildLauncherError);

                return;
            }

            MonsterDebug.Log("Launcher successfully built!");

            string MonsterLauncherPath = Path.Combine(MonsterTestCore.MonsterLocalDirectoryRoot, "Launchers");

            if (!Directory.Exists(MonsterLauncherPath))
            {
                Directory.CreateDirectory(MonsterLauncherPath);
            }

            MonsterDebug.Log("Copying launcher back to project.");

            CopyLauncherToProjectPath(TargetTestPlatform, MonsterLauncherProjectPath, MonsterLauncherPath);

            IgorRuntimeUtils.DeleteDirectory(MonsterLauncherProjectPath);

            string MonsterRunPyFile = Path.Combine(MonsterLauncherPath, "MonsterRun.py");

            if (File.Exists(MonsterRunPyFile))
            {
                IgorRuntimeUtils.DeleteFile(MonsterRunPyFile);
            }

            string MonsterRunPyFileLatest = Path.Combine(IgorUpdater.LocalModuleRoot, Path.Combine("MonsterTest", Path.Combine("Core", Path.Combine("Runtime", "MonsterRun.py"))));

            if (File.Exists(MonsterRunPyFileLatest))
            {
                MonsterDebug.Log("Copying latest MonsterRun.py to the Launchers folder.");

                IgorRuntimeUtils.CopyFile(MonsterRunPyFileLatest, MonsterRunPyFile);
            }

            MonsterDebug.Log("Done building launcher for platform " + TargetTestPlatform);
        }
Пример #7
0
        public virtual bool CreateWebDeployFiles()
        {
            List <string> BuiltProducts = IgorCore.GetModuleProducts();

            string FileToCopy           = "";
            string RootProjectDirectory = "";
            string WebDeployTempDir     = Path.Combine(Path.GetFullPath("."), "iOSOTATemp");

            if (IgorAssert.EnsureTrue(this, BuiltProducts.Count > 1, "iOS OTA expected at least two built products, the IPA and the iOS XCode project directory."))
            {
                FileToCopy           = BuiltProducts[0];
                RootProjectDirectory = BuiltProducts[1];
            }

            if (IgorAssert.EnsureTrue(this, File.Exists(FileToCopy), "iOS OTA expected the IPA to be at " + FileToCopy + ", but it was not there.") &&
                IgorAssert.EnsureTrue(this, Directory.Exists(RootProjectDirectory), "iOS OTA expected the XCode Project folder to be at " + RootProjectDirectory + ", but it was not there."))
            {
                if (Directory.Exists(WebDeployTempDir))
                {
                    IgorRuntimeUtils.DeleteDirectory(WebDeployTempDir);
                }

                Directory.CreateDirectory(WebDeployTempDir);

                string PlistPath = Path.Combine(RootProjectDirectory, "Info.plist");

                string BundleIdentifier = PlayerSettings.bundleIdentifier;
                string BundleVersion    = IgorPlistUtils.GetStringValue(this, PlistPath, "CFBundleVersion");
                string DisplayName      = IgorPlistUtils.GetStringValue(this, PlistPath, "CFBundleDisplayName");

                string OTAManifestPath = GetParamOrConfigString(OTAPlistNameFlag, "", "Application", false);

                if (!OTAManifestPath.EndsWith(".plist"))
                {
                    OTAManifestPath += ".plist";
                }

                OTAManifestPath = Path.Combine(WebDeployTempDir, OTAManifestPath);

                string FullIconName = Path.Combine(RootProjectDirectory, Path.Combine("Unity-iPhone", Path.Combine("Images.xcassets", Path.Combine("AppIcon.appiconset", "Icon.png"))));

                string IPAName  = Path.GetFileName(FileToCopy);
                string IconName = Path.GetFileName(FullIconName);

                GenerateAndSavePlist(OTAManifestPath, IPAName, IconName, BundleIdentifier, BundleVersion, DisplayName);

                string IPADeployName  = Path.Combine(WebDeployTempDir, IPAName);
                string IconDeployName = Path.Combine(WebDeployTempDir, IconName);

                IgorRuntimeUtils.CopyFile(FileToCopy, IPADeployName);
                IgorRuntimeUtils.CopyFile(FullIconName, IconDeployName);

                List <string> NewBuiltProducts = new List <string>();

                NewBuiltProducts.Add(OTAManifestPath);
                NewBuiltProducts.Add(IPADeployName);
                NewBuiltProducts.Add(IconDeployName);

                IgorCore.SetNewModuleProducts(NewBuiltProducts);

                Log("iOS OTA files successfully generated.");
            }

            return(true);
        }
Пример #8
0
        public virtual bool Build(BuildOptions PlatformSpecificOptions)
        {
            if (!IgorAssert.EnsureTrue(this, GetAndroidSDKPath(this) != "", "Android SDK path is not set!"))
            {
                return(true);
            }

            PlayerSettings.Android.keystorePass = GetParamOrConfigString(AndroidKeystorePassFlag, "Your Android Keystore Password isn't set!  We won't be able to sign your application!");
            PlayerSettings.Android.keyaliasPass = GetParamOrConfigString(AndroidKeyAliasPassFlag, "Your Android Key Alias Password isn't set!  We won't be able to sign your application!");

            if (PlayerSettings.Android.keystorePass == "" || PlayerSettings.Android.keyaliasPass == "")
            {
                return(true);
            }

            FixReadOnlyFilesIn3rdPartyLibs();

            string AndroidProjDirectory = Path.Combine(Path.GetFullPath("."), "Android");

            if (AndroidProjDirectory.Contains(" "))
            {
                AndroidProjDirectory = Path.Combine(Path.GetTempPath() + PlayerSettings.productName, "Android");
            }

            if (Directory.Exists(AndroidProjDirectory))
            {
                IgorRuntimeUtils.DeleteDirectory(AndroidProjDirectory);
            }

            string FullBuiltPath = System.IO.Path.Combine(System.IO.Path.GetFullPath("."), GetBuiltNameForTarget(BuildTarget.Android));

            if (File.Exists(FullBuiltPath))
            {
                IgorRuntimeUtils.DeleteFile(FullBuiltPath);
            }

            // We need to force create the directory before we use it or it will prompt us for a path to build to
            Directory.CreateDirectory(AndroidProjDirectory);

            Log("Android project destination directory is: " + AndroidProjDirectory);

            EditorUserBuildSettings.symlinkLibraries             = true;
            EditorUserBuildSettings.exportAsGoogleAndroidProject = true;

            EditorUserBuildSettings.SetBuildLocation(BuildTarget.Android, AndroidProjDirectory);

            BuildOptions AllOptions = PlatformSpecificOptions | BuildOptions.AcceptExternalModificationsToPlayer;

            AllOptions |= GetExternalBuildOptions(JobBuildTarget);

            BuildPipeline.BuildPlayer(IgorUtils.GetLevels(), AndroidProjDirectory, BuildTarget.Android, AllOptions);

            CopyActivityOverrideSourceFiles(AndroidProjDirectory);

            List <string> BuiltFiles = new List <string>();

            BuiltFiles.Add(AndroidProjDirectory);

            IgorCore.SetNewModuleProducts(BuiltFiles);

            Log("Android Eclipse project has been created.");

            return(true);
        }