예제 #1
0
    public static string BuildOBB()
    {
        try
        {
            var tmpfoler = "/tmp/packs";
            GeneralUtils.DeleteDirectory(tmpfoler, true);               // mko: cleaning up build folder
            Directory.CreateDirectory(tmpfoler);

            var version = "1.0";
            try {
                var parts = PlayerSettings.bundleVersion.Split('.');
                version = parts[0] + "." + parts[1];
            }
            catch {
            }

            // moko: changed to do a debug dump of all builder job info first
            var    date   = System.DateTime.Now.ToString("dd/MM/yy HH:mm");
            string header = "*******************************************************************************\n";
            header += "Building to " + tmpfoler + " @" + date;
            Debug.Log(header);
            Debug.Log("Build Setting Parameters:\n" + BuildSettings.ToString());
            Debug.Log("Environment Setting Parameters:\n" + EnvironmentUtils.GetEnvirnomentDetails());

            var cl = EnvironmentUtils.Get("BUILD_CL", "0");

            PlayerSettings.bundleVersion = version + "." + cl;

            // step1 build all the bundles (extended bundles)
            var options = Bundler.BundleOptions.Force | Bundler.BundleOptions.Extended | Bundler.BundleOptions.SkipBase;
            var packs   = Bundler.BuildAll(BuildSettings.BundlerConfigFolder, options);

            var tarPath  = Path.Combine(tmpfoler, "packs.tar");
            var packPath = BuildSettings.BuildFolder;
            var gzipPath = tarPath + ".gz";

            var filesPath = Path.Combine(packPath, "files.json");
            FileUtil.DeleteFileOrDirectory(filesPath);

            // calculate the files
            var files = new Hashtable();
            foreach (var packFile in Directory.GetFiles(packPath, "*", SearchOption.AllDirectories))
            {
                var relativeName = packFile.Substring(packPath.Length + 1);
                var finfo        = new FileInfo(packFile);
                files[relativeName] = finfo.Length;
            }

            // write to the files.json
            var fileData = new Hashtable();
            fileData["packs"] = packs;
            fileData["files"] = files;
            File.WriteAllBytes(filesPath, EB.Encoding.GetBytes(EB.JSON.Stringify(fileData)));

            // turn into gz, tar archive
            using (var gzFile = new FileStream(gzipPath, FileMode.Create, FileAccess.ReadWrite))
            {
                using (var gzStream = new Ionic.Zlib.GZipStream(gzFile, Ionic.Zlib.CompressionMode.Compress, Ionic.Zlib.CompressionLevel.BestCompression))
                {
                    var writer = new tar_cs.TarWriter(gzStream);
                    foreach (var packFile in Directory.GetFiles(packPath, "*", SearchOption.AllDirectories))
                    {
                        var relativeName = packFile.Substring(packPath.Length + 1);
                        //Debug.Log("file: " + relativeName);
                        using (var f = new FileStream(packFile, FileMode.Open, FileAccess.Read))
                        {
                            writer.Write(f, f.Length, relativeName, string.Empty, string.Empty, 511, System.DateTime.UtcNow);
                        }
                    }
                    writer.Close();
                }
            }

            //var url = S3Utils.Put(gzipPath, Path.Combine(cl,cl+".obb") );

            //return url;
            return(gzipPath);
        }
        catch (System.Exception ex)
        {
            Debug.Log("BuildOBB Failed: exception: " + ex.ToString());
            throw ex;
        }
    }
예제 #2
0
    public static void BuildContentPacksWithOptions(string distList, bool skipBase, bool uploadProduction = false)
    {
        try
        {
            var tmpfoler = "/tmp/packs";
            GeneralUtils.DeleteDirectory(tmpfoler, true);               // mko: cleaning up build folder
            Directory.CreateDirectory(tmpfoler);

            var version = "1.0";
            try {
                var parts = PlayerSettings.bundleVersion.Split('.');
                version = parts[0] + "." + parts[1];
            }
            catch {
            }

            var platform = BuildSettings.Target;

            var date  = System.DateTime.Now.ToString("dd/MM/yy HH:mm");
            var cl    = EnvironmentUtils.Get("BUILD_CL", "0");
            var desc  = "Content Package " + BuildSettings.Target + " " + date + " CL: " + cl + "\n";
            var notes = (ArrayList)EB.JSON.Parse(EnvironmentUtils.Get("BUILD_NOTES", "[]"));

            PlayerSettings.bundleVersion = version + "." + cl;

            // step1 build all the bundles (extended bundles)
            var options = Bundler.BundleOptions.Force | Bundler.BundleOptions.Extended;
            if (skipBase)
            {
                options |= Bundler.BundleOptions.SkipBase;
            }

            var packs = Bundler.BuildAll(BuildSettings.BundlerConfigFolder, options);

            var files = new ArrayList();
            foreach (var pack in packs)
            {
                var tarPath  = Path.Combine(tmpfoler, pack + ".tar");
                var packPath = Path.Combine(BuildSettings.BuildFolder, pack);
                var gzipPath = tarPath + ".gz";

                // turn into gz, tar archive
                using (var gzFile = new FileStream(gzipPath, FileMode.Create, FileAccess.ReadWrite))
                {
                    using (var gzStream = new Ionic.Zlib.GZipStream(gzFile, Ionic.Zlib.CompressionMode.Compress, Ionic.Zlib.CompressionLevel.BestCompression))
                    {
                        var writer = new tar_cs.TarWriter(gzStream);
                        foreach (var packFile in Directory.GetFiles(packPath, "*", SearchOption.AllDirectories))
                        {
                            var relativeName = packFile.Substring(packPath.Length + 1);
                            //Debug.Log("file: " + relativeName);
                            using (var f = new FileStream(packFile, FileMode.Open, FileAccess.Read))
                            {
                                writer.Write(f, f.Length, relativeName, string.Empty, string.Empty, 511, System.DateTime.UtcNow);
                            }
                        }
                        writer.Close();
                    }
                }

                var info = new Hashtable();
                var size = new FileInfo(gzipPath).Length;

                info["size"]     = size;
                info["url"]      = S3Utils.Put(gzipPath, Path.Combine(cl, Path.GetFileName(gzipPath)));
                info["md5"]      = S3Utils.CalculateMD5(gzipPath);
                info["pack"]     = pack;
                info["included"] = skipBase;
                files.Add(info);
            }

            // send email
            var data = new Hashtable();
            data["cl"]         = int.Parse(cl);
            data["minVersion"] = int.Parse(cl);
            data["title"]      = desc;
            data["notes"]      = notes;
            data["files"]      = files;
            data["platform"]   = platform;

            var manifest    = EB.JSON.Stringify(data);
            var manifestUrl = S3Utils.PutData(EB.Encoding.GetBytes(manifest), "manifest.json", Path.Combine(cl, "manifest.json"));
            data["manifest"] = manifestUrl;

            if (!string.IsNullOrEmpty(manifestUrl))
            {
                UploadContentManifest(WWWUtils.Environment.LocalTest, manifestUrl, skipBase ? 1 : 0);

                if (uploadProduction)
                {
                    UploadContentManifest(WWWUtils.Environment.LocalTest, manifestUrl, skipBase ? 1 : 0);
                }
            }

            Email(distList, "New " + platform + "  Content Build: " + cl, File.ReadAllText("Assets/Editor/EB.Core.Editor/Build/Email/contentbuild.txt"), data);

            Done();
        }
        catch (System.Exception ex)
        {
            Debug.Log("BuildContentPacks Failed: exception: " + ex.ToString());
            Failed(ex);
        }

        ClearProgressBar();
    }