Exemple #1
0
        public static void ZipFilesMac(IIgorModule ModuleInst, List <string> FilesToZip, string ZipFilename, bool bUpdateBuildProducts, string RootDir)
        {
            string ZipParams = "-r \"" + ZipFilename + "\" ";

            foreach (string CurrentFile in FilesToZip)
            {
                ZipParams += "\"" + CurrentFile + "\" ";
            }

            string ZipOutput = "";
            string ZipError  = "";

            if (IgorRuntimeUtils.RunProcessCrossPlatform(ModuleInst, "zip", "", ZipParams, Path.GetFullPath(RootDir), "Zipping the files", true) == 0)
            {
                IgorDebug.Log(ModuleInst, "Zip file " + ZipFilename + " created successfully!\nOutput:\n" + ZipOutput + "\nError\n" + ZipError);

                if (bUpdateBuildProducts)
                {
                    List <string> NewProducts = new List <string>();

                    NewProducts.Add(ZipFilename);

                    IgorCore.SetNewModuleProducts(NewProducts);
                }
            }
        }
Exemple #2
0
        public static bool RunAnt(IIgorModule ModuleInst, string ProjectDirectory, string Targets)
        {
            string ANT_ROOT   = IgorRuntimeUtils.GetEnvVariable("ANT_ROOT");
            string AntCommand = "";

            string FinalParams = "";

#if UNITY_EDITOR_OSX
            if (ANT_ROOT != "")
            {
                AntCommand = Path.Combine(ANT_ROOT, Path.Combine("bin", "ant"));
            }
            else
            {
                AntCommand = "/usr/bin/ant";
            }

            FinalParams += Targets + " -lib " +
                           Path.Combine(EditorApplication.applicationPath, Path.Combine("Contents", Path.Combine("PlaybackEngines", Path.Combine("AndroidPlayer", Path.Combine("bin", "classes.jar")))));
#else
            AntCommand = "C:\\Windows\\System32\\cmd.exe";

            FinalParams += "/C " + ANT_ROOT + "bin\\ant.bat " + Targets + " -lib " +
                           Path.Combine(EditorApplication.applicationPath, Path.Combine("Data", Path.Combine("PlaybackEngines", Path.Combine("androidplayer", Path.Combine("bin", "classes.jar")))));
#endif // UNITY_EDITOR_OSX

            if (!IgorAssert.EnsureTrue(ModuleInst, File.Exists(AntCommand), "Can't find the Ant executable!  Did you set your ANT_ROOT?"))
            {
                return(false);
            }

//			IgorCore.LogError(ModuleInst, "Ant params are " + FinalParams);

            return(IgorRuntimeUtils.RunProcessCrossPlatform(ModuleInst, AntCommand, AntCommand, FinalParams, ProjectDirectory, "Running Ant build") == 0);
        }
Exemple #3
0
        public virtual bool RunTest(string TestName)
        {
            MonsterDebug.Log("Attempting to run test " + TestName + " on a standalone copy of the game.");

            Environment.SetEnvironmentVariable(MonsterTestCore.MonsterStarterTestNameEnvVariable, TestName);

            string AppPath = "";

            if (IgorJobConfig.IsStringParamSet(MonsterTestCore.ExplicitAppPathFlag))
            {
                AppPath = IgorJobConfig.GetStringParam(MonsterTestCore.ExplicitAppPathFlag);
            }
            else
            {
                foreach (string CurrentProduct in IgorCore.GetModuleProducts())
                {
                    if (CurrentProduct.Contains(".app"))
                    {
                        AppPath = CurrentProduct.Substring(0, CurrentProduct.IndexOf(".app") + 4);
                    }
                    else if (CurrentProduct.EndsWith(".exe"))
                    {
                        AppPath = CurrentProduct;
                    }
                }
            }

            if (AppPath.EndsWith(".app"))
            {
                AppPath = Path.Combine(AppPath, Path.Combine("Contents", Path.Combine("MacOS", AppPath.Substring(AppPath.LastIndexOf('/') + 1, AppPath.Length - AppPath.LastIndexOf('/') - 5))));

                IgorRuntimeUtils.SetFileExecutable(AppPath);
            }

            string AppOutput = "";
            string AppError  = "";

            int RunAppRC = IgorRuntimeUtils.RunProcessCrossPlatform(AppPath, AppPath, "", Path.GetFullPath("."), ref AppOutput, ref AppError);

            if (RunAppRC != 0)
            {
                MonsterDebug.LogError("Failed to run test.  App retruned RC " + RunAppRC + "!\n\nOutput:\n" + AppOutput + "\n\nError:\n" + AppError);

                return(true);
            }

            MonsterDebug.Log("Test ran successfully!\n\nOutput:\n" + AppOutput + "\n\nError:\n" + AppError);

            return(true);
        }
Exemple #4
0
        public static void ZipFilesWindows(IIgorModule ModuleInst, List <string> FilesToZip, string ZipFilename, bool bUpdateBuildProducts, string RootDir)
        {
            string ZipCommand = "";
            string ZipParams  = "";

            string PathX86 = "C:\\Program Files (x86)\\7-Zip\\7z.exe";
            string Path64  = "C:\\Program Files\\7-Zip\\7z.exe";

            if (File.Exists(PathX86))
            {
                ZipCommand = PathX86;
                ZipParams += "a -tzip \"" + ZipFilename + "\" ";
            }
            else
            if (File.Exists(Path64))
            {
                ZipCommand = Path64;
                ZipParams += "a -tzip \"" + ZipFilename + "\" ";
            }
            else
            {
                IgorDebug.LogError(ModuleInst, "7Zip is not installed.  Currently 7Zip is the only zip tool supported on Windows.\nPlease download it from here: http://www.7-zip.org/download.html");
                IgorDebug.LogError(ModuleInst, "Skipping zip step.");

                return;
            }

            foreach (string CurrentFile in FilesToZip)
            {
                ZipParams += "\"" + CurrentFile + "\" ";
            }

            string ZipOutput = "";
            string ZipError  = "";

            if (IgorRuntimeUtils.RunProcessCrossPlatform(ModuleInst, "", ZipCommand, ZipParams, Path.GetFullPath(RootDir), "Zipping the files") == 0)
            {
                IgorDebug.Log(ModuleInst, "Zip file " + ZipFilename + " created successfully!\nOutput:\n" + ZipOutput + "\nError\n" + ZipError);

                if (bUpdateBuildProducts)
                {
                    List <string> NewProducts = new List <string>();

                    NewProducts.Add(ZipFilename);

                    IgorCore.SetNewModuleProducts(NewProducts);
                }
            }
        }
Exemple #5
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);
        }
Exemple #6
0
        public static void UnzipFileWindows(IIgorModule ModuleInst, string ZipFilename, string DirectoryToUnzipTo, bool bUpdateBuildProducts)
        {
            string ZipParams = "/c unzip -o \"" + ZipFilename + "\"";

            if (DirectoryToUnzipTo != "")
            {
                ZipParams += " -d \"" + DirectoryToUnzipTo + "\"";
            }

            string ZipOutput = "";
            string ZipError  = "";

            if (IgorRuntimeUtils.RunProcessCrossPlatform(ModuleInst, "", "c:\\windows\\system32\\cmd.exe", ZipParams, Path.GetFullPath("."), "Unzipping the archive " + ZipFilename + " to folder " + DirectoryToUnzipTo, false) == 0)
            {
                IgorDebug.Log(ModuleInst, "Zip file " + ZipFilename + " unzipped successfully!\nOutput:\n" + ZipOutput + "\nError\n" + ZipError);

                if (bUpdateBuildProducts)
                {
                    if (IgorRuntimeUtils.RunProcessCrossPlatform(ModuleInst, "", "c:\\windows\\system32\\cmd.exe", "/c unzip -v \"" + ZipFilename + "\"", Path.GetFullPath("."), "Listing the contents of " + ZipFilename, ref ZipOutput, ref ZipError, false) == 0)
                    {
                        IgorDebug.Log(ModuleInst, "Zip " + ZipFilename + " contents are:\nOutput:\n" + ZipOutput + "\nError\n" + ZipError);

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

                        string[] Lines = ZipOutput.Split(new char[] { '\n', '\r' });

                        foreach (string ZipLine in Lines)
                        {
                            if (ZipLine.Contains("Defl") || ZipLine.Contains("Stored"))
                            {
                                if (!ZipLine.EndsWith("/"))
                                {
                                    NewProducts.Add(ZipLine.Substring(ZipLine.LastIndexOf(' ') + 1));
                                }
                            }
                        }

                        IgorCore.SetNewModuleProducts(NewProducts);
                    }
                }
            }
        }
Exemple #7
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);
        }
Exemple #8
0
 public static bool RunAndroidCommandLineUtility(IIgorModule ModuleInst, string ProjectDirectory, string Command)
 {
     return(IgorRuntimeUtils.RunProcessCrossPlatform(ModuleInst, GetAndroidSDKPath(ModuleInst) + "/tools/android", GetAndroidSDKPath(ModuleInst) + "/tools/android.bat", Command, ProjectDirectory, "Running Android project helper utility") == 0);
 }