//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"); } } }
private void DataReceived(object sender, DataReceivedEventArgs dataReceivedEventArgs) { var stdout = dataReceivedEventArgs.Data; if (stdout == null) { return; } var regex = new Regex(@"(?<currentdir>[a-zA-Z]:\\[^>]*)(>$)", RegexOptions.Multiline); var match = regex.Match(stdout); if (match.Success) { CurrentDir = match.Groups["currentdir"].ToString(); if (CurrentDir.Contains(HomeDir)) { stdout = "[" + CurrentDir.Replace(HomeDir, "~") + "] " + "(な・ω・ゆ)" + " $ "; } else { stdout = "[" + CurrentDir + "] " + "(な・ω・ゆ)" + " $ "; } } BackBuffer += stdout.Replace(CurrentDir + ">", "") + "\r\n"; }
private void LoadItems() { if (_showFiles) { var itemList = new List <FileSystemInfo>(); itemList.AddRange(CurrentDir.GetDirectories().OrderBy(d => d.Name).ToArray()); itemList.AddRange(CurrentDir.GetFiles().OrderBy(f => f.Name).ToArray()); lsbItems.Items = itemList; } else { var itemList = new List <FileSystemInfo>(); itemList.AddRange(CurrentDir.GetDirectories().OrderBy(d => d.Name).ToArray()); lsbItems.Items = itemList; } }
void ParseFromFile(string fileName) { // Check if file exists if (!(new FileInfo(fileName)).Exists) { throw new UsageException("argfile", fileName + " not found"); } // Point current directory at the input file string argDir = Path.GetDirectoryName(Path.GetFullPath(fileName)); using (CurrentDir cd = new CurrentDir(argDir)) using (StreamReader reader = new StreamReader(fileName)) { Parse(reader.ReadToEnd()); } }
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()); } } }
/// <summary> /// Extracts the archive resource to a temporary location. /// </summary> /// <param name="archiveName"></param> /// <returns>Directory in which the files are extracted to</returns> public DirectoryInfo ExtractArchive(string archiveName) { if (TemporaryDirectory == null) { TemporaryDirectory = CurrentDir.CreateSubdirectory("temp"); } var archiveStream = GetArchiveResourceStream(archiveName); var archive = new FileInfo(Path.Combine(TemporaryDirectory.FullName, archiveName)); archiveStream.WriteBytesToFile(archive); TemporaryFiles.Add(archive); archive.Extract(TemporaryDirectory); TemporaryFiles.AddRange(TemporaryDirectory.GetFiles()); return(TemporaryDirectory); }
//TODO: This is slow, use Win32 function calls instead of DirectoryInfo internal IEnumerable <ListViewItem> GetAllFiles() { IEnumerable <ListViewItem> items = CurrentDir.EnumerateFileSystemInfos().Select(info => { ListViewItem item = null; bool isDirectory = false; if (info is FileInfo file) { item = GetFileItem(file); } else if (info is DirectoryInfo dir) { item = GetDirItem(dir); isDirectory = true; } return(new { isDirectory, item }); }).OrderByDescending(arg => arg.isDirectory).Select(arg => arg.item); return(items); }
public void ContentTypeTest() { //....\\FtpServerTest\\TestDir var startup = Directory.GetCurrentDirectory(); var path1 = Path.GetDirectoryName(startup); var path2 = Path.GetDirectoryName(path1); var dir = Path.GetDirectoryName(path2); //dir = c:\tmp2\bjd5 //var dir = new File(".").getAbsoluteFile().getParentFile().getParent(); //c:\dev\bjd6 var workDir = dir + "\\work"; var rootDirectory = workDir + "\\FtpTestDir"; var listMount = new ListMount(null); //var op = new Option(kernel, "", "Ftp"); var homeDir = string.Format("{0}\\home0", rootDirectory); //ディレクトリ変更 と表示テキスト var currentDir = new CurrentDir(homeDir, listMount); //初期化 Assert.That(currentDir.Cwd("home0-sub0"), Is.EqualTo(true)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/home0-sub0")); currentDir = new CurrentDir(homeDir, listMount); //初期化 Assert.That(currentDir.Cwd("home0-sub0/sub0-sub0"), Is.EqualTo(true)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/home0-sub0/sub0-sub0")); currentDir = new CurrentDir(homeDir, listMount); //初期化 Assert.That(currentDir.Cwd("home0-sub0/sub0-sub0"), Is.EqualTo(true)); Assert.That(currentDir.Cwd(".."), Is.EqualTo(true)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/home0-sub0")); //ホームディレクトリより階層上へは移動できない currentDir = new CurrentDir(homeDir, listMount); //初期化 Assert.That(currentDir.Cwd("home0-sub0/sub0-sub0"), Is.EqualTo(true)); Assert.That(currentDir.Cwd(".."), Is.EqualTo(true)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/home0-sub0")); Assert.That(currentDir.Cwd(".."), Is.EqualTo(true)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/")); Assert.That(currentDir.Cwd(".."), Is.EqualTo(false)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/")); //存在しないディレクトリへの変更 currentDir = new CurrentDir(homeDir, listMount); Assert.That(currentDir.Cwd("home0-sub0/sub0"), Is.EqualTo(false)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/")); //初期化文字列の対応 currentDir = new CurrentDir(homeDir + "\\", listMount); Assert.That(currentDir.Cwd("home0-sub0"), Is.EqualTo(true)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/home0-sub0")); //ファイル一覧の取得 currentDir = new CurrentDir(homeDir, listMount); var ar = new List <string> { "d home0-sub0", "d home0-sub1", "d home0-sub2", "- home0-1.txt", "- home0-2.txt", "- home0-3.txt" }; Assert.That(confirm(currentDir, "*.*", ar), Is.EqualTo(true)); //ファイル一覧の取得 currentDir = new CurrentDir(homeDir, listMount); Assert.That(currentDir.Cwd("home0-sub0"), Is.EqualTo(true)); ar.Clear(); ar.Add("- home0-sub0-1.txt"); ar.Add("- home0-sub0-2.txt"); ar.Add("- home0-sub0-3.txt"); Assert.That(confirm(currentDir, "*.txt", ar), Is.EqualTo(true)); //************************************************** //仮想フォルダを追加して試験する //************************************************** var fromFolder = string.Format("{0}\\home2", rootDirectory); var toFolder = string.Format("{0}\\home0", rootDirectory); listMount.Add(fromFolder, toFolder); //ファイル一覧の取得 currentDir = new CurrentDir(homeDir, listMount); ar.Clear(); ar.Add("d home0-sub0"); ar.Add("d home0-sub1"); ar.Add("d home0-sub2"); ar.Add("d home2"); ar.Add("- home0-1.txt"); ar.Add("- home0-2.txt"); ar.Add("- home0-3.txt"); Assert.That(confirm(currentDir, "*.*", ar), Is.EqualTo(true)); Assert.That(currentDir.Cwd("home2"), Is.EqualTo(true)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/home2")); Assert.That(currentDir.Cwd("home2-sub0"), Is.EqualTo(true)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/home2/home2-sub0")); Assert.That(currentDir.Cwd(".."), Is.EqualTo(true)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/home2")); Assert.That(currentDir.Cwd(".."), Is.EqualTo(true)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/")); Assert.That(currentDir.Cwd("home2/home2-sub0"), Is.EqualTo(true)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/home2/home2-sub0")); Assert.That(currentDir.Cwd("../../.."), Is.EqualTo(false)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/home2/home2-sub0")); Assert.That(currentDir.Cwd("../.."), Is.EqualTo(true)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/")); //************************************************** ////仮想フォルダを追加して試験する //************************************************** fromFolder = workDir + "\\FtpTestDir2\\tmp"; toFolder = string.Format("{0}\\home0", rootDirectory); listMount.Add(fromFolder, toFolder); //ファイル一覧の取得 currentDir = new CurrentDir(homeDir, listMount); ar.Clear(); ar.Add("d home0-sub0"); ar.Add("d home0-sub1"); ar.Add("d home0-sub2"); ar.Add("d home2"); ar.Add("d tmp"); ar.Add("- home0-1.txt"); ar.Add("- home0-2.txt"); ar.Add("- home0-3.txt"); Assert.That(confirm(currentDir, "*.*", ar), Is.EqualTo(true)); Assert.That(currentDir.Cwd("tmp"), Is.EqualTo(true)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/tmp")); Assert.That(currentDir.Cwd("sub"), Is.EqualTo(true)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/tmp/sub")); Assert.That(currentDir.Cwd(".."), Is.EqualTo(true)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/tmp")); Assert.That(currentDir.Cwd(".."), Is.EqualTo(true)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/")); Assert.That(currentDir.Cwd("tmp/sub"), Is.EqualTo(true)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/tmp/sub")); Assert.That(currentDir.Cwd("../../.."), Is.EqualTo(false)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/tmp/sub")); Assert.That(currentDir.Cwd("../.."), Is.EqualTo(true)); Assert.That(currentDir.GetPwd(), Is.EqualTo("/")); }
//CurrentDir.List()の確認用メソッド private bool confirm(CurrentDir currentDir, string mask, List <string> list) { //widwMode=trueで試験を実施する var wideMode = true; //一覧取得 var ar = currentDir.List(mask, wideMode); //件数確認 if (ar.Count != list.Count) { return(false); } //確認用テンポラリ文字列を生成する //var tmp = ar.Select(l => l.Split(' ')).Select(a => a[0][0] + " " + a[8]).ToList(); var tmp = new List <string>(); foreach (var s in ar) { var t = s.Split(' '); var l = string.Format("{0} {1}", t[0][0], t[8]); tmp.Add(l); } //指定リストに該当したテンポラリ行を削除していく foreach (var l in list) { var index = tmp.IndexOf(l); if (index < 0) { return(false); } tmp.RemoveAt(index); } //テンポラリが0行になったら成功 if (tmp.Count != 0) { return(false); } //widwMode=falseでもう一度同じ要領で試験を実施する wideMode = false; //一覧取得 tmp = currentDir.List(mask, wideMode); //件数確認 if (tmp.Count != list.Count) { return(false); } //指定レストに該当したテンポラリ行を削除していく foreach (var l in list) { var index = tmp.IndexOf(l.Substring(2)); if (index < 0) { return(false); } tmp.RemoveAt(index); } //テンポラリが0行になったら成功 if (tmp.Count != 0) { return(false); } return(true); }
/** * Update is called once per frame * Builds list of Swipes */ void Update() { if (Application.platform == RuntimePlatform.Android) { if (UnityEngine.Input.acceleration.x > accelerationThreshold || UnityEngine.Input.acceleration.y > accelerationThreshold || UnityEngine.Input.acceleration.z > accelerationThreshold) { inputMap.FireInputEvents(MultiPlatformInputs.Shake); } if (Input.touchCount > 0) { Touch touch = Input.touches [0]; switch (touch.phase) { //Clears all data when swipe begins case TouchPhase.Began: directionList.Clear(); currentDist = 0; break; //Builds list of directions swiped case TouchPhase.Moved: //Right swiping if (Math.Abs(touch.deltaPosition.x) > Math.Abs(touch.deltaPosition.y) && touch.deltaPosition.x > 0) { if (currentDir != CurrentDir.right) { if (currentDist > minSwipeDist) { directionList.Add(currentDir); } currentDir = CurrentDir.right; currentDist = 0; } currentDist += touch.deltaPosition.x; } //Up swiping if (Math.Abs(touch.deltaPosition.y) > Math.Abs(touch.deltaPosition.x) && touch.deltaPosition.y > 0) { if (currentDir != CurrentDir.up) { if (currentDist > minSwipeDist) { directionList.Add(currentDir); } currentDir = CurrentDir.up; currentDist = 0; } currentDist += touch.deltaPosition.y; } //Left swiping if (Math.Abs(touch.deltaPosition.x) > Math.Abs(touch.deltaPosition.y) && touch.deltaPosition.x < 0) { if (currentDir != CurrentDir.left) { if (currentDist > minSwipeDist) { directionList.Add(currentDir); } currentDir = CurrentDir.left; currentDist = 0; } currentDist += -touch.deltaPosition.x; } //Down swiping if (Math.Abs(touch.deltaPosition.y) > Math.Abs(touch.deltaPosition.x) && touch.deltaPosition.y < 0) { if (currentDir != CurrentDir.down) { if (currentDist > minSwipeDist) { directionList.Add(currentDir); } currentDir = CurrentDir.down; currentDist = 0; } currentDist += -touch.deltaPosition.y; } break; case TouchPhase.Ended: //Adds the last direction swiped to the list if (currentDist > minSwipeDist) { directionList.Add(currentDir); } this.FireSwipeEvents(); break; } } } }
private bool Shell(bool superuser) { while (true) { string currentCommand = ""; Console.Write(AliasCurrentDir + prompt); string[] tokens = Console.ReadLine().Split(' '); currentCommand = tokens[0]; commandsChoice selectedCommand = commandsChoice.error; if (CommandCheck(tokens, currentCommand, ref selectedCommand, superuser) == false) { continue; } else { switch (selectedCommand) { case commandsChoice.logout: { return(false); } case commandsChoice.exit: { return(true); } case commandsChoice.clear: { Console.Clear(); break; //or continue } case commandsChoice.where: { Console.WriteLine(CurrentDir); break; } case commandsChoice.addUser: { UserDatabase db = new UserDatabase(@"C:\Users\Aleksa\source\repos\OOSWinSimpleShell\OOSWinSimpleShell\Users.db"); if (db.GetUser(tokens[1]) != null) { Console.WriteLine("Username '{0}' already exists.", tokens[1]); break; } Console.Write("Password:"******"C:\Users\Aleksa\source\repos\OOSWinSimpleShell\OOSWinSimpleShell\Users.db"); if (db.GetUser(tokens[1]) == null) { Console.WriteLine("User '{0}' doesn't exist.", tokens[1]); break; } Console.Write("sudo password: "******"root").IsPasswordValid(PasswordEnter())) { db.RemoveUser(tokens[1]); } else { Console.WriteLine("\nWrong sudo password."); } Console.WriteLine(); break; } case commandsChoice.go: { if (tokens[1].Equals("..")) { if (AliasCurrentDir == CurrentDir && CurrentDir.Contains("\\")) { AliasCurrentDir = CurrentDir = CurrentDir.Substring(0, CurrentDir.LastIndexOf("\\")); } else if (CurrentDir.Contains("\\")) { CurrentDir = CurrentDir.Substring(0, CurrentDir.LastIndexOf("\\")); } } else { tokens[1] = tokens[1].Trim(); if ((Directory.Exists(tokens[1]) && tokens[1].Contains("\\")) || Directory.Exists(CurrentDir + "\\" + tokens[1])) { if (AliasCurrentDir == CurrentDir && tokens[1].Contains("\\") && Directory.Exists(CurrentDir + "\\" + tokens[1])) { AliasCurrentDir = CurrentDir += "\\" + tokens[1]; } else if (AliasCurrentDir != CurrentDir && tokens[1].Contains("\\") && Directory.Exists(CurrentDir + "\\" + tokens[1])) { CurrentDir += "\\" + tokens[1]; } else if (AliasCurrentDir == CurrentDir && Directory.Exists(CurrentDir + "\\" + tokens[1])) { AliasCurrentDir = CurrentDir += "\\" + tokens[1]; } else if (AliasCurrentDir != CurrentDir && Directory.Exists(CurrentDir + "\\" + tokens[1])) { CurrentDir += "\\" + tokens[1]; } else if (AliasCurrentDir == CurrentDir && !Directory.Exists(CurrentDir + "\\" + tokens[1])) { AliasCurrentDir = CurrentDir = tokens[1]; } else { CurrentDir = tokens[1]; } } else { Console.WriteLine("Path is not valid."); } } break; } case commandsChoice.alias: { if (tokens.Length == 2) { AliasCurrentDir = tokens[1]; } else { AliasCurrentDir = CurrentDir; } break; } case commandsChoice.create: { string fileName = null; string path = null; SetFileNameAndPath(ref tokens, ref path, ref fileName); // help method Mkdir(fileName, path, tokens); break; } case commandsChoice.list: { if (tokens.Length == 2) { tokens[1] = tokens[1].Trim(); if (Directory.Exists(tokens[1])) { DirectorySearch(tokens[1], "\t"); } else { Console.WriteLine("Path is not valid."); } } else { DirectorySearch(CurrentDir, "\t"); } break; } case commandsChoice.findDat: { tokens[2] = tokens[2].Trim(); if (Directory.Exists(tokens[2])) { FindFile(tokens[2], tokens[1]); } else { Console.WriteLine("Path is not valid."); } break; } case commandsChoice.print: { if (File.Exists(CurrentDir + "\\" + tokens[1])) { string extension = Path.GetExtension(tokens[1]); if (extension == String.Empty) { Console.WriteLine("File {0} doesn't have extension information.", CurrentDir); } else if (extension.Contains(".")) { extension = extension.TrimStart('.'); if (extension.Equals("txt")) { Console.Write(File.ReadAllText(CurrentDir + "\\" + tokens[1])); } else { Console.WriteLine("File '{0}' is not a text file.", CurrentDir + tokens[1]); } } else { Console.WriteLine("File doesn't have an extension."); } } else { Console.WriteLine("File '{0}' doesn't exist in path {1}.", tokens[1], CurrentDir); } break; } case commandsChoice.find: { if (tokens[1].StartsWith("\"") && tokens[1].EndsWith("\"") && tokens[1].Length > 2) { if (File.Exists(CurrentDir + "\\" + tokens[2])) { tokens[1] = tokens[1].Substring(1, tokens[1].Length - 2); var lines = File.ReadLines(CurrentDir + "\\" + tokens[2]); int lineNmb = 1; foreach (var line in lines) { if (line.Contains(tokens[1])) { Console.Write(lineNmb + ":"); Console.Write(line.Substring(0, line.IndexOf(tokens[1]))); Console.ForegroundColor = ConsoleColor.Red; Console.Write(tokens[1]); Console.ResetColor(); Console.WriteLine(line.Substring(line.IndexOf(tokens[1]) + tokens[1].Length)); break; } lineNmb++; } } else { Console.WriteLine("File '{0}' doesn't exist in path {1}.", tokens[2], CurrentDir); } } else { Console.WriteLine("Text option doesn't have the correct signature."); } break; } } } } }
internal static string GetRelativePath(string relativeTo, string path, StringComparison comparisonType) { if (relativeTo == null) { throw new ArgumentNullException(nameof(relativeTo)); } if (PathInternal.IsEffectivelyEmpty(relativeTo.AsSpan())) { throw new ArgumentException(nameof(relativeTo)); } if (path == null) { throw new ArgumentNullException(nameof(path)); } if (PathInternal.IsEffectivelyEmpty(path.AsSpan())) { throw new ArgumentException(nameof(path)); } Debug.Assert(comparisonType == StringComparison.Ordinal || comparisonType == StringComparison.OrdinalIgnoreCase); relativeTo = Path.GetFullPath(relativeTo); path = Path.GetFullPath(path); // Need to check if the roots are different- if they are we need to return the "to" path. if (!PathInternal.AreRootsEqual(relativeTo, path, comparisonType)) { return(path); } int commonLength = PathInternal.GetCommonPathLength(relativeTo, path, ignoreCase: comparisonType == StringComparison.OrdinalIgnoreCase); // If there is nothing in common they can't share the same root, return the "to" path as is. if (commonLength == 0) { return(path); } // Trailing separators aren't significant for comparison int relativeToLength = relativeTo.Length; if (DoesEndInDirectorySeparator(relativeTo.AsSpan())) { relativeToLength--; } bool pathEndsInSeparator = DoesEndInDirectorySeparator(path.AsSpan()); int pathLength = path.Length; if (pathEndsInSeparator) { pathLength--; } // If we have effectively the same path, return "." if (relativeToLength == pathLength && commonLength >= relativeToLength) { return(CurrentDir.ToString()); } // We have the same root, we need to calculate the difference now using the // common Length and Segment count past the length. // // Some examples: // // C:\Foo C:\Bar L3, S1 -> ..\Bar // C:\Foo C:\Foo\Bar L6, S0 -> Bar // C:\Foo\Bar C:\Bar\Bar L3, S2 -> ..\..\Bar\Bar // C:\Foo\Foo C:\Foo\Bar L7, S1 -> ..\Bar var sb = new StringBuilder(); // Add parent segments for segments past the common on the "from" path if (commonLength < relativeToLength) { sb.Append(ParentDir); for (int i = commonLength + 1; i < relativeToLength; i++) { if (PathInternal.IsDirectorySeparator(relativeTo[i])) { sb.Append(Path.DirectorySeparatorChar); sb.Append(ParentDir); } } } else if (PathInternal.IsDirectorySeparator(path[commonLength])) { // No parent segments and we need to eat the initial separator // (C:\Foo C:\Foo\Bar case) commonLength++; } // Now add the rest of the "to" path, adding back the trailing separator int differenceLength = pathLength - commonLength; if (pathEndsInSeparator) { differenceLength++; } if (differenceLength > 0) { if (sb.Length > 0) { sb.Append(Path.DirectorySeparatorChar); } sb.Append(path, commonLength, differenceLength); } return(sb.ToString()); }
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)); }
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")); } }
private static void ClearLog(string[] args) { string[] hosts = Utils.GetQizmtHosts(); if (hosts.Length == 0) { Console.Error.WriteLine("No Qizmt host is found."); return; } const int MAX_TRIES = 10; List <string> errs = new List <string>(hosts.Length); string logpath = CurrentDir.Replace(':', '$') + @"\errors.txt"; RDBMS_Admin.ThreadTools <string> .Parallel( new Action <string>( delegate(string host) { int triesremain = MAX_TRIES; string fn = @"\\" + host + @"\" + logpath; for (; ;) { try { System.IO.File.Delete(fn); lock (hosts) { Console.Write('.'); } return; } catch (Exception e) { if (--triesremain <= 0) { lock (hosts) { errs.Add(host); } break; } } } } ), hosts, hosts.Length); Console.WriteLine(); if (errs.Count > 0) { Console.WriteLine("Errors encountered while trying to clear logs from these machines:"); foreach (string e in errs) { Console.WriteLine(e); } } else { Console.WriteLine("Done"); } }
/** * Update is called once per frame * Builds list of Swipes */ void Update () { if (Application.platform == RuntimePlatform.Android) { if(UnityEngine.Input.acceleration.x > accelerationThreshold || UnityEngine.Input.acceleration.y > accelerationThreshold || UnityEngine.Input.acceleration.z > accelerationThreshold) { inputMap.FireInputEvents(MultiPlatformInputs.Shake); } if (Input.touchCount > 0) { Touch touch = Input.touches [0]; switch (touch.phase) { //Clears all data when swipe begins case TouchPhase.Began: directionList.Clear(); currentDist = 0; break; //Builds list of directions swiped case TouchPhase.Moved: //Right swiping if(Math.Abs(touch.deltaPosition.x) > Math.Abs(touch.deltaPosition.y) && touch.deltaPosition.x > 0) { if(currentDir != CurrentDir.right) { if (currentDist > minSwipeDist) { directionList.Add(currentDir); } currentDir = CurrentDir.right; currentDist = 0; } currentDist += touch.deltaPosition.x; } //Up swiping if(Math.Abs(touch.deltaPosition.y) > Math.Abs(touch.deltaPosition.x) && touch.deltaPosition.y > 0) { if(currentDir != CurrentDir.up) { if (currentDist > minSwipeDist) { directionList.Add(currentDir); } currentDir = CurrentDir.up; currentDist = 0; } currentDist += touch.deltaPosition.y; } //Left swiping if(Math.Abs(touch.deltaPosition.x) > Math.Abs(touch.deltaPosition.y) && touch.deltaPosition.x < 0) { if(currentDir != CurrentDir.left) { if (currentDist > minSwipeDist) { directionList.Add(currentDir); } currentDir = CurrentDir.left; currentDist = 0; } currentDist += -touch.deltaPosition.x; } //Down swiping if(Math.Abs(touch.deltaPosition.y) > Math.Abs(touch.deltaPosition.x) && touch.deltaPosition.y < 0) { if(currentDir != CurrentDir.down) { if (currentDist > minSwipeDist) { directionList.Add(currentDir); } currentDir = CurrentDir.down; currentDist = 0; } currentDist += -touch.deltaPosition.y; } break; case TouchPhase.Ended: //Adds the last direction swiped to the list if (currentDist > minSwipeDist) { directionList.Add(currentDir); } this.FireSwipeEvents(); break; } } } }
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."); } }
private static void ViewLog(string[] args) { int maxentries = 1000; string[] hosts = Utils.GetQizmtHosts(); if (hosts.Length == 0) { Console.Error.WriteLine("No Qizmt host is found."); return; } List <string> logpaths = new List <string>(); { string execpath = CurrentDir.Replace(':', '$'); foreach (string host in hosts) { logpaths.Add(@"\\" + host + @"\" + execpath + @"\errors.txt"); } } const int MAXBYTE = 1024 * 1024 * 64; int maxbytepart = MAXBYTE / logpaths.Count; int maxentriespart = maxentries / logpaths.Count; if (maxentries % logpaths.Count != 0) { maxentriespart++; } List <string[]> allentries = new List <string[]>(logpaths.Count); RDBMS_Admin.ThreadTools <string> .Parallel( new Action <string>( delegate(string logpath) { if (!System.IO.File.Exists(logpath)) { return; } string token = Environment.NewLine + Environment.NewLine + "["; System.IO.FileStream fs = null; try { fs = new System.IO.FileStream(logpath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite); if (fs.Length > maxbytepart * 2) { fs.Position = fs.Length - maxbytepart; } int ib = 0; List <long> idx = new List <long>(); long entryStart = 0; while ((ib = fs.ReadByte()) > -1) { if (ib == (int)token[0]) { bool istoken = true; for (int i = 1; i < token.Length; i++) { if (fs.ReadByte() != (int)token[i]) { istoken = false; break; } } if (istoken) { idx.Add(entryStart); entryStart = fs.Position - 1; } } } //get the last entryStart. if (idx.Count > 0) { if (entryStart != idx[idx.Count - 1]) { idx.Add(entryStart); } } else { //1 entry only. if (fs.Length > 0) { idx.Add(entryStart); } } if (idx.Count == 0) { return; } long flen = fs.Length; int startidx = idx.Count > maxentriespart ? idx.Count - maxentriespart : 0; long offset = idx[startidx]; long buflen = flen - offset; while (buflen > maxbytepart && startidx < idx.Count - 1) { startidx++; offset = idx[startidx]; buflen = flen - offset; } if (buflen > maxbytepart) { throw new Exception("log too large"); } byte[] buf = new byte[buflen]; fs.Position = offset; fs.Read(buf, 0, buf.Length); fs.Close(); fs = null; string[] entries = new string[idx.Count - startidx]; for (int i = startidx; i < idx.Count; i++) { int pos = (int)(idx[i] - offset); int bytecount = 0; if (i < idx.Count - 1) { bytecount = (int)(idx[i + 1] - offset - pos); } else { bytecount = buf.Length - pos; } entries[i - startidx] = System.Text.Encoding.ASCII.GetString(buf, pos, bytecount); } lock (allentries) { allentries.Add(entries); } } catch { if (fs != null) { fs.Close(); fs = null; } throw; } } ), logpaths, logpaths.Count); if (allentries.Count == 0) { Console.Error.WriteLine("No log entries found."); return; } Console.WriteLine("-"); Console.WriteLine("Log entries:"); Console.WriteLine("-"); if (allentries.Count == 1) { foreach (string entry in allentries[0]) { Console.Write(entry); Console.WriteLine("----------------------------------------------------------------"); } Console.WriteLine("-"); Console.WriteLine("Entries displayed: {0}", allentries[0].Length); Console.WriteLine("-"); } else { List <KeyValuePair <DateTime, string> > list = new List <KeyValuePair <DateTime, string> >(); foreach (string[] entries in allentries) { foreach (string entry in entries) { int del = entry.IndexOf('M'); //AM or PM string sdate = entry.Substring(1, del); try { DateTime dt = DateTime.Parse(sdate); list.Add(new KeyValuePair <DateTime, string>(dt, entry)); } catch { } } } list.Sort(delegate(KeyValuePair <DateTime, string> x, KeyValuePair <DateTime, string> y) { return(x.Key.CompareTo(y.Key)); }); int start = list.Count > maxentries ? list.Count - maxentries : 0; for (int i = start; i < list.Count; i++) { Console.Write(list[i].Value); Console.WriteLine("----------------------------------------------------------------"); } Console.WriteLine("-"); Console.WriteLine("Entries displayed: {0}", list.Count - start); Console.WriteLine("-"); } }
void ParseFromFile(string fileName) { // Check if file exists if( !(new FileInfo(fileName)).Exists ) { throw new UsageException("argfile", fileName + " not found"); } // Point current directory at the input file string argDir = Path.GetDirectoryName(Path.GetFullPath(fileName)); using( CurrentDir cd = new CurrentDir(argDir) ) using( StreamReader reader = new StreamReader(fileName) ) { Parse(reader.ReadToEnd()); } }
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. } }
private static void DeleteRIndexes(string[] args) { string[] hosts = Utils.GetQizmtHosts(); if (hosts.Length == 0) { Console.Error.WriteLine("No Qizmt host is found."); return; } const int MAX_TRIES = 10; Dictionary <string, StringBuilder> errs = new Dictionary <string, StringBuilder>(hosts.Length); string currentdir = CurrentDir.Replace(':', '$'); int threadcount = hosts.Length; if (threadcount > 15) { threadcount = 15; } RDBMS_Admin.ThreadTools <string> .Parallel( new Action <string>( delegate(string host) { int triesremain = MAX_TRIES; string root = @"\\" + host + @"\" + currentdir + @"\"; string[] indfiles = System.IO.Directory.GetFiles(root, "ind.*.ind"); foreach (string indfile in indfiles) { for (; ;) { try { System.IO.File.Delete(indfile); lock (hosts) { Console.Write('.'); } break; } catch (Exception e) { if (--triesremain <= 0) { lock (hosts) { if (!errs.ContainsKey(host)) { errs.Add(host, new StringBuilder(1024)); } StringBuilder sb = errs[host]; sb.Append(Environment.NewLine).Append("File: "). Append(indfile).Append("; Delete error: ").Append(e.ToString()); } break; } } } } string sysindex = root + "sys.indexes"; if (System.IO.File.Exists(sysindex)) { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.Load(sysindex); System.Xml.XmlNodeList indexes = doc.SelectNodes("//index"); for (int i = 0; i < indexes.Count; i++) { indexes[i].ParentNode.RemoveChild(indexes[i]); } triesremain = MAX_TRIES; for (; ;) { try { doc.Save(sysindex); lock (hosts) { Console.Write('.'); } break; } catch (Exception e) { if (--triesremain <= 0) { lock (hosts) { if (!errs.ContainsKey(host)) { errs.Add(host, new StringBuilder(1024)); } StringBuilder sb = errs[host]; sb.Append(Environment.NewLine).Append("File: "). Append(sysindex).Append("; Save error: ").Append(e.ToString()); } break; } } } } } ), hosts, threadcount); Console.WriteLine(); if (errs.Count > 0) { Console.WriteLine("Errors encountered while trying to delete rindexes from these machines:"); foreach (string host in errs.Keys) { Console.WriteLine(host); Console.WriteLine(errs[host].ToString()); } } else { Console.WriteLine("Done"); } }
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)); }
private static void VerifyRIndexes(string[] args) { string[] hosts = Utils.GetQizmtHosts(); if (hosts.Length == 0) { Console.Error.WriteLine("No Qizmt host is found."); return; } bool verbose = args.Length > 1 && string.Compare(args[1], "-v", true) == 0; string currentdir = CurrentDir.Replace(':', '$'); int threadcount = hosts.Length; if (threadcount > 15) { threadcount = 15; } bool identicalsysindexes = true; { Console.WriteLine(); Console.WriteLine("Getting sysindexes state..."); if (hosts.Length > 1) { System.Xml.XmlDocument prevdoc = null; for (int i = 0; i < hosts.Length; i++) { string sysindex = @"\\" + hosts[i] + @"\" + currentdir + @"\sys.indexes"; System.Xml.XmlDocument doc = null; if (System.IO.File.Exists(sysindex)) { doc = new System.Xml.XmlDocument(); doc.Load(sysindex); } if (i > 0) { //compare if (!CompareSysIndexes(prevdoc, doc)) { identicalsysindexes = false; break; } } prevdoc = doc; } } } Dictionary <string, List <string> > leaks = new Dictionary <string, List <string> >(); Dictionary <string, Dictionary <string, int> > duprindexes = new Dictionary <string, Dictionary <string, int> >(); Dictionary <string, Dictionary <string, int> > duptables = new Dictionary <string, Dictionary <string, int> >(); Dictionary <string, Dictionary <string, int> > rindexeswithmissingfiles = new Dictionary <string, Dictionary <string, int> >(); Dictionary <string, int> okrindexesscore = new Dictionary <string, int>(); Dictionary <string, string> okrindexestypeinfo = new Dictionary <string, string>(); RDBMS_Admin.ThreadTools <string> .Parallel( new Action <string>( delegate(string host) { if (verbose) { lock (leaks) { Console.WriteLine(); Console.WriteLine("Getting info: {0}...", host); } } string root = @"\\" + host + @"\" + currentdir; string sysindex = root + @"\sys.indexes"; Dictionary <string, int> rindexes = new Dictionary <string, int>(); Dictionary <string, int> tables = new Dictionary <string, int>(); if (System.IO.File.Exists(sysindex)) { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.Load(sysindex); System.Xml.XmlNodeList nodes = doc.SelectNodes("//index"); foreach (System.Xml.XmlNode node in nodes) { string rindexname = node["name"].InnerText.ToLower(); string tablename = node["table"]["name"].InnerText.ToLower(); bool pin = node["pin"].InnerText == "1"; bool ok = true; if (!rindexes.ContainsKey(rindexname)) { rindexes.Add(rindexname, 1); } else { ok = false; lock (duprindexes) { if (!duprindexes.ContainsKey(host)) { duprindexes.Add(host, new Dictionary <string, int>()); } if (!duprindexes[host].ContainsKey(rindexname)) { duprindexes[host].Add(rindexname, 0); } duprindexes[host][rindexname]++; } } if (!tables.ContainsKey(tablename)) { tables.Add(tablename, 1); } else { ok = false; lock (duptables) { if (!duptables.ContainsKey(host)) { duptables.Add(host, new Dictionary <string, int>()); } if (!duptables[host].ContainsKey(tablename)) { duptables[host].Add(tablename, 0); } duptables[host][tablename]++; } } if (!System.IO.File.Exists(root + @"\ind.Index." + rindexname + ".ind")) { ok = false; lock (rindexeswithmissingfiles) { if (!rindexeswithmissingfiles.ContainsKey(host)) { rindexeswithmissingfiles.Add(host, new Dictionary <string, int>()); } if (!rindexeswithmissingfiles[host].ContainsKey(rindexname)) { rindexeswithmissingfiles[host].Add(rindexname, 0); } rindexeswithmissingfiles[host][rindexname]++; } } if (pin && !System.IO.File.Exists(root + @"\ind.Pin." + rindexname + ".ind")) { ok = false; lock (rindexeswithmissingfiles) { if (!rindexeswithmissingfiles.ContainsKey(host)) { rindexeswithmissingfiles.Add(host, new Dictionary <string, int>()); } if (!rindexeswithmissingfiles[host].ContainsKey(rindexname)) { rindexeswithmissingfiles[host].Add(rindexname, 0); } rindexeswithmissingfiles[host][rindexname]++; } } if (ok) { lock (okrindexesscore) { if (!okrindexesscore.ContainsKey(rindexname)) { okrindexesscore.Add(rindexname, 0); } okrindexesscore[rindexname]++; } lock (okrindexestypeinfo) { if (!okrindexestypeinfo.ContainsKey(rindexname)) { okrindexestypeinfo.Add(rindexname, GetRIndexTypeInfo(node)); } } } } } string[] indfiles = System.IO.Directory.GetFiles(root, "ind.*.ind"); foreach (string indfile in indfiles) { string[] parts = indfile.Split('.'); string rindexname = parts[2].ToLower(); if (!rindexes.ContainsKey(rindexname)) { lock (leaks) { if (!leaks.ContainsKey(host)) { leaks.Add(host, new List <string>()); } leaks[host].Add(indfile); } } } } ), hosts, threadcount); if (identicalsysindexes) { Console.WriteLine(); Console.WriteLine("State of sysindexes on cluster:"); Console.WriteLine("All identical"); } Console.WriteLine(); Console.WriteLine("Healthy Hosts:"); bool unhealthyhostfound = false; foreach (string host in hosts) { if (!(leaks.ContainsKey(host) || duprindexes.ContainsKey(host) || duptables.ContainsKey(host) || rindexeswithmissingfiles.ContainsKey(host))) { Console.WriteLine(); Console.WriteLine(host); Console.WriteLine("No leak"); Console.WriteLine("No duplicated rindex"); Console.WriteLine("No duplicated table"); Console.WriteLine("No rindex with missing meta files"); } else { unhealthyhostfound = true; } } Console.WriteLine(); Console.WriteLine("Valid RIndexes:"); foreach (string key in okrindexesscore.Keys) { if (okrindexesscore[key] == hosts.Length) { Console.WriteLine(okrindexestypeinfo[key]); } } ConsoleColor oldColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; if (!identicalsysindexes) { Console.WriteLine(); Console.WriteLine("State of sysindexes on cluster:"); Console.WriteLine("Not identical"); } if (unhealthyhostfound) { Console.WriteLine(); Console.WriteLine("Unhealthy Hosts:"); foreach (string host in hosts) { if (leaks.ContainsKey(host) || duprindexes.ContainsKey(host) || duptables.ContainsKey(host) || rindexeswithmissingfiles.ContainsKey(host)) { Console.WriteLine(); Console.WriteLine(host); if (leaks.ContainsKey(host)) { Console.WriteLine("Leaks found"); if (verbose) { List <string> dups = leaks[host]; foreach (string dp in dups) { Console.WriteLine(" " + dp); } } } else { Console.WriteLine("No leak"); } if (duprindexes.ContainsKey(host)) { Console.WriteLine("Duplicated rindex found"); if (verbose) { foreach (string dp in duprindexes[host].Keys) { Console.WriteLine(" " + dp); } } } else { Console.WriteLine("No duplicated rindex"); } if (duptables.ContainsKey(host)) { Console.WriteLine("Duplicated table found"); if (verbose) { foreach (string dp in duptables[host].Keys) { Console.WriteLine(" " + dp); } } } else { Console.WriteLine("No duplicated table"); } if (rindexeswithmissingfiles.ContainsKey(host)) { Console.WriteLine("Rindex with missing meta files found"); if (verbose) { foreach (string dp in rindexeswithmissingfiles[host].Keys) { Console.WriteLine(" " + dp); } } } else { Console.WriteLine("No rindex with missing meta files"); } } } } Console.ForegroundColor = oldColor; }
public static void Callstack(string[] args) { if (args.Length <= 1) { Console.Error.WriteLine("Expected host"); return; } string hostcs = args[1]; string netpath = @"\\" + hostcs + @"\" + CurrentDir.Replace(':', '$'); { int protopid; string sprotopid; string protofp = netpath + @"\protocol.pid.rdbms"; for (; ; System.Threading.Thread.Sleep(1000 * 1)) { try { string protofcontent; using (System.IO.FileStream f = new System.IO.FileStream(protofp, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read | System.IO.FileShare.Write | System.IO.FileShare.Delete)) { System.IO.StreamReader sr = new System.IO.StreamReader(f); protofcontent = sr.ReadToEnd(); sr.Close(); } { int inl = protofcontent.IndexOf('\n'); // Continue if no \n. if (-1 != inl) { sprotopid = protofcontent.Substring(0, inl).Trim(); break; } } } catch (System.IO.FileNotFoundException) { Console.Error.WriteLine("No protocol process for host {0}", hostcs); return; } } protopid = int.Parse(sprotopid); sprotopid = protopid.ToString(); // Normalize. Console.WriteLine("Waiting on protocol callstack..."); { string path = netpath + @"\" + sprotopid + ".trace.rdbms"; for (; System.IO.File.Exists(path); System.Threading.Thread.Sleep(1000 * 1)) { } string tpath = "pid" + System.Diagnostics.Process.GetCurrentProcess().Id + "tracing.proto" + sprotopid + ".tof.rdbms"; System.IO.File.WriteAllText(path, tpath + Environment.NewLine + "."); } for (int tries = 0; ; tries++) { if (0 != tries) { System.Threading.Thread.Sleep(1000 * 3); } { string tpath = netpath + @"\" + "pid" + System.Diagnostics.Process.GetCurrentProcess().Id + "tracing.proto" + sprotopid + ".tof.rdbms"; { string toutput = ReadTraceFromFile(tpath); if (null == toutput) { if (!System.IO.File.Exists(protofp)) { Console.WriteLine(); Console.WriteLine("Protocol no longer running"); try { System.IO.File.Delete(netpath + @"\" + sprotopid + ".trace.rdbms"); } catch { } break; } } else { Console.WriteLine(); Console.WriteLine(toutput); try { System.IO.File.Delete(tpath); } catch { } break; } } } } Console.WriteLine(); } }
private static void RepairRIndexes(string[] args) { string[] hosts = Utils.GetQizmtHosts(); if (hosts.Length == 0) { Console.Error.WriteLine("No Qizmt host is found."); return; } ConsoleColor oldcolor = Console.ForegroundColor; Console.WriteLine(); Console.WriteLine("Getting the master index..."); { string currentdir = CurrentDir.Replace(':', '$'); Dictionary <string, int> mihash = new Dictionary <string, int>(hosts.Length); foreach (string host in hosts) { string mipath = @"\\" + host + @"\" + currentdir + @"\sys.indexes"; try { string mitext = System.IO.File.ReadAllText(mipath); if (!mihash.ContainsKey(mitext)) { mihash.Add(mitext, 1); } else { mihash[mitext]++; } } catch { Console.WriteLine("Master index is skipped at:" + mipath); } } //Get master index with the highest count. System.Xml.XmlDocument mi = null; { string themi = ""; int max = Int32.MinValue; foreach (KeyValuePair <string, int> pair in mihash) { if (pair.Value > max) { max = pair.Value; themi = pair.Key; } } if (themi.Length == 0) { Console.Error.WriteLine("Cannot find the master index."); return; } else { Console.WriteLine("Master index found. Copies count: {0}", max); mi = new System.Xml.XmlDocument(); mi.LoadXml(themi); } } //Create statements List <string> skipped = new List <string>(); Dictionary <string, string> creates = null; { System.Xml.XmlNodeList indexes = mi.SelectNodes("indexes/index"); if (indexes.Count == 0) { Console.WriteLine("There is no rindex in the master index. Nothing to repair."); return; } Console.WriteLine(); Console.WriteLine(indexes.Count.ToString() + " rindexes were found from the master index."); Console.WriteLine(); Console.WriteLine("Preparing RINDEX CREATE statements..."); creates = new Dictionary <string, string>(indexes.Count); foreach (System.Xml.XmlNode index in indexes) { string iname = index["name"].InnerText; int ordinal = Int32.Parse(index["ordinal"].InnerText); bool updatememoryonly = (index["updatememoryonly"] != null && index["updatememoryonly"].InnerText == "1"); bool pin = (index["pin"].InnerText == "1"); bool pinHash = (index["pinHash"].InnerText == "1"); bool keepvalueorder = (index["keepValueOrder"].InnerText == "1"); string outliermode = index["outlier"]["mode"].InnerText; int outliermax = Int32.Parse(index["outlier"]["max"].InnerText); string tablename = index["table"]["name"].InnerText; System.Xml.XmlNodeList cols = index.SelectNodes("table/column"); if (ordinal >= cols.Count) { string msg = "Skipped: Cannot generate CREATE statement for rindex: " + iname + ". Reason: ordinal >= columns count of table; ordinal: " + ordinal.ToString() + "; columns count=" + cols.Count.ToString(); skipped.Add(msg); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(msg); Console.ForegroundColor = oldcolor; } else { string keycol = cols[ordinal]["name"].InnerText; string create = "CREATE RINDEX " + iname + " FROM " + tablename; if (updatememoryonly) { create += " updatememoryonly"; } if (pin & pinHash) { create += " pinmemoryhash"; } else if (pin) { create += " pinmemory"; } else if (pinHash) // should never be this case. { create += " pinmemoryhash"; } else { create += " diskonly"; } if (keepvalueorder) { create += " keepvalueorder"; } if (string.Compare(outliermode, "none", true) != 0) { create += " outlier " + outliermode + " " + outliermax.ToString(); } create += " on " + keycol; creates.Add(iname, create); } } } { string log = "rdbms_admin repairrindexes command issued:" + Environment.NewLine + "CREATE RINDEX statements prepared:" + Environment.NewLine; foreach (KeyValuePair <string, string> pair in creates) { log += pair.Value + Environment.NewLine; } LogOutputToFile(log); } Console.WriteLine(); Console.WriteLine(creates.Count.ToString() + " statements prepared."); if (skipped.Count > 0) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(skipped.Count.ToString() + " statements skipped."); Console.ForegroundColor = oldcolor; } if (creates.Count == 0) { Console.WriteLine("All statements were skipped. Nothing to repair."); return; } //Drop all indexes Console.WriteLine(); Console.WriteLine("Dropping all rindexes..."); DeleteRIndexes(args); Console.WriteLine("Rindexes dropped."); //Create rindexes Console.WriteLine(); Console.WriteLine("Creating rindexes..."); System.Data.Common.DbProviderFactory fact = DbProviderFactories.GetFactory("Qizmt_DataProvider"); Dictionary <string, string> failed = new Dictionary <string, string>(creates.Count); int createdcount = 0; using (DbConnection conn = fact.CreateConnection()) { conn.ConnectionString = "Data Source = localhost"; foreach (KeyValuePair <string, string> pair in creates) { string iname = pair.Key; string create = pair.Value; try { Console.WriteLine("Creating rindex {0}...", iname); conn.Open(); DbCommand cmd = conn.CreateCommand(); cmd.CommandText = create; cmd.ExecuteNonQuery(); conn.Close(); createdcount++; Console.WriteLine("Created successfully"); } catch (Exception e) { string msg = "Failed to create rindex: " + iname + ". Statement:" + create + ". Error:" + e.ToString(); failed.Add(iname, msg); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(msg); Console.ForegroundColor = oldcolor; } } } Console.WriteLine(); Console.WriteLine(createdcount.ToString() + " RIndexes were created successfully."); if (failed.Count > 0) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(failed.Count.ToString() + " RIndexes were skipped because of error."); Console.ForegroundColor = oldcolor; } } }