private void Compile(string file, bool isTemp) { var directory = Directory.GetCurrentDirectory(); var acc_bin = Dirs.Bin.ACC.FullName; var argBuilder = new List <string>(); var outputDir = "bin"; if (isTemp) { outputDir = "obj"; } var Project = AncientProject.FromLocal(); var fileName = Path.GetFileNameWithoutExtension(file); argBuilder.Add($"-o ./{outputDir}/{fileName}"); if (Project.Extension != null) { argBuilder.Add($"-e {Project.Extension}"); } argBuilder.Add($"-s \"{file}\""); var external = new ExternalTools(acc_bin, string.Join(" ", argBuilder)); Directory.CreateDirectory(Path.Combine(directory, outputDir)); external.Start().Wait().ExitCode(); }
public int Execute(bool isTemp) { var directory = Directory.GetCurrentDirectory(); if (!Validate(directory)) { return(1); } var ancient_home = Environment.GetEnvironmentVariable("ANCIENT_HOME", EnvironmentVariableTarget.User); if (ancient_home is null) { throw new InvalidOperationException($"env variable 'ANCIENT_HOME' is not set."); } if (!new DirectoryInfo(ancient_home).Exists) { throw new InvalidOperationException($"Env variable 'ANCIENT_HOME' is invalid."); } var acc_home = Path.Combine(ancient_home, "compiler"); var acc_bin = Path.Combine(acc_home, "acc.exe"); if (!new DirectoryInfo(acc_home).Exists || !new FileInfo(acc_bin).Exists) { throw new InvalidOperationException($"Ancient compiler is not installed."); } var argBuilder = new List <string>(); var files = Directory.GetFiles(directory, "*.asm"); var outputDir = "bin"; if (isTemp) { outputDir = "obj"; } var Project = AncientProject.FromLocal(); argBuilder.Add($"-o ./{outputDir}/{Project.Name}"); if (Project.Extension != null) { argBuilder.Add($"-e {Project.Extension}"); } argBuilder.Add($"-s \"{files.First()}\""); var external = new ExternalTools(acc_bin, string.Join(" ", argBuilder)); Directory.CreateDirectory(Path.Combine(directory, outputDir)); return(external.Start().Wait().ExitCode()); }