Exemple #1
0
        public static CurrentDir Enter(string path)
        {
            var c = new CurrentDir()
            {
                _prev = Directory.GetCurrentDirectory()
            };

            Directory.SetCurrentDirectory(path);
            Console.WriteLine("Enter CurrentDir: " + path);
            return(c);
        }
        public static void Initialize(Build builder)
        {
            //var cloneParentDir = Path.Combine(builder.LuminoBuildCacheDir, "Tools");
            var cloneParentDir = Path.Combine(builder.BuildDir, "Emscripten");

            EmsdkDir = Path.Combine(builder.BuildDir, "Emscripten", "emsdk");
            //EmsdkDir = Path.Combine(builder.LuminoBuildCacheDir, "Tools", "emsdk");
            EmscriptenRoot         = Path.Combine(EmsdkDir, "upstream", "emscripten");
            EmscriptenSysRootLocal = Path.Combine(EmscriptenRoot, "system", "local");



            // Install emsdk
            if (BuildEnvironment.IsWebTarget && Utils.IsWin32)
            {
                if (!builder.ExistsCache(EmsdkDir))
                {
                    if (!Directory.Exists(EmsdkDir))
                    {
                        Directory.CreateDirectory(cloneParentDir);
                        using (var cd = CurrentDir.Enter(cloneParentDir))
                        {
                            Utils.CallProcess("git", "clone https://github.com/juj/emsdk.git");

                            //if (!Directory.Exists(EmscriptenDir))
                            {
                                Directory.SetCurrentDirectory(Path.GetFullPath(EmsdkDir));

                                if (Utils.IsWin32)
                                {
                                    Utils.CallProcess("emsdk.bat", "install " + emsdkVer);
                                }
                                else
                                {
                                    Utils.CallProcess("emsdk", "install " + emsdkVer);
                                }

                                //Utils.CopyFile(
                                //    Path.Combine(repoRootDir, "external", "emscripten", "Emscripten.cmake"),
                                //    Path.Combine(EmscriptenDir, "cmake", "Modules", "Platform"));
                            }
                        }
                    }

                    builder.CommitCache(EmsdkDir);
                }
            }


            if (Directory.Exists(EmsdkDir))
            {
                EmscriptenFound = true;
            }
        }
Exemple #3
0
        static public void Setup(Build b)
        {
            EmsdkDir = Path.Combine(b.BuildToolsDir, "emsdk");
            if (!Directory.Exists(EmsdkDir))
            {
                using (CurrentDir.Enter(b.BuildToolsDir))
                {
                    Proc.Make("git", "clone https://github.com/juj/emsdk.git").WithSilent().Call();

                    using (CurrentDir.Enter(EmsdkDir))
                    {
                        Proc.Make("emsdk", "install " + emsdkVer)
                        .WithShell()
                        .WithSilent()
                        .Call();
                    }
                }
            }

            // $ emsdk activate xxxx
            var path = Environment.GetEnvironmentVariable("PATH");

            path = EmsdkDir + ";" + path;
            path = Path.Combine(EmsdkDir, "upstream", "emscripten") + ";" + path;
            Environment.SetEnvironmentVariable("PATH", path);
            Environment.SetEnvironmentVariable("EMSDK", EmsdkDir);
            Environment.SetEnvironmentVariable("EM_CONFIG", Path.Combine(EmsdkDir, ".emscripten"));

            Ninja = b.VcpkgDir + "/downloads/tools/ninja/1.10.1-windows/ninja.exe";

            //                    EM_CONFIG = C:\Proj\LN\Lumino\_build\tools\emsdk\.emscripten
            //EMSDK_NODE = C:\Proj\LN\Lumino\_build\tools\emsdk\node\14.15.5_64bit\bin\node.exe
            //EMSDK_PYTHON = C:\Proj\LN\Lumino\_build\tools\emsdk\python\3.9.2 - 1_64bit\python.exe
            //  JAVA_HOME = C:\Proj\LN\Lumino\_build\tools\emsdk\java\8.152_64bit


            /*
             * C:\Proj\LN\Lumino\build\tools\vcpkg
             * C:\Proj\LN\Lumino\build\tools\emsdk
             */
        }
        private static void InstallTools(Builder builder)
        {
            // BuildExternalProjects のものたちは cmake install などで、各 Target ごとの ExternalInstall に入り、このフォルダは CI によりキャッシュされる。
            // しかし一部の、主に Header-only-library はリポジトリ内のファイルを直接参照するため、キャッシュされる別のフォルダに clone する。
            // (ExternalSource フォルダは全体で 5GB を超えるため、GitHub Actions の cache size に引っかかる。そのため必要なものだけ別フォルダに逃がす)
            string buildCacheDir = Path.Combine(builder.LuminoBuildDir, "BuildCache");

            if (!builder.ExistsCache(buildCacheDir))
            {
                Directory.CreateDirectory(buildCacheDir);
                using (CurrentDir.Enter(buildCacheDir))
                {
                    if (!Directory.Exists("stb"))
                    {
                        Utils.CallProcess("git", "clone https://github.com/nothings/stb.git stb");
                        Utils.CallProcess("git", "-C stb checkout e6afb9cbae4064da8c3e69af3ff5c4629579c1d2");
                    }

                    if (!Directory.Exists("imgui"))
                    {
                        //Utils.CallProcess("git", "clone --depth 1 -b v1.72 https://github.com/ocornut/imgui.git imgui");
                        //Utils.CallProcess("git", "clone --depth 1 -b docking https://github.com/ocornut/imgui.git imgui");
                        Utils.CallProcess("git", "clone https://github.com/ocornut/imgui.git imgui");

                        // 現時点の docking ブランチの先頭
                        using (CurrentDir.Enter("imgui"))
                        {
                            Utils.CallProcess("git", "config advice.detachedHead false");
                            Utils.CallProcess("git", "checkout 732cd837a9ed8ecb2ce4035e7d40a1c9a04ae240");
                        }
                    }

                    if (!Directory.Exists("Streams"))
                    {
                        Utils.CallProcess("git", "clone https://github.com/jscheiny/Streams.git Streams");

                        using (CurrentDir.Enter("Streams"))
                        {
                            Utils.CallProcess("git", "config advice.detachedHead false");
                            Utils.CallProcess("git", "checkout 8fc0657b977cfd8f075ad0afb4dca3800630b56c");
                        }
                    }

                    if (!Directory.Exists("tinyobjloader"))
                    {
                        // v1.0.6 より後はタグが降られていないが、頂点カラーなどの対応が入っている。それを持ってくる。
                        Utils.CallProcess("git", "clone https://github.com/syoyo/tinyobjloader.git tinyobjloader");

                        using (CurrentDir.Enter("tinyobjloader"))
                        {
                            Utils.CallProcess("git", "checkout f37fed32f3eb0912cc10a970f78774cd98598ef6");
                        }
                    }

                    if (!Directory.Exists("tinygltf"))
                    {
                        Utils.CallProcess("git", "clone --depth 1 -b v2.2.0 https://github.com/syoyo/tinygltf.git tinygltf");
                    }
                }

                builder.CommitCache(buildCacheDir);
            }
            else
            {
                Logger.WriteLine("BuildCache found.");
                foreach (var dir in Directory.GetDirectories(buildCacheDir))
                {
                    Logger.WriteLine("- " + Path.GetFileName(dir));
                }
            }

            using (CurrentDir.Enter(buildCacheDir))
            {
                foreach (string file in System.IO.Directory.GetFiles("imgui", "*.h"))
                {
                    File.Copy(file, Path.Combine(builder.LuminoRootDir, "include", "LuminoEngine", "UI", "imgui", System.IO.Path.GetFileName(file)), true);
                }
            }

            string externalSourceDir = Path.Combine(builder.LuminoBuildDir, "ExternalSource");

            if (!builder.ExistsCache(externalSourceDir))
            {
                Directory.CreateDirectory(externalSourceDir);
                using (CurrentDir.Enter(externalSourceDir))
                {
                    if (!Directory.Exists("googletest"))
                    {
                        Utils.CallProcess("git", "clone --depth 1 -b release-1.8.1 https://github.com/google/googletest.git googletest");
                    }
                }
            }

            AndoridBuildEnv.Initialize(builder);

            Directory.CreateDirectory(BuildToolsDir);
        }