Exemplo n.º 1
0
        //public override List<string> Dependencies => new List<string>() { "BuildExternalProjects" };

        public override void Build(Build b)
        {
            using (CurrentDir.Enter(b.EngineBuildDir))
            {
                // Configuration
                {
                    //var generator = "MinGW Makefiles";
                    var generator = "Ninja";

                    var args = new string[]
                    {
                        $"-G\"{generator}\"",
                        $"-DCMAKE_MAKE_PROGRAM=" + EmscriptenEnv.Ninja,
                        $"-DCMAKE_BUILD_TYPE=Release",
                        $"-DCMAKE_TOOLCHAIN_FILE=\"{b.VcpkgDir}/scripts/buildsystems/vcpkg.cmake\"",
                        $"-DCMAKE_INSTALL_PREFIX=\"{b.EngineInstallDir}\"",
                        $"-DCMAKE_DEBUG_POSTFIX=d",
                        $"-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE={EmscriptenEnv.EmsdkDir}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake",
                        //$"-DX_VCPKG_APPLOCAL_DEPS_INSTALL=ON",
                        $"-DVCPKG_TARGET_TRIPLET=\"{b.Triplet}\"",
                        $"-DLN_BUILD_TESTS=OFF",
                        b.RootDir,
                    };
                    Utils.CallProcess("cmake", string.Join(' ', args));
                }

                // Build
                {
                    Utils.CallProcess("cmake", $"--build . -j8");
                    Utils.CallProcess("cmake", $"--build . --target install");
                }
            }
        }
Exemplo n.º 2
0
        public override void Build(Build builder)
        {
            if (Utils.IsWin32)
            {
                var gemprojDir = Path.Combine(builder.LuminoToolsDir, "Bindings", "Ruby", "GemProject");

                //File.Copy(
                //    Path.Combine(builder.LuminoRootDir, "build/MSVC2019-x64-MT/EngineInstall/bin/LuminoEngine.dll"),
                //    Path.Combine(gemprojDir, "ext", "LuminoEngine.dll"));

                using (CurrentDir.Enter(gemprojDir))
                {
                    Utils.CallProcessShell("bundle", "install");    // bundle.cmd
                    Utils.CallProcessShell("rake", "build");
                    Utils.CallProcessShell("gem", "install " + Directory.EnumerateFiles("pkg", "*.gem").First());
                }
            }
        }
Exemplo n.º 3
0
        public override void Build(Build builder)
        {
            if (builder.ExistsCache(builder.GetExternalInstallDir(BuildEnvironment.Target)))
            {
                Logger.WriteLine("BuildExternalProjects has cache.");
                return;
            }

            var reposDir = Path.Combine(builder.BuildDir, "ExternalSource");

            Directory.CreateDirectory(reposDir);
            Directory.SetCurrentDirectory(reposDir);

            if (!Directory.Exists("ios-cmake"))
            {
                Utils.CallProcess("git", "clone --depth 1 -b 3.0.1 https://github.com/leetal/ios-cmake.git ios-cmake");
            }
            if (!Directory.Exists("SDL2"))
            {
                var zip = Path.Combine(reposDir, "SDL2-2.0.12.zip");
                using (var wc = new System.Net.WebClient())
                {
                    wc.DownloadFile("https://www.libsdl.org/release/SDL2-2.0.12.zip", zip);
                }

                Utils.ExtractZipFile(zip, Path.Combine(reposDir, "SDL2-2.0.12"));
                var dst = Path.Combine(reposDir, "SDL2-2.0.12", "SDL2-2.0.12");
                Utils.CopyDirectory(dst, Path.Combine(reposDir, "SDL2"));

                //System.Threading.Thread.Sleep(1000);
                //var dst = Path.Combine(reposDir, "SDL2-2.0.12", "SDL2-2.0.12");
                //var dir = new DirectoryInfo(dst);
                //dir.Attributes = dir.Attributes & ~FileAttributes.ReadOnly;
                //Directory.Move(dst, Path.Combine(reposDir, "SDL2"));
            }
            if (!Directory.Exists("tmxlite"))
            {
                Utils.CallProcess("git", "clone https://github.com/fallahn/tmxlite.git tmxlite");
                Directory.SetCurrentDirectory("tmxlite");
                Utils.CallProcess("git", "checkout 8ed41071fe0774947fc7f7c6ece77de3061a5239");
                Directory.SetCurrentDirectory(reposDir);
            }
            if (!Directory.Exists("Effekseer"))
            {
                Utils.CallProcess("git", "clone https://github.com/effekseer/Effekseer Effekseer");
                Directory.SetCurrentDirectory("Effekseer");
                Utils.CallProcess("git", "submodule update --init");
                Directory.SetCurrentDirectory(reposDir);
            }
            if (!Directory.Exists("lua"))
            {
                Utils.CallProcess("git", "clone --depth 1 -b v5.4.0 https://github.com/lua/lua.git");
                Utils.CopyFile(Path.Combine(builder.LuminoExternalDir, "lua", "CMakeLists.txt"), "lua");
            }
            if (!Directory.Exists("nanovg"))
            {
                Utils.CallProcess("git", "clone https://github.com/memononen/nanovg.git");
                using (CurrentDir.Enter("nanovg"))
                {
                    Utils.CallProcess("git", "checkout c35e80c3fed7445b4e2973fccccc89afd97834cf");
                }

                // TODO: https://github.com/memononen/nanovg/pull/565 のマージ待ち
                Utils.CopyFile(Path.Combine(builder.LuminoExternalDir, "nanovg", "CMakeLists.txt"), "nanovg");
            }
            if (!BuildEnvironment.FromCI && !Directory.Exists("glTF-Sample-Models"))
            {
                Utils.CallProcess("git", "clone https://github.com/KhronosGroup/glTF-Sample-Models");
            }

            const string bulletOptions = "-DBUILD_BULLET2_DEMOS=OFF -DBUILD_CLSOCKET=OFF -DBUILD_CPU_DEMOS=OFF -DBUILD_ENET=OFF -DBUILD_EXTRAS=OFF -DBUILD_OPENGL3_DEMOS=OFF -DBUILD_UNIT_TESTS=OFF -DINSTALL_LIBS=ON";


            if (Utils.IsWin32)
            {
                // Visual C++
                if (BuildEnvironment.IsMSVCTarget)
                {
                    var targetName     = BuildEnvironment.Target;
                    var targetFullName = BuildEnvironment.TargetFullName;
                    var configuration  = BuildEnvironment.Configuration;
                    var oggInstallDir  = Utils.ToUnixPath(Path.Combine(builder.BuildDir, $"{BuildEnvironment.TargetFullName}", "ExternalInstall", "ogg"));
                    var targetInfo     = BuildEngine_MSVC.TargetInfoMap[builder.Triplet];
                    var altRuntime     = "-DUSE_MSVC_RUNTIME_LIBRARY_DLL=" + (targetInfo.StaticRuntime == "ON" ? "OFF" : "ON");
                    var cppyamlRuntime = "-DYAML_MSVC_SHARED_RT=" + (targetInfo.StaticRuntime == "ON" ? "OFF" : "ON");

                    BuildProjectMSVC(builder, "nanovg", reposDir, targetName, targetFullName, configuration);
                    BuildProjectMSVC(builder, "SDL2", reposDir, targetName, targetFullName, configuration, $"-DSDL_SHARED=OFF -DSDL_STATIC=ON -DSSE=OFF ");
                    BuildProjectMSVC(builder, "tmxlite/tmxlite", reposDir, targetName, targetFullName, configuration, $"-DTMXLITE_STATIC_LIB=ON");
                    BuildProjectMSVC(builder, "lua", reposDir, targetName, targetFullName, configuration);

                    if (builder.Args.Contains("--enable-Effekseer"))
                    {
                        BuildProjectMSVC(builder, "Effekseer", reposDir, targetName, targetFullName, configuration, $"{altRuntime} -DBUILD_VIEWER=ON -DBUILD_EDITOR=ON -DBUILD_VULKAN=ON");
                    }
                }

                // Android
                if (LuminoBuild.AndoridBuildEnv.AndroidStudioFound && BuildEnvironment.IsAndroidTarget)
                {
                    //foreach (var target in BuildEngine_AndroidJNI.Targets)
                    {
                        var targetName    = BuildEnvironment.Target;
                        var oggInstallDir = Utils.ToUnixPath(Path.Combine(builder.BuildDir, $"{targetName}", "ExternalInstall", "ogg"));

                        BuildProjectAndroid(builder, "tmxlite/tmxlite", reposDir, targetName, "-DTMXLITE_STATIC_LIB=ON");
                        BuildProjectAndroid(builder, "nanovg", reposDir, targetName);
                    }
                }

                // Emscripten
                if (BuildEnvironment.IsWebTarget)
                {
                    var externalInstallDir = Path.Combine(EmscriptenBuildEnv.EmscriptenSysRootLocal, "ExternalInstall");
                    var oggInstallDir      = Utils.ToUnixPath(Path.Combine(externalInstallDir, "ogg"));

                    BuildProjectEm(builder, "tmxlite/tmxlite", reposDir, "Emscripten", "-DTMXLITE_STATIC_LIB=ON");
                    BuildProjectEm(builder, "nanovg", reposDir, "Emscripten");
                }
            }
            else
            {
                // iOS
                if (BuildEnvironment.IsIOSTarget)
                {
                    //var targetInfos = new []
                    //{
                    //    new { Config = "", Platform = "OS64" },
                    //new { Config = "Release", Platform = "OS64" },
                    //    new { Config = "", Platform = "SIMULATOR64" },
                    //new { Config = "Release", Platform = "SIMULATOR64" },
                    //};


                    var iOSToolchainFile = Utils.ToUnixPath(Path.Combine(builder.BuildDir, "ExternalSource", "ios-cmake", "ios.toolchain.cmake "));

                    //foreach (var t in targetInfos)
                    {
                        var dirName   = BuildEnvironment.Target;//$"iOS-{t.Platform}";
                        var platform  = dirName.Replace("iOS-", "");
                        var args      = $"-DCMAKE_TOOLCHAIN_FILE=\"{iOSToolchainFile}\" -DPLATFORM={platform}";
                        var generator = "Xcode";

                        var oggInstallDir = Utils.ToUnixPath(Path.Combine(builder.BuildDir, dirName, "ExternalInstall", "ogg"));

                        BuildProject(builder, "tmxlite/tmxlite", "", reposDir, dirName, generator, $"-DTMXLITE_STATIC_LIB=ON " + args);
                        BuildProject(builder, "nanovg", "", reposDir, dirName, generator, args);
                    }
                }

                // macOS
                if (BuildEnvironment.IsMacOSTarget)
                {
                    var targetArgs = new[]
                    {
                        //new { DirName = "macOS", Config = "Debug",Args = "" },
                        new { DirName = "macOS", Config = "", Args = "" },
                    };

                    foreach (var t in targetArgs)
                    {
                        var dirName       = t.DirName;
                        var args          = t.Args;
                        var oggInstallDir = Utils.ToUnixPath(Path.Combine(builder.BuildDir, dirName, "ExternalInstall", "ogg"));

                        var generator = "Xcode";
                        BuildProject(builder, "tmxlite/tmxlite", t.Config, reposDir, dirName, generator, $"-DTMXLITE_STATIC_LIB=ON " + args);
                        BuildProject(builder, "nanovg", t.Config, reposDir, dirName, generator, args);
                    }
                }
            }

            if (BuildEnvironment.FromCI)
            {
                // CI 環境でディスク消費を抑えるため、一時ファイルを削除する
                var buildDir = builder.GetExternalProjectBuildDir(BuildEnvironment.Target);
                Utils.DeleteDirectory(buildDir);
            }

            builder.CommitCache(builder.GetExternalInstallDir(BuildEnvironment.Target));
        }
Exemplo n.º 4
0
        public override void Build(Build b)
        {
            var targetInfo = TargetInfoMap[b.Triplet];

            var fileMoving = false;

            var buildDir   = b.EngineBuildDir;
            var installDir = b.EngineInstallDir;

            using (CurrentDir.Enter(buildDir))
            {
                // Configuration
                {
                    var additional = "";
                    if (!string.IsNullOrEmpty(targetInfo.Arch))
                    {
                        additional += "-A " + targetInfo.Arch;
                    }
                    if (!string.IsNullOrEmpty(BuildEnvironment.FbxSdkVS2017))
                    {
                        additional += "-DLN_FBX_SDK_PATH:STRING=\"{BuildEnvironment.FbxSdkVS2017}\"";
                    }

                    var args = new string[]
                    {
                        $"-G\"{targetInfo.Generator}\"",
                        $"-DCMAKE_TOOLCHAIN_FILE=\"{b.VcpkgDir}/scripts/buildsystems/vcpkg.cmake\"",
                        $"-DCMAKE_INSTALL_PREFIX=\"{installDir}\"",
                        $"-DCMAKE_DEBUG_POSTFIX=d",
                        $"-DVCPKG_TARGET_TRIPLET={b.Triplet}",
                        $"-DX_VCPKG_APPLOCAL_DEPS_INSTALL=ON",
                        $"-DLN_MSVC_STATIC_RUNTIME={targetInfo.StaticRuntime}",
                        $"-DLN_BUILD_TESTS=ON",
                        $"-DLN_BUILD_EDITOR=ON",
                        //$"-DLN_BUILD_SHARED_LIBRARY=ON",
                        $"-DLN_BUILD_EMBEDDED_SHADER_TRANSCOMPILER=ON",
                        $"-DLN_TARGET_ARCH:STRING={targetInfo.LegacyTriplet}",
                        additional,
                        b.RootDir,
                    };
                    Utils.CallProcess("cmake", string.Join(' ', args));

                    // ポストイベントからファイルコピーが行われるため、先にフォルダを作っておく
                    //Directory.CreateDirectory(Path.Combine(b.LuminoLibDir, targetInfo.LegacyTriplet));
                }

                // Build
                {
                    if (string.IsNullOrEmpty(BuildEnvironment.Configuration) || BuildEnvironment.Configuration == "Debug")
                    {
                        Utils.CallProcess("cmake", $"--build . --config Debug");
                        Utils.CallProcess("ctest", $"-C Debug --output-on-failure --verbose");
                        Utils.CallProcess("cmake", $"--build . --config Debug --target INSTALL");
                    }

                    if (string.IsNullOrEmpty(BuildEnvironment.Configuration) || BuildEnvironment.Configuration == "Release")
                    {
                        Utils.CallProcess("cmake", $"--build . --config Release");
                        Utils.CallProcess("ctest", $"-C Release --output-on-failure --verbose");
                        Utils.CallProcess("cmake", $"--build . --config Release --target INSTALL");
                    }
                }

                /*
                 * // Copy external libs to EngineInstall dir
                 * {
                 *  var externalInstallDir = Path.Combine(b.BuildDir, targetName, "ExternalInstall");
                 *  var installLibDir = Path.Combine(installDir, "lib");
                 *
                 *  foreach (var dir in Directory.GetDirectories(externalInstallDir))
                 *  {
                 *      var libDir = Path.Combine(dir, "lib");
                 *      if (Directory.Exists(libDir))
                 *      {
                 *          foreach (var file in Directory.GetFiles(libDir, "*.lib", SearchOption.TopDirectoryOnly))
                 *          {
                 *              if (fileMoving)
                 *                  File.Move(file, Path.Combine(installLibDir, Path.GetFileName(file)));
                 *              else
                 *                  File.Copy(file, Path.Combine(installLibDir, Path.GetFileName(file)), true);
                 *          }
                 *      }
                 *  }
                 * }
                 *
                 * // Copy .pdb
                 * {
                 *  // CMake では static library の PDB 出力先をコントロールできない。https://cmake.org/cmake/help/v3.1/prop_tgt/PDB_OUTPUT_DIRECTORY.html
                 *  // そのためビルドスクリプト側でコントロールする。
                 *  // 以下、パスに "Debug" を含むもののうち、lib と同じ名前の pdb ファイルをコピーする。
                 *
                 *  var installLibDir = Path.Combine(installDir, "lib");
                 *  var libfiles = Directory.GetFiles(installLibDir, "*.lib", SearchOption.TopDirectoryOnly);
                 *  var libnames = new HashSet<string>(libfiles.Select(x => Path.GetFileNameWithoutExtension(x)));
                 *  var pdbFiles = Directory.GetFiles(buildDir, "*.pdb", SearchOption.AllDirectories);
                 *  foreach (var pdbFile in pdbFiles)
                 *  {
                 *      var pdbName = Path.GetFileNameWithoutExtension(pdbFile);
                 *
                 *      // png と glfw は出力ファイル名がカスタマイズされており .pdb と名前が異なっているため個別に指定する
                 *      if (pdbName.StartsWith("png16"))
                 *          pdbName = "libpng16";
                 *      else if (pdbName.StartsWith("glfw"))
                 *          pdbName = "glfw3";
                 *
                 *      if (pdbFile.Contains("Debug") && libnames.Contains(pdbName))
                 *      {
                 *          // FIXME: CI サーバのストレージ不足対策
                 *          if (fileMoving)
                 *              File.Move(pdbFile, Path.Combine(installLibDir, Path.GetFileName(pdbFile)));
                 *          else
                 *              File.Copy(pdbFile, Path.Combine(installLibDir, Path.GetFileName(pdbFile)), true);
                 *      }
                 *  }
                 * }
                 */
            }

            if (BuildEnvironment.FromCI)
            {
                Utils.DeleteDirectory(b.EngineBuildDir);                            // Free disk space.
            }
        }
Exemplo n.º 5
0
        public override void Build(Builder builder)
        {
            if (builder.ExistsCache(builder.GetExternalInstallDir(BuildEnvironment.Target)))
            {
                Logger.WriteLine("BuildExternalProjects has cache.");
                return;
            }

            var reposDir = Path.Combine(builder.LuminoBuildDir, "ExternalSource");

            Directory.CreateDirectory(reposDir);
            Directory.SetCurrentDirectory(reposDir);

            if (!Directory.Exists("ios-cmake"))
            {
                Utils.CallProcess("git", "clone --depth 1 -b 3.0.1 https://github.com/leetal/ios-cmake.git ios-cmake");
            }
            if (!Directory.Exists("zlib"))
            {
                Utils.CallProcess("git", "clone --depth 1 -b v1.2.11 https://github.com/madler/zlib.git zlib");
                Utils.CopyFile(Path.Combine(builder.LuminoExternalDir, "zlib", "CMakeLists.txt"), "zlib");
            }
            if (!Directory.Exists("libpng"))
            {
                //Utils.CallProcess("git", "clone --depth 1 -b v1.6.9 git://git.code.sf.net/p/libpng/code libpng");
                Utils.CallProcess("git", "clone --depth 1 -b libpng17 https://github.com/glennrp/libpng.git libpng");

#if false
                var zip = Path.Combine(reposDir, "lpng1635.zip");
                Utils.DownloadFile("https://download.sourceforge.net/libpng/lpng1635.zip", zip);

                var dir = Path.Combine(reposDir, "lpng1635");
                Utils.ExtractZipFile(zip, dir);
                Directory.Move(Path.Combine(dir, "lpng1635"), Path.Combine(reposDir, "libpng"));
                //Directory.Move(dir, Path.Combine(reposDir, "libpng"));

                //Utils.CallProcess("git", "clone --depth 1 -b libpng17 https://github.com/glennrp/libpng.git libpng");
#endif
                Utils.CopyFile(Path.Combine(builder.LuminoExternalDir, "libpng", "CMakeLists.txt"), "libpng");
            }
            if (!Directory.Exists("glslang"))
            {
                Utils.CallProcess("git", "clone --depth 1 -b SDK-candidate-26-Jul-2020 https://github.com/KhronosGroup/glslang.git glslang");
            }
            if (!Directory.Exists("SPIRV-Cross"))
            {
                Utils.CallProcess("git", "clone --depth 1 -b 2020-06-29 https://github.com/KhronosGroup/SPIRV-Cross.git SPIRV-Cross");
                //Utils.CallProcess("git", "clone https://github.com/KhronosGroup/SPIRV-Cross.git SPIRV-Cross");
                //Directory.SetCurrentDirectory("SPIRV-Cross");
                //Utils.CallProcess("git", "checkout be7425ef70231ab82930331959ab487d605d0482");
                //Directory.SetCurrentDirectory(reposDir);
            }
            if (!Directory.Exists("glfw"))
            {
                // TODO: #glfw 816 の対策が現時点の最新 3.2.1 には入っていないので、開発中の master を取ってくる
                // 3.3 リリース後、そのタグで clone するようにしておく。
                if (Utils.IsMac)
                {
                    Utils.CallProcess("git", "clone https://github.com/glfw/glfw.git glfw");
                    Directory.SetCurrentDirectory("glfw");
                    Utils.CallProcess("git", "checkout 5afcd0981bf2fe9b9550f24ba298857aac6c35c2");
                    Directory.SetCurrentDirectory(reposDir);
                }
                else
                {
                    Utils.CallProcess("git", "clone --depth 1 -b 3.2.1 https://github.com/glfw/glfw.git glfw");
                }
            }
            if (!Directory.Exists("glad"))
            {
                Utils.CopyDirectory(Path.Combine(builder.LuminoExternalDir, "glad"), "glad");
                //Utils.CallProcess("git", "clone --depth 1 -b v0.1.26 https://github.com/Dav1dde/glad.git glad");
            }
            if (!Directory.Exists("openal-soft"))
            {
                Utils.CallProcess("git", "clone --depth 1 -b openal-soft-1.20.1 https://github.com/kcat/openal-soft.git");
                //// https://github.com/kcat/openal-soft/issues/183 の問題の修正後、まだタグが降られていない。そのため latest を取得
                //Utils.CallProcess("git", "clone https://github.com/kcat/openal-soft.git openal-soft");
                //Directory.SetCurrentDirectory("openal-soft");
                //Utils.CallProcess("git", "checkout 7d76cbddd6fbdb52eaa917845435b95ae89efced");
                //Directory.SetCurrentDirectory(reposDir);
            }
            if (!Directory.Exists("SDL2"))
            {
                var zip = Path.Combine(reposDir, "SDL2-2.0.12.zip");
                using (var wc = new System.Net.WebClient())
                {
                    wc.DownloadFile("https://www.libsdl.org/release/SDL2-2.0.12.zip", zip);
                }

                Utils.ExtractZipFile(zip, Path.Combine(reposDir, "SDL2-2.0.12"));
                var dst = Path.Combine(reposDir, "SDL2-2.0.12", "SDL2-2.0.12");
                Utils.CopyDirectory(dst, Path.Combine(reposDir, "SDL2"));

                //System.Threading.Thread.Sleep(1000);
                //var dst = Path.Combine(reposDir, "SDL2-2.0.12", "SDL2-2.0.12");
                //var dir = new DirectoryInfo(dst);
                //dir.Attributes = dir.Attributes & ~FileAttributes.ReadOnly;
                //Directory.Move(dst, Path.Combine(reposDir, "SDL2"));
            }
            if (!Directory.Exists("freetype2"))
            {
                Utils.CallProcess("git", "clone --depth 1 -b VER-2-7-1 git://git.sv.nongnu.org/freetype/freetype2.git freetype2");

                // freetype2 の CMakeList.txt は iOS ツールチェインを独自で持っているが、
                // 2018/11/19 時点では master のサポートでもビルドを通すことができない。
                // そのため ↑のほうにある ios-cmake を有効にするため、PLATFORM に関する設定を削除した CMakeLists.txt を使用する。
                Utils.CopyFile(Path.Combine(builder.LuminoExternalDir, "freetype2", "CMakeLists.txt"), "freetype2");
            }
            if (!Directory.Exists("ogg"))
            {
                Utils.CallProcess("git", "clone --depth 1 -b v1.3.3 https://github.com/xiph/ogg.git ogg");
            }
            if (!Directory.Exists("vorbis"))
            {
                Utils.CallProcess("git", "clone --depth 1 -b v1.3.6-lumino https://github.com/lriki/vorbis.git vorbis");
            }
            if (!Directory.Exists("bullet3"))
            {
                Utils.CallProcess("git", "clone --depth 1 -b 2.89 https://github.com/bulletphysics/bullet3.git bullet3");

                // 2.87 時点では Android ターゲットのビルドができない。
                // - ルートの CMakeLists.txt が python を探しに行く、{} 初期化リストで暗黙変換を使っている。など。
                // 2018/12/29 時点の master では対策されていたのでこれを使用する。
                //Utils.CallProcess("git", "clone https://github.com/bulletphysics/bullet3.git bullet3");
                //Directory.SetCurrentDirectory("bullet3");
                //Utils.CallProcess("git", "checkout 8bc1c8e01b1b2b9284df08385da0e03241f4e6aa");
                //Directory.SetCurrentDirectory(reposDir);
            }
            if (!Directory.Exists("pcre"))
            {
                Utils.DownloadFile("ftp://ftp.pcre.org/pub/pcre/pcre2-10.31.zip", "pcre2-10.31.zip");
                Utils.ExtractZipFile("pcre2-10.31.zip", reposDir, true);
                Directory.Move("pcre2-10.31", "pcre");
            }
            if (!Directory.Exists("tmxlite"))
            {
                Utils.CallProcess("git", "clone https://github.com/fallahn/tmxlite.git tmxlite");
                Directory.SetCurrentDirectory("tmxlite");
                Utils.CallProcess("git", "checkout 8ed41071fe0774947fc7f7c6ece77de3061a5239");
                Directory.SetCurrentDirectory(reposDir);
            }
            if (!Directory.Exists("Box2D"))
            {
                Utils.CallProcess("git", "clone --depth 1 -b v2.3.1 https://github.com/erincatto/Box2D.git Box2D");
            }
            if (!Directory.Exists("Vulkan-Headers"))
            {
                Utils.CallProcess("git", "clone --depth 1 -b v1.1.105 https://github.com/KhronosGroup/Vulkan-Headers.git Vulkan-Headers");
            }
            if (!Directory.Exists("Effekseer"))
            {
                Utils.CallProcess("git", "clone https://github.com/effekseer/Effekseer Effekseer");
                Directory.SetCurrentDirectory("Effekseer");
                Utils.CallProcess("git", "submodule update --init");
                Directory.SetCurrentDirectory(reposDir);
            }
            if (!Directory.Exists("yaml-cpp"))
            {
                //Utils.CallProcess("git", "clone --depth 1 -b yaml-cpp-0.6.3 https://github.com/jbeder/yaml-cpp.git yaml-cpp");
                // まだタグの振られていない #824 の修正がほしい
                Utils.CallProcess("git", "clone https://github.com/jbeder/yaml-cpp.git yaml-cpp");
                Directory.SetCurrentDirectory("yaml-cpp");
                Utils.CallProcess("git", "checkout 4edff1fa5dbfca16fc72d89870841bee89f8ef89");
                Directory.SetCurrentDirectory(reposDir);
            }
            if (!Directory.Exists("lua"))
            {
                Utils.CallProcess("git", "clone --depth 1 -b v5.4.0 https://github.com/lua/lua.git");
                Utils.CopyFile(Path.Combine(builder.LuminoExternalDir, "lua", "CMakeLists.txt"), "lua");
            }
            if (!Directory.Exists("nanovg"))
            {
                Utils.CallProcess("git", "clone https://github.com/memononen/nanovg.git");
                using (CurrentDir.Enter("nanovg"))
                {
                    Utils.CallProcess("git", "checkout c35e80c3fed7445b4e2973fccccc89afd97834cf");
                }

                // TODO: https://github.com/memononen/nanovg/pull/565 のマージ待ち
                Utils.CopyFile(Path.Combine(builder.LuminoExternalDir, "nanovg", "CMakeLists.txt"), "nanovg");
            }
            if (!BuildEnvironment.FromCI && !Directory.Exists("glTF-Sample-Models"))
            {
                Utils.CallProcess("git", "clone https://github.com/KhronosGroup/glTF-Sample-Models");
            }

            const string bulletOptions = "-DBUILD_BULLET2_DEMOS=OFF -DBUILD_CLSOCKET=OFF -DBUILD_CPU_DEMOS=OFF -DBUILD_ENET=OFF -DBUILD_EXTRAS=OFF -DBUILD_OPENGL3_DEMOS=OFF -DBUILD_UNIT_TESTS=OFF -DINSTALL_LIBS=ON";


            if (Utils.IsWin32)
            {
                // Visual C++
                if (BuildEnvironment.IsMSVCTarget)
                {
                    var targetName     = BuildEnvironment.Target;
                    var targetFullName = BuildEnvironment.TargetFullName;
                    var configuration  = BuildEnvironment.Configuration;
                    var zlibInstallDir = Utils.ToUnixPath(Path.Combine(builder.LuminoBuildDir, $"{BuildEnvironment.TargetFullName}", "ExternalInstall", "zlib"));
                    var pngIncludeDir  = Utils.ToUnixPath(Path.Combine(builder.LuminoBuildDir, $"{BuildEnvironment.TargetFullName}", "ExternalInstall", "libpng", "include"));
                    var oggInstallDir  = Utils.ToUnixPath(Path.Combine(builder.LuminoBuildDir, $"{BuildEnvironment.TargetFullName}", "ExternalInstall", "ogg"));
                    var targetInfo     = BuildEngine_MSVC.TargetInfoMap[targetName];
                    var altRuntime     = "-DUSE_MSVC_RUNTIME_LIBRARY_DLL=" + (targetInfo.StaticRuntime == "ON" ? "OFF" : "ON");
                    var cppyamlRuntime = "-DYAML_MSVC_SHARED_RT=" + (targetInfo.StaticRuntime == "ON" ? "OFF" : "ON");

                    BuildProjectMSVC(builder, "nanovg", reposDir, targetName, targetFullName, configuration);
                    BuildProjectMSVC(builder, "yaml-cpp", reposDir, targetName, targetFullName, configuration, $"{cppyamlRuntime} -DYAML_CPP_BUILD_TESTS=OFF -DYAML_CPP_BUILD_CONTRIB=OFF -DYAML_CPP_BUILD_TOOLS=OFF");
                    BuildProjectMSVC(builder, "zlib", reposDir, targetName, targetFullName, configuration);
                    BuildProjectMSVC(builder, "libpng", reposDir, targetName, targetFullName, configuration, $"-DZLIB_INCLUDE_DIR={zlibInstallDir}/include");
                    BuildProjectMSVC(builder, "glslang", reposDir, targetName, targetFullName, configuration);
                    BuildProjectMSVC(builder, "SPIRV-Cross", reposDir, targetName, targetFullName, configuration);
                    BuildProjectMSVC(builder, "glfw", reposDir, targetName, targetFullName, configuration, $"-DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_DOCS=OFF -DGLFW_INSTALL=ON");
                    BuildProjectMSVC(builder, "glad", reposDir, targetName, targetFullName, configuration, $"-DGLAD_INSTALL=ON");
                    BuildProjectMSVC(builder, "openal-soft", reposDir, targetName, targetFullName, configuration, $"-DALSOFT_BACKEND_DSOUND=OFF");  // find_package(DSound) で古い WindowsSDK の include パスが登録されてしまい、Windows.h など他の include が古い方に引っ張られてしまう
                    BuildProjectMSVC(builder, "SDL2", reposDir, targetName, targetFullName, configuration, $"-DSDL_SHARED=OFF -DSDL_STATIC=ON -DSSE=OFF ");
                    BuildProjectMSVC(builder, "freetype2", reposDir, targetName, targetFullName, configuration, $"-DPNG_FOUND=ON -DPNG_INCLUDE_DIRS={pngIncludeDir}");
                    BuildProjectMSVC(builder, "ogg", reposDir, targetName, targetFullName, configuration);
                    BuildProjectMSVC(builder, "vorbis", reposDir, targetName, targetFullName, configuration, $"-DOGG_ROOT={oggInstallDir}");
                    BuildProjectMSVC(builder, "bullet3", reposDir, targetName, targetFullName, configuration, $"{altRuntime} {bulletOptions}");
                    BuildProjectMSVC(builder, "pcre", reposDir, targetName, targetFullName, configuration, $"-DPCRE2_BUILD_PCRE2_8=OFF -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=OFF");
                    BuildProjectMSVC(builder, "tmxlite/tmxlite", reposDir, targetName, targetFullName, configuration, $"-DTMXLITE_STATIC_LIB=ON");
                    BuildProjectMSVC(builder, "Box2D/Box2D", reposDir, targetName, targetFullName, configuration, $"-DBOX2D_BUILD_EXAMPLES=OFF -DBOX2D_INSTALL_DOC=OFF -DBOX2D_BUILD_SHARED=OFF -DBOX2D_BUILD_STATIC=ON -DBOX2D_INSTALL=ON");
                    BuildProjectMSVC(builder, "Vulkan-Headers", reposDir, targetName, targetFullName, configuration);
                    BuildProjectMSVC(builder, "lua", reposDir, targetName, targetFullName, configuration);

                    if (builder.Args.Contains("--enable-Effekseer"))
                    {
                        BuildProjectMSVC(builder, "Effekseer", reposDir, targetName, targetFullName, configuration, $"{altRuntime} -DBUILD_VIEWER=ON -DBUILD_EDITOR=ON -DBUILD_VULKAN=ON");
                    }
                }

                // Android
                if (LuminoBuild.AndoridBuildEnv.AndroidStudioFound && BuildEnvironment.IsAndroidTarget)
                {
                    //foreach (var target in BuildEngine_AndroidJNI.Targets)
                    {
                        var targetName = BuildEnvironment.Target;

                        var zlibInstallDir = Utils.ToUnixPath(Path.Combine(builder.LuminoBuildDir, $"{targetName}", "ExternalInstall", "zlib"));
                        var pngIncludeDir  = Utils.ToUnixPath(Path.Combine(builder.LuminoBuildDir, $"{BuildEnvironment.TargetFullName}", "ExternalInstall", "libpng", "include"));
                        var oggInstallDir  = Utils.ToUnixPath(Path.Combine(builder.LuminoBuildDir, $"{targetName}", "ExternalInstall", "ogg"));

                        //BuildProjectAndroid(builder, "zlib", reposDir,targetName);
                        BuildProjectAndroid(builder, "libpng", reposDir, targetName);//, $"-DZLIB_INCLUDE_DIR={zlibInstallDir}/include");
                        BuildProjectAndroid(builder, "freetype2", reposDir, targetName, $"-DPNG_FOUND=ON -DPNG_INCLUDE_DIRS={pngIncludeDir}");
                        BuildProjectAndroid(builder, "ogg", reposDir, targetName);
                        BuildProjectAndroid(builder, "vorbis", reposDir, targetName, $"-DOGG_ROOT={oggInstallDir} -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH");
                        BuildProjectAndroid(builder, "bullet3", reposDir, targetName, bulletOptions);
                        BuildProjectAndroid(builder, "pcre", reposDir, targetName, "-DPCRE2_BUILD_PCRE2_8=OFF -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=OFF");
                        BuildProjectAndroid(builder, "tmxlite/tmxlite", reposDir, targetName, "-DTMXLITE_STATIC_LIB=ON");
                        BuildProjectAndroid(builder, "Box2D/Box2D", reposDir, targetName, "-DBOX2D_BUILD_EXAMPLES=OFF -DBOX2D_INSTALL_DOC=OFF -DBOX2D_BUILD_SHARED=OFF -DBOX2D_BUILD_STATIC=ON -DBOX2D_INSTALL=ON");
                        BuildProjectAndroid(builder, "Vulkan-Headers", reposDir, targetName);
                        BuildProjectAndroid(builder, "yaml-cpp", reposDir, targetName, $"-DYAML_CPP_BUILD_TESTS=OFF -DYAML_CPP_BUILD_CONTRIB=OFF -DYAML_CPP_BUILD_TOOLS=OFF");
                        BuildProjectAndroid(builder, "nanovg", reposDir, targetName);
                    }
                }

                // Emscripten
                if (BuildEnvironment.IsWebTarget)
                {
                    var externalInstallDir = Path.Combine(EmscriptenBuildEnv.EmscriptenSysRootLocal, "ExternalInstall");
                    var zlibInstallDir     = Utils.ToUnixPath(Path.Combine(externalInstallDir, "zlib"));
                    var pngIncludeDir      = Utils.ToUnixPath(Path.Combine(externalInstallDir, "libpng", "include"));
                    var oggInstallDir      = Utils.ToUnixPath(Path.Combine(externalInstallDir, "ogg"));

                    BuildProjectEm(builder, "zlib", reposDir, "Emscripten");
                    BuildProjectEm(builder, "libpng", reposDir, "Emscripten", $"-DZLIB_INCLUDE_DIR={zlibInstallDir}/include");
                    BuildProjectEm(builder, "glad", reposDir, "Emscripten", "-DGLAD_INSTALL=ON");
                    BuildProjectEm(builder, "freetype2", reposDir, "Emscripten", $"-DPNG_FOUND=ON -DPNG_INCLUDE_DIRS={pngIncludeDir}");
                    BuildProjectEm(builder, "ogg", reposDir, "Emscripten");
                    BuildProjectEm(builder, "vorbis", reposDir, "Emscripten", $"-DOGG_ROOT={oggInstallDir} -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH");
                    BuildProjectEm(builder, "bullet3", reposDir, "Emscripten", bulletOptions);
                    BuildProjectEm(builder, "pcre", reposDir, "Emscripten", "-DPCRE2_BUILD_PCRE2_8=OFF -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=OFF");
                    BuildProjectEm(builder, "tmxlite/tmxlite", reposDir, "Emscripten", "-DTMXLITE_STATIC_LIB=ON");
                    BuildProjectEm(builder, "Box2D/Box2D", reposDir, "Emscripten", "-DBOX2D_BUILD_EXAMPLES=OFF -DBOX2D_INSTALL_DOC=OFF -DBOX2D_BUILD_SHARED=OFF -DBOX2D_BUILD_STATIC=ON -DBOX2D_INSTALL=ON");
                    BuildProjectEm(builder, "yaml-cpp", reposDir, "Emscripten", $"-DYAML_CPP_BUILD_TESTS=OFF -DYAML_CPP_BUILD_CONTRIB=OFF -DYAML_CPP_BUILD_TOOLS=OFF");
                    BuildProjectEm(builder, "nanovg", reposDir, "Emscripten");
                }
            }
            else
            {
                // iOS
                if (BuildEnvironment.IsIOSTarget)
                {
                    //var targetInfos = new []
                    //{
                    //    new { Config = "", Platform = "OS64" },
                    //new { Config = "Release", Platform = "OS64" },
                    //    new { Config = "", Platform = "SIMULATOR64" },
                    //new { Config = "Release", Platform = "SIMULATOR64" },
                    //};


                    var iOSToolchainFile = Utils.ToUnixPath(Path.Combine(builder.LuminoBuildDir, "ExternalSource", "ios-cmake", "ios.toolchain.cmake "));

                    //foreach (var t in targetInfos)
                    {
                        var dirName   = BuildEnvironment.Target;//$"iOS-{t.Platform}";
                        var platform  = dirName.Replace("iOS-", "");
                        var args      = $"-DCMAKE_TOOLCHAIN_FILE=\"{iOSToolchainFile}\" -DPLATFORM={platform}";
                        var generator = "Xcode";

                        var zlibInstallDir = Utils.ToUnixPath(Path.Combine(builder.LuminoBuildDir, dirName, "ExternalInstall", "zlib"));
                        var pngIncludeDir  = Utils.ToUnixPath(Path.Combine(builder.LuminoBuildDir, dirName, "ExternalInstall", "libpng", "include"));
                        var oggInstallDir  = Utils.ToUnixPath(Path.Combine(builder.LuminoBuildDir, dirName, "ExternalInstall", "ogg"));

                        BuildProject(builder, "zlib", "", reposDir, dirName, generator, args);
                        BuildProject(builder, "libpng", "", reposDir, dirName, generator, $"-DZLIB_INCLUDE_DIR={zlibInstallDir}/include " + args);
                        BuildProject(builder, "freetype2", "", reposDir, dirName, generator, $"-DWITH_ZLIB=OFF -DWITH_BZip2=OFF  -DWITH_PNG=OFF -DWITH_HarfBuzz=OFF -DPNG_FOUND=ON -DPNG_INCLUDE_DIRS={pngIncludeDir} " + args);
                        BuildProject(builder, "ogg", "", reposDir, dirName, generator, args);
                        BuildProject(builder, "vorbis", "", reposDir, dirName, generator, $"-DOGG_ROOT={oggInstallDir} -DCMAKE_DEVELOPER_ROOT={builder.LuminoBuildDir} " + args);
                        BuildProject(builder, "bullet3", "", reposDir, dirName, generator, $"{bulletOptions} " + args);
                        BuildProject(builder, "pcre", "", reposDir, dirName, generator, $"-DPCRE2_BUILD_PCRE2_8=OFF -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=OFF -DPCRE2_BUILD_TESTS=OFF " + args);
                        BuildProject(builder, "tmxlite/tmxlite", "", reposDir, dirName, generator, $"-DTMXLITE_STATIC_LIB=ON " + args);
                        BuildProject(builder, "Box2D/Box2D", "", reposDir, dirName, generator, $"-DBOX2D_BUILD_EXAMPLES=OFF -DBOX2D_INSTALL_DOC=OFF -DBOX2D_BUILD_SHARED=OFF -DBOX2D_BUILD_STATIC=ON -DBOX2D_INSTALL=ON " + args);
                        BuildProject(builder, "Vulkan-Headers", "", reposDir, dirName, generator, args);
                        BuildProject(builder, "yaml-cpp", "", reposDir, dirName, generator, $"-DYAML_CPP_BUILD_TESTS=OFF -DYAML_CPP_BUILD_CONTRIB=OFF -DYAML_CPP_BUILD_TOOLS=OFF " + args);
                        BuildProject(builder, "nanovg", "", reposDir, dirName, generator, args);
                    }
                }

                // macOS
                if (BuildEnvironment.IsMacOSTarget)
                {
                    var targetArgs = new[]
                    {
                        //new { DirName = "macOS", Config = "Debug",Args = "" },
                        new { DirName = "macOS", Config = "", Args = "" },
                    };

                    foreach (var t in targetArgs)
                    {
                        var dirName        = t.DirName;
                        var args           = t.Args;
                        var zlibInstallDir = Utils.ToUnixPath(Path.Combine(builder.LuminoBuildDir, dirName, "ExternalInstall", "zlib"));
                        var pngIncludeDir  = Utils.ToUnixPath(Path.Combine(builder.LuminoBuildDir, dirName, "ExternalInstall", "libpng", "include"));
                        var oggInstallDir  = Utils.ToUnixPath(Path.Combine(builder.LuminoBuildDir, dirName, "ExternalInstall", "ogg"));

                        var generator = "Xcode";
                        BuildProject(builder, "zlib", t.Config, reposDir, dirName, generator, args);
                        BuildProject(builder, "libpng", t.Config, reposDir, dirName, generator, $"-DZLIB_INCLUDE_DIR={zlibInstallDir}/include " + args);
                        BuildProject(builder, "glslang", t.Config, reposDir, dirName, generator, args);
                        BuildProject(builder, "SPIRV-Cross", t.Config, reposDir, dirName, generator, args);
                        BuildProject(builder, "glfw", t.Config, reposDir, dirName, generator, $"-DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_DOCS=OFF -DGLFW_INSTALL=ON");
                        BuildProject(builder, "glad", t.Config, reposDir, dirName, generator, $"-DGLAD_INSTALL=ON " + args);
                        BuildProject(builder, "freetype2", t.Config, reposDir, dirName, generator, $"-DWITH_ZLIB=OFF -DWITH_BZip2=OFF  -DWITH_PNG=OFF -DWITH_HarfBuzz=OFF -DPNG_FOUND=ON -DPNG_INCLUDE_DIRS={pngIncludeDir} " + args);
                        BuildProject(builder, "ogg", t.Config, reposDir, dirName, generator, args);
                        BuildProject(builder, "vorbis", t.Config, reposDir, dirName, generator, $"-DOGG_ROOT={oggInstallDir} " + args);
                        BuildProject(builder, "bullet3", t.Config, reposDir, dirName, generator, $"{bulletOptions} " + args);
                        BuildProject(builder, "pcre", t.Config, reposDir, dirName, generator, $"-DPCRE2_BUILD_PCRE2_8=OFF -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=OFF " + args);
                        BuildProject(builder, "tmxlite/tmxlite", t.Config, reposDir, dirName, generator, $"-DTMXLITE_STATIC_LIB=ON " + args);
                        BuildProject(builder, "Box2D/Box2D", t.Config, reposDir, dirName, generator, $"-DBOX2D_BUILD_EXAMPLES=OFF -DBOX2D_INSTALL_DOC=OFF -DBOX2D_BUILD_SHARED=OFF -DBOX2D_BUILD_STATIC=ON -DBOX2D_INSTALL=ON " + args);
                        BuildProject(builder, "Vulkan-Headers", t.Config, reposDir, dirName, generator, args);
                        BuildProject(builder, "yaml-cpp", t.Config, reposDir, dirName, generator, $"-DYAML_CPP_BUILD_TESTS=OFF -DYAML_CPP_BUILD_CONTRIB=OFF -DYAML_CPP_BUILD_TOOLS=OFF " + args);
                        BuildProject(builder, "nanovg", t.Config, reposDir, dirName, generator, args);
                    }
                }
            }

            if (BuildEnvironment.FromCI)
            {
                // CI 環境でディスク消費を抑えるため、一時ファイルを削除する
                var buildDir = builder.GetExternalProjectBuildDir(BuildEnvironment.Target);
                Utils.DeleteDirectory(buildDir);
            }

            builder.CommitCache(builder.GetExternalInstallDir(BuildEnvironment.Target));
        }
Exemplo n.º 6
0
        public override void Build(Builder builder)
        {
            string destinationRootDir = Path.Combine(builder.LuminoBuildDir, builder.LocalPackageName);
            string destinationToolDir = Path.Combine(destinationRootDir, "Tools");

            Directory.CreateDirectory(destinationRootDir);
            Directory.CreateDirectory(destinationToolDir);

            foreach (var target in BuildEnvironment.Targets.Where(x => x.Package))
            {
                string sourceBuildDir = Path.Combine(builder.LuminoBuildDir, target.Name);
                if (Directory.Exists(sourceBuildDir))
                {
                    Console.WriteLine($"{target.Name}...");

                    string destinationEngineRoot       = Path.Combine(destinationRootDir, "Engine", target.Name);
                    string destinationEngineIncludeDir = Path.Combine(destinationEngineRoot, "include");
                    string destinationEngineLibDir     = Path.Combine(destinationEngineRoot, "lib");
                    string destinationEngineBinDir     = Path.Combine(destinationEngineRoot, "bin");
                    Directory.CreateDirectory(destinationEngineRoot);
                    Directory.CreateDirectory(destinationEngineIncludeDir);
                    Directory.CreateDirectory(destinationEngineLibDir);

                    string engineInstallDir = Path.Combine(builder.LuminoBuildDir, target.Name, BuildEnvironment.EngineInstallDirName);

                    // Engine include
                    {
                        Utils.CopyDirectory(
                            Path.Combine(engineInstallDir, "include"),
                            Path.Combine(destinationEngineIncludeDir));
                    }

                    // Engine lib
                    {
                        var srcDir = Path.Combine(engineInstallDir, "lib");
                        Utils.CopyDirectory(srcDir, destinationEngineLibDir, recursive: false);
                        if (fileMoving)
                        {
                            Directory.Delete(srcDir, true); // FIXME: CI サーバのストレージ不足対策
                        }
                    }

                    // Engine bin
                    {
                        var srcDir = Path.Combine(engineInstallDir, "bin");
                        if (Directory.Exists(srcDir))
                        {
                            Utils.CopyDirectory(srcDir, destinationEngineBinDir, recursive: false);
                            if (fileMoving)
                            {
                                Directory.Delete(srcDir, true); // FIXME: CI サーバのストレージ不足対策
                            }
                        }
                    }

                    // External libs
                    var externalInstallDir = Path.Combine(builder.LuminoBuildDir, target.Name, "ExternalInstall");
                    foreach (var dir in Directory.EnumerateDirectories(externalInstallDir))
                    {
                        var srcDir = Path.Combine(dir, "lib");
                        if (Directory.Exists(srcDir))   // copy if directory exists. openal-soft etc are optional.
                        {
                            Console.WriteLine($"Copy {srcDir} to {destinationEngineLibDir}");

                            foreach (var lib in Directory.EnumerateFiles(srcDir, target.LibraryExt, SearchOption.TopDirectoryOnly))
                            {
                                if (fileMoving)
                                {
                                    File.Move(lib, Path.Combine(destinationEngineLibDir, Path.GetFileName(lib)));
                                }
                                else
                                {
                                    File.Copy(lib, Path.Combine(destinationEngineLibDir, Path.GetFileName(lib)), true);
                                }
                            }
                        }
                    }

                    // cmake
                    {
                        Utils.CopyFile2(
                            Path.Combine(builder.LuminoRootDir, "src", "LuminoConfig.cmake"),
                            Path.Combine(destinationEngineRoot, "LuminoConfig.cmake"));
                        Utils.CopyFile2(
                            Path.Combine(builder.LuminoRootDir, "src", "LuminoCommon.cmake"),
                            Path.Combine(destinationEngineRoot, "LuminoCommon.cmake"));
                        Utils.CopyFile2(
                            Path.Combine(builder.LuminoRootDir, "external", "ImportExternalLibraries.cmake"),
                            Path.Combine(destinationEngineRoot, "ImportExternalLibraries.cmake"));
                    }
                }
            }

            // Tools
            {
                Console.WriteLine($"Copy tools...");

                if (Utils.IsWin32)
                {
                    var engineInstallDir = Path.Combine(builder.LuminoBuildDir, "MSVC2019-x64-MT", BuildEnvironment.EngineInstallDirName);
                    var sourceBinDir     = Path.Combine(engineInstallDir, "bin");
                    if (Directory.Exists(sourceBinDir))
                    {
                        Utils.CopyDirectory(sourceBinDir, destinationToolDir, pattern: "*.exe");

                        Utils.DownloadFile(BuildEnvironment.VSWhereUrl, Path.Combine(destinationToolDir, "vswhere.exe"));
                    }
                }
                else if (Utils.IsMac)
                {
                    var engineInstallDir = Path.Combine(builder.LuminoBuildDir, "macOS", BuildEnvironment.EngineInstallDirName);
                    var sourceBinDir     = Path.Combine(engineInstallDir, "bin");

                    if (Directory.Exists(sourceBinDir))
                    {
                        Utils.CopyDirectory(sourceBinDir, destinationToolDir);

                        var setupFile = Path.Combine(destinationToolDir, "setup.sh");
                        File.Copy(Path.Combine(builder.LuminoRootDir, "Tools", "PackageSource", "macOS", "setup.sh"), setupFile, true);
                        Utils.chmod(setupFile, Utils.S_0755);
                    }
                }

                // Templates
                {
                    Utils.CopyDirectory(
                        Path.Combine(builder.LuminoToolsDir, "ProjectTemplates"),
                        Path.Combine(destinationToolDir, "ProjectTemplates"));
                }
            }

            // Docs
            {
                Console.WriteLine($"Copy docs...");
                GenerateReadme(builder, destinationRootDir);
            }

            // Engine assets
            {
                var reposDir = Path.Combine(builder.LuminoBuildDir, "ExternalSource");
                using (var cd = CurrentDir.Enter(reposDir))
                {
                    if (!Directory.Exists("noto-emoji"))
                    {
                        Utils.CallProcess("git", "clone --depth 1 -b v2019-11-19-unicode12 https://github.com/googlefonts/noto-emoji.git noto-emoji");
                        File.Copy("noto-emoji/fonts/NotoColorEmoji.ttf", Path.Combine(builder.LuminoToolsDir, "EngineResources", "NotoColorEmoji.ttf"), true);
                    }
                }

                Utils.CopyDirectory(
                    Path.Combine(builder.LuminoToolsDir, "EngineResources"),
                    Path.Combine(destinationToolDir, "EngineResources"));
            }
        }
Exemplo n.º 7
0
        public override void Build(Build b)
        {
            string lockFile = $"{b.Triplet}.lock";

            using (CurrentDir.Enter(b.BuildToolsDir))
            {
                if (File.Exists(lockFile))
                {
                    return;
                }

                if (!Directory.Exists(b.VcpkgDir))
                {
                    Proc.Make("git", "clone -b 2021.05.12 https://github.com/microsoft/vcpkg.git").WithSilent().Call();
                }

                using (CurrentDir.Enter(b.VcpkgDir))
                {
                    if (!File.Exists("vcpkg.exe") && !File.Exists("vcpkg"))
                    {
                        Proc.Make("bootstrap-vcpkg").WithShell().WithSilent().Call();
                    }

                    if (b.IsDesktopSystem)
                    {
                        Proc.Make("vcpkg", "install gtest:" + b.Triplet).WithSilent().Call();
                    }

                    Proc.Make("vcpkg", "install fmt:" + b.Triplet).WithSilent().Call();
                    Proc.Make("vcpkg", "install yaml-cpp:" + b.Triplet).WithSilent().Call();
                    Proc.Make("vcpkg", "install toml11:" + b.Triplet).WithSilent().Call();

                    Proc.Make("vcpkg", "install zlib:" + b.Triplet).WithSilent().Call();
                    Proc.Make("vcpkg", "install libpng:" + b.Triplet).WithSilent().Call();
                    Proc.Make("vcpkg", "install freetype[core,png,zlib]:" + b.Triplet).WithSilent().Call();    // emsdk では brotli がビルドエラーになるため機能を制限する
                    Proc.Make("vcpkg", "install libvorbis:" + b.Triplet).WithSilent().Call();
                    Proc.Make("vcpkg", "install pcre2:" + b.Triplet).WithSilent().Call();

                    Proc.Make("vcpkg", "install box2d:" + b.Triplet).WithSilent().Call();
                    Proc.Make("vcpkg", "install bullet3:" + b.Triplet).WithSilent().Call();

                    Proc.Make("vcpkg", "install nanovg:" + b.Triplet).WithSilent().Call();
                    Proc.Make("vcpkg", "install stb:" + b.Triplet).WithSilent().Call();
                    Proc.Make("vcpkg", "install tinyobjloader:" + b.Triplet).WithSilent().Call();
                    Proc.Make("vcpkg", "install tinygltf:" + b.Triplet).WithSilent().Call();
                    Proc.Make("vcpkg", "install imgui[docking-experimental]:" + b.Triplet).WithSilent().Call();

                    if (b.IsDesktopSystem)
                    {
                        Proc.Make("vcpkg", "install glfw3:" + b.Triplet).WithSilent().Call();
                        Proc.Make("vcpkg", "install vulkan-headers:" + b.Triplet).WithSilent().Call();
                        Proc.Make("vcpkg", "install glad:" + b.Triplet).WithSilent().Call();
                        Proc.Make("vcpkg", "install glslang:" + b.Triplet).WithSilent().Call();
                        Proc.Make("vcpkg", "install spirv-cross:" + b.Triplet).WithSilent().Call();
                        Proc.Make("vcpkg", "install gtest:" + b.Triplet).WithSilent().Call();
                        Proc.Make("vcpkg", "install openal-soft:" + b.Triplet).WithSilent().Call();
                    }

                    if (BuildEnvironment.FromCI)
                    {
                        // Free disk space
                        // https://github.com/Microsoft/vcpkg/issues/2352
                        Directory.Delete("downloads", true);
                        Directory.Delete("buildtrees", true);
                    }
                }

                File.WriteAllText(lockFile, "The presence of this file indicates that the dependency is ready to be placed by LuminoBuild.");
            }
        }