private static string GetPagePath(string pageName) { string path = Path.Combine( Toolbox.FindCitrusDirectory(), "Tangerine", "Tangerine", "Documentation", Path.Combine(pageName.Split('.'))); return(path + ".md"); }
public static void GenerateBinaryDeserializersAndCloners() { var assembly = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.FullName.StartsWith("Lime", StringComparison.OrdinalIgnoreCase)).First(); Generate(Path.Combine(Toolbox.FindCitrusDirectory(), "Lime", "Source", "YuzuGeneratedBinaryDeserializer.cs"), new BinaryDeserializerGenerator("YuzuGenerated", InternalPersistence.Instance.YuzuCommonOptions, "LimeDeserializer") { LineSeparator = "\n", }, GenerateForAssemblies(new[] { assembly }) ); Generate(Path.Combine(Toolbox.FindCitrusDirectory(), "Lime", "Source", "YuzuGeneratedCloners.cs"), new ClonerGenerator("YuzuGenerated", InternalPersistence.Instance.YuzuCommonOptions, "LimeCloner") { LineSeparator = "\n", }, GenerateForAssemblies(new[] { assembly }) ); }
public static string RunTangerine() { const string projectName = "Tangerine"; var projectDirectory = Path.Combine(Toolbox.FindCitrusDirectory(), projectName); #if WIN var solutionPath = Path.Combine(projectDirectory, projectName + ".Win.sln"); MSBuild.TryGetMSBuildPath(out var msbuildPath); Nuget.Restore(solutionPath, msbuildPath); var solutionBuilder = new SolutionBuilder(new Target("Tangerine.Win", solutionPath, false, TargetPlatform.Win, BuildConfiguration.Release)); #elif MAC var solutionPath = Path.Combine(projectDirectory, projectName + ".Win.sln"); Nuget.Restore(solutionPath); // "Release" configuration requires code signing, use debug for a while. var solutionBuilder = new SolutionBuilder(new Target("Tangerine.Mac", solutionPath, false, TargetPlatform.Mac, BuildConfiguration.Debug)); #endif if (!solutionBuilder.Build()) { return("Build system has returned error"); } var p = new System.Diagnostics.Process(); #if WIN p.StartInfo.FileName = Path.Combine( projectDirectory, "Tangerine", "bin", BuildConfiguration.Release, "Tangerine.exe"); #elif MAC p.StartInfo.FileName = Path.Combine( projectDirectory, "Tangerine", "bin", BuildConfiguration.Debug, "Tangerine.app/Contents/MacOS/Tangerine"); p.StartInfo.UseShellExecute = false; p.StartInfo.EnvironmentVariables.Clear(); p.StartInfo.EnvironmentVariables.Add("PATH", "/usr/bin"); #endif p.Start(); return(null); }
static Nuget() { #if MAC nugetPath = Path.Combine(Toolbox.GetApplicationDirectory(), "nuget.exe"); #else nugetPath = Path.Combine(Toolbox.GetApplicationDirectory(), "Toolchain.Win", "nuget.exe"); #endif if (!File.Exists(nugetPath)) { nugetPath = Path.Combine(Toolbox.FindCitrusDirectory(), "Orange", "Toolchain.Win", "nuget.exe"); } if (!File.Exists(nugetPath)) { throw new InvalidOperationException($"Can't find nuget.exe."); } #if MAC monoPath = Toolbox.GetMonoPath(); #endif }
public static void NewProjectAction(Func <string, bool> projectOpened) { Application.InvokeOnMainThread(() => { var citrusPath = Toolbox.FindCitrusDirectory(); var dlg = new FileDialog { AllowedFileTypes = new string[] { "" }, Mode = FileDialogMode.SelectFolder }; if (dlg.RunModal()) { targetDirectory = dlg.FileName; newCitrusDirectory = Path.Combine(dlg.FileName, "Citrus"); var projectName = Path.GetFileName(dlg.FileName); if (char.IsDigit(projectName[0])) { throw new System.Exception($"Project name '{projectName}' cannot start with a digit"); } foreach (char c in projectName) { if (!ValidChars.Contains(c)) { throw new System.Exception($"Project name '{projectName}' must contain only latin letters and digits"); } } var newProjectApplicationName = String.Join(" ", Regex.Split(projectName, @"(?<!^)(?=[A-Z])")); Console.WriteLine($"New project name is \"{projectName}\""); HashSet <string> textfileExtensions = new HashSet <string> { ".cs", ".xml", ".csproj", ".sln", ".citproj", ".projitems", ".shproj", ".txt", ".plist", ".strings", ".gitignore", }; using (var dc = new DirectoryChanger($"{citrusPath}/Samples/EmptyProject/")) { var fe = new FileEnumerator("."); foreach (var f in fe.Enumerate()) { var targetPath = Path.Combine(dlg.FileName, f.Path.Replace("EmptyProject", projectName)); Console.WriteLine($"Copying: {f.Path} => {targetPath}"); Directory.CreateDirectory(Path.GetDirectoryName(targetPath)); System.IO.File.Copy(f.Path, targetPath); if (textfileExtensions.Contains(Path.GetExtension(targetPath).ToLower(CultureInfo.InvariantCulture))) { string text = File.ReadAllText(targetPath); text = text.Replace("EmptyProject", projectName); text = text.Replace("Empty Project", newProjectApplicationName); text = text.Replace("emptyproject", projectName.ToLower()); var citrusUri = new Uri(newCitrusDirectory); var fileUri = new Uri(targetPath); var relativeUri = fileUri.MakeRelativeUri(citrusUri); // TODO: apply only to .sln and .csproj file text = text.Replace("..\\..\\..", relativeUri.ToString()); if (targetPath.EndsWith(".citproj", StringComparison.OrdinalIgnoreCase)) { text = text.Replace("\"CitrusDirectory\": \"../../\",", $"\"CitrusDirectory\": \"{relativeUri}\","); newProjectCitprojPath = targetPath; } File.WriteAllText(targetPath, text); } } } #if WIN // TODO: fix unresponsiveness on mac Git.Exec(targetDirectory, "init"); Git.Exec(targetDirectory, "add -A"); Git.Exec(targetDirectory, "submodule add https://gitlab.game-forest.com:8888/Common/Citrus.git Citrus"); Git.Exec(targetDirectory, "submodule update --init --recursive"); Git.Exec(targetDirectory, "commit -m\"Initial commit.\""); #endif // WIN } }); if (projectOpened != null) { projectOpened?.Invoke(newProjectCitprojPath); } }
public static void Save(CitrusVersion citrusVersion) { using (var stream = File.Open(Path.Combine(Toolbox.FindCitrusDirectory(), Filename), FileMode.Open)) { Save(citrusVersion, stream); } }
public static CitrusVersion Load() { using (var stream = File.Open(Path.Combine(Toolbox.FindCitrusDirectory(), Filename), FileMode.Open)) { return(Load(stream)); } }