Beispiel #1
0
        static void BuildApkFromOtherEclipsePrj()
        {
            Debug.Log("BuildApkFromOtherEclipsePrj");
            string number_ = Environment.GetEnvironmentVariable("ECLIPSE_PRJ_NUMBER");
            int    number;

            if (!int.TryParse(number_, out number))
            {
                throw new Exception("Invalid ECLIPSE_PRJ_NUMBER " + number_);
            }
            Debug.Log("ECLIPSE_PRJ_NUMBER " + number);

            string shareRootDir = CommandLineReader.GetCustomArgument("ShareRootDir");

            if (!Directory.Exists(shareRootDir))
            {
                throw new Exception("ShareRootDir doesn't exist, " + shareRootDir);
            }
            Debug.Log("ShareRootDir " + shareRootDir);

            string[] dirs = Directory.GetDirectories(shareRootDir);
            string   dir  = dirs.First(d => Path.GetFileName(d).StartsWith("[" + number + "]"));

            if (dir == null)
            {
                throw new Exception("Can't find dir with build number " + number);
            }
            Debug.Log("Use dir " + dir);

            dirs = Directory.GetDirectories(dir);
            dir  = dirs.First(d => d.EndsWith(".apk_prj"));
            if (dir == null)
            {
                throw new Exception("Can't find .apk_prj with build number " + number);
            }
            Debug.Log("Use dir " + dir);

            string target_ = CommandLineReader.GetCustomArgument("Build_Target");

            if (string.IsNullOrEmpty(target_))
            {
                throw new Exception("Build_Target is empty.");
            }
            BuildMultiApkFromEclipsePrj(dir, target_);
        }
Beispiel #2
0
        static void PerformAndroidBuild()
        {
            string target = APP_NAME + "_" + DateTime.Now.ToString("MM-dd_HH-mm-ss") + ".apk";
            string dir    = "./" + TARGET_DIR + "/Android/";

            string dir_ = CommandLineReader.GetCustomArgument("Build_Dir");

            if (!String.IsNullOrEmpty(dir_))
            {
                dir = dir_;
            }
            dir = dir.Substring(0, dir.LastIndexOf("/"));
            Directory.CreateDirectory(dir);

            dir = dir + "/" + DateTime.Now.ToString("MM-dd");

            GenericBuild(SCENES, dir + "/" + target, BuildTarget.Android, BuildOptions.None);
        }
Beispiel #3
0
        static void GenericBuild(string[] scenes, string target, BuildTarget build_target, BuildOptions build_options)
        {
                #if !SERVER_BUILD
            if (build_target != EditorUserBuildSettings.activeBuildTarget)
            {
                throw new Exception("You need switch platform to " + build_target + " by your own, in case wrong operation.");
            }
                #endif

            // Version number
            var gameVersion = CommandLineReader.GetCustomArgument("Game_Version").Trim(new [] { '\r', '\n' });
            if (string.IsNullOrEmpty(gameVersion))
            {
                #if !SERVER_BUILD
                gameVersion = "0.0.1";
                #else
                throw new Exception("missing Game_Version in command line args");
                #endif
            }
            PlayerSettings.bundleVersion = gameVersion;

            string target_ = CommandLineReader.GetCustomArgument("Build_Target");
            if (!String.IsNullOrEmpty(target_))
            {
                target = target_;
            }
            string dir = target.Substring(0, target.LastIndexOf("/"));
            Directory.CreateDirectory(dir);

            Debug.Log("GenericBuild pre build.");
            Assembly[]   assemblies = AppDomain.CurrentDomain.GetAssemblies();
            MethodInfo[] methods    = assemblies.SelectMany(a => a.GetTypes())
                                      .SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
                                      .Where(m => m.GetCustomAttributes(typeof(PreBuildAttribute), false).Length > 0)
                                      .OrderBy(m => (m.GetCustomAttributes(typeof(PreBuildAttribute), false)[0] as PreBuildAttribute).callbackOrder)
                                      .ToArray();
            if (methods.Length == 0)
            {
                throw new Exception("No PreBuild method found?");
            }
            foreach (MethodInfo method in methods)
            {
                method.Invoke(null, new object[] { scenes, target, build_target, build_options });
            }

                #if !RELEASE_VERSION
            build_options |= BuildOptions.ForceEnableAssertions;
                #endif
            string prjTarget = target;
            if (build_target == BuildTarget.Android)
            {
                build_options |= BuildOptions.AcceptExternalModificationsToPlayer;
                prjTarget     += "_prj";
                #if SDK_OBBDOWNLOADER
                PlayerSettings.Android.useAPKExpansionFiles = true;
                #endif
            }
            if (Directory.Exists(prjTarget))
            {
                Directory.Delete(prjTarget, true);
            }

            Debug.Log("Start build " + build_target.ToString() + " with option " + build_options.ToString() + " to " + prjTarget);
            EditorUserBuildSettings.SwitchActiveBuildTarget(build_target);
            string res = BuildPipeline.BuildPlayer(scenes, prjTarget, build_target, build_options);
            if (res.Length > 0)
            {
                throw new Exception("BuildPlayer failure: " + res);
            }

            Debug.Log("GenericBuild post build.");
            assemblies = AppDomain.CurrentDomain.GetAssemblies();
            methods    = assemblies.SelectMany(a => a.GetTypes())
                         .SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
                         .Where(m => m.GetCustomAttributes(typeof(PostBuildAttribute), false).Length > 0)
                         .OrderBy(m => (m.GetCustomAttributes(typeof(PostBuildAttribute), false)[0] as PostBuildAttribute).callbackOrder)
                         .ToArray();
            if (methods.Length == 0)
            {
                throw new Exception("No PostBuild method found?");
            }
            foreach (MethodInfo method in methods)
            {
                method.Invoke(null, new object[] { build_target, prjTarget, target });
            }
        }