- fixed a series of corruption bugs in the admin cache (oh man, i suck sometimes)
- fixed per-group immunity being implemented completely wrong
- fixed GetAdminGroup being implemented wrong
- fixed a crash bug in the native GetAdminGroup
3 using System.Diagnostics;
7 public abstract class ABuilder
15 public abstract string CompressPackage(Package pkg);
17 public abstract bool BuildLibrary(Package pkg, Library lib, ref string _binName, ref string _binPath);
19 public abstract string GetPawnCompilerName();
21 public bool CompilePlugin(Package pkg, Plugin pl)
23 string local_dir = Config.PathFormat("{0}/{1}/addons/sourcemod/scripting", cfg.OutputBase, pkg.GetBaseFolder());
25 string filepath = null;
26 if (pl.Folder != null)
28 filepath = Config.PathFormat("{0}/{1}", pl.Folder, pl.Source);
35 ProcessStartInfo info = new ProcessStartInfo();
36 info.WorkingDirectory = local_dir;
37 info.FileName = Config.PathFormat("{0}/{1}", local_dir, GetPawnCompilerName());
38 info.Arguments = filepath + ".sp";
39 info.UseShellExecute = false;
40 info.RedirectStandardOutput = true;
41 info.RedirectStandardError = true;
43 Process p = Process.Start(info);
44 string output = p.StandardOutput.ReadToEnd() + "\n";
45 output += p.StandardError.ReadToEnd();
49 Console.WriteLine(output);
51 string binary = Config.PathFormat("{0}/{1}/addons/sourcemod/scripting/{2}.smx", cfg.OutputBase, pkg.GetBaseFolder(), pl.Source);
52 if (!File.Exists(binary))
60 new_loc = Config.PathFormat("{0}/{1}/addons/sourcemod/plugins/disabled/{2}.smx", cfg.OutputBase, pkg.GetBaseFolder(), pl.Source);
64 new_loc = Config.PathFormat("{0}/{1}/addons/sourcemod/plugins/{2}.smx", cfg.OutputBase, pkg.GetBaseFolder(), pl.Source);
69 if (File.Exists(new_loc))
73 File.Move(binary, new_loc);
75 catch (System.Exception e)
77 Console.WriteLine(e.Message);
84 public string GetRevsionOfPath(string path)
86 ProcessStartInfo info = new ProcessStartInfo();
88 info.WorkingDirectory = path;
89 info.FileName = cfg.SVNVersion;
90 info.Arguments = "--committed \"" + path + "\"";
91 info.UseShellExecute = false;
92 info.RedirectStandardOutput = true;
94 Process p = Process.Start(info);
95 string output = p.StandardOutput.ReadToEnd();
99 string [] revs = output.Split(":".ToCharArray(), 2);
106 if (revs.Length == 1)
116 rev = rev.Replace("M", "");
117 rev = rev.Replace("S", "");
122 public bool CopyFile(Package pkg, string source, string dest)
124 string from = Config.PathFormat("{0}/{1}",
127 string to = Config.PathFormat("{0}/{1}/{2}",
132 File.Copy(from, to, true);
137 /** dest can be null to mean root base folder */
138 public void CopyFolder(Package pkg, string source, string dest, string [] omits)
140 string from_base = Config.PathFormat("{0}/{1}", cfg.SourceBase, source);
141 string to_base = null;
145 to_base = Config.PathFormat("{0}/{1}",
147 pkg.GetBaseFolder());
151 to_base = Config.PathFormat("{0}/{1}/{2}",
157 string [] files = Directory.GetFiles(from_base);
160 for (int i=0; i<files.Length; i++)
162 file = Path.GetFileName(files[i]);
167 for (int j=0; j<omits.Length; j++)
169 if (file.CompareTo(omits[j]) == 0)
180 dest = Config.PathFormat("{0}/{1}", to_base, file);
181 File.Copy(files[i], dest, true);
185 public string PackageBuildName(Package pkg)
187 return pkg.GetPackageName()
189 + GetRevsionOfPath(cfg.SourceBase)
192 + DateTime.Now.Month.ToString("00")
193 + DateTime.Now.Day.ToString("00");
196 public void BuildPackage(Package pkg)
198 string path = Config.PathFormat("{0}/{1}", cfg.OutputBase, pkg.GetBaseFolder());
200 if (!Directory.Exists(path))
202 Directory.CreateDirectory(path);
205 /* Create all dirs */
206 string [] paths = pkg.GetFolders();
207 for (int i=0; i<paths.GetLength(0); i++)
209 path = Config.PathFormat("{0}/{1}/{2}", cfg.OutputBase, pkg.GetBaseFolder(), paths[i]);
210 if (!Directory.Exists(path))
212 Directory.CreateDirectory(path);
216 /* Do primitive copies */
217 pkg.OnCopyFolders(this);
218 pkg.OnCopyFiles(this);
221 Library [] libs = pkg.GetLibraries();
222 string bin = null, binpath = null;
223 for (int i=0; i<libs.Length; i++)
225 if (BuildLibrary(pkg, libs[i], ref bin, ref binpath))
227 path = Config.PathFormat("{0}/{1}/{2}/{3}",
232 File.Copy(binpath, path, true);
236 throw new System.Exception("Failed to compile library: " + libs[i].Name);
241 Plugin [] plugins = pkg.GetPlugins();
244 for (int i=0; i<plugins.Length; i++)
246 if (!CompilePlugin(pkg, plugins[i]))
248 throw new System.Exception("Failed to compile plugin: " + plugins[i].Source);
253 string pkg_file = null;
254 if (cfg.Compressor != null)
256 if ((pkg_file=CompressPackage(pkg)) == null)
258 throw new System.Exception("Failed to compress package: " + pkg.GetPackageName());
261 string lpath = null, ltarget = null;
262 pkg.GetCompressBases(ref lpath, ref ltarget);
263 lpath = Config.PathFormat("{0}/{1}/{2}",
267 ltarget = Config.PathFormat("{0}/{1}", cfg.OutputBase, pkg_file);
269 if (File.Exists(ltarget))
271 File.Delete(ltarget);
274 File.Move(lpath, ltarget);