public Package(string name, Package package, IEnumerable<string> fileList) : this(name: name, preprocessorDefinitions: package.PreprocessorDefinitions.ToOptionalClass(), lineList: package.LineList.ToOptionalClass(), fileList: fileList.ToOptionalClass(), skip: package.Skip) { }
public void BuildPackage(Package pkg) { string path = Config.PathFormat("{0}/{1}", cfg.pkg_path, pkg.GetBaseFolder()); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } /* Create all dirs */ string [] paths = pkg.GetFolders(); for (int i=0; i<paths.GetLength(0); i++) { path = Config.PathFormat("{0}/{1}/{2}", cfg.pkg_path, pkg.GetBaseFolder(), paths[i]); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } } /* Do primitive copies */ pkg.OnCopyFolders(this); pkg.OnCopyFiles(this); /* Do libraries */ Library [] libs = pkg.GetLibraries(); for (int i=0; i<libs.Length; i++) { if (libs[i].build_mode == BuildMode.BuildMode_Episode1) { continue; } if ((libs[i].platform & cfg.Platform) != cfg.Platform) { continue; } if (!BuildLibrary(pkg, libs[i])) { throw new System.Exception("Failed to compile library: " + libs[i].binary_name); } } /* Do plugins */ Plugin [] plugins = pkg.GetPlugins(); if (plugins != null) { for (int i=0; i<plugins.Length; i++) { if (!CompilePlugin(pkg, plugins[i])) { throw new System.Exception("Failed to compile plugin: " + plugins[i].Source); } } } }
public void Make(Package package) { File.WriteAllLines( FileName("boost_" + package.Name.Select(n => n, () => "")), new[] { "#define _SCL_SECURE_NO_WARNINGS", "#define _CRT_SECURE_NO_WARNINGS", "#pragma warning(disable: 4244 4503 4752 4800 4996)" }. Concat(package.LineList). Concat( new[] { "#include \"" + Path.GetFileName(_localFile) + "\"" } ) ); }
public bool CompilePlugin(Package pkg, Plugin pl) { string local_dir = Config.PathFormat("{0}/{1}/addons/sourcemod/scripting", cfg.pkg_path, pkg.GetBaseFolder()); string filepath = null; if (pl.Folder != null) { filepath = Config.PathFormat("{0}/{1}", pl.Folder, pl.Source); } else { filepath = pl.Source; } ProcessStartInfo info = new ProcessStartInfo(); info.WorkingDirectory = local_dir; info.FileName = Config.PathFormat("{0}/{1}", local_dir, GetPawnCompilerName()); info.Arguments = filepath + ".sp"; info.UseShellExecute = false; info.RedirectStandardOutput = true; info.RedirectStandardError = true; Process p = Process.Start(info); string output = p.StandardOutput.ReadToEnd() + "\n"; output += p.StandardError.ReadToEnd(); p.WaitForExit(); p.Close(); Console.WriteLine(output); string binary = Config.PathFormat("{0}/{1}/addons/sourcemod/scripting/{2}.smx", cfg.pkg_path, pkg.GetBaseFolder(), pl.Source); if (!File.Exists(binary)) { Console.WriteLine("Could not find binary: " + binary); return false; } string new_loc; if (pl.disabled) { new_loc = Config.PathFormat("{0}/{1}/addons/sourcemod/plugins/disabled/{2}.smx", cfg.pkg_path, pkg.GetBaseFolder(), pl.Source); } else { new_loc = Config.PathFormat("{0}/{1}/addons/sourcemod/plugins/{2}.smx", cfg.pkg_path, pkg.GetBaseFolder(), pl.Source); } try { if (File.Exists(new_loc)) { File.Delete(new_loc); } File.Move(binary, new_loc); } catch (System.Exception e) { Console.WriteLine(e.Message); return false; } return true; }
public abstract bool BuildLibrary(Package pkg, Library lib);
/** dest can be null to mean root base folder */ public void CopyFolder(Package pkg, string source, string dest, string [] omits) { string from_base = Config.PathFormat("{0}/{1}", cfg.source_path, source); string to_base = null; if (dest == null) { to_base = Config.PathFormat("{0}/{1}", cfg.pkg_path, pkg.GetBaseFolder()); } else { to_base = Config.PathFormat("{0}/{1}/{2}", cfg.pkg_path, pkg.GetBaseFolder(), dest); } string [] files = Directory.GetFiles(from_base); string file; for (int i=0; i<files.Length; i++) { file = Path.GetFileName(files[i]); if (omits != null) { bool skip = false; for (int j=0; j<omits.Length; j++) { if (file.CompareTo(omits[j]) == 0) { skip = true; break; } } if (skip) { continue; } } dest = Config.PathFormat("{0}/{1}", to_base, file); File.Copy(files[i], dest, true); } }
public bool CopyFile(Package pkg, string source, string dest) { string from = Config.PathFormat("{0}/{1}", cfg.source_path, source); string to = Config.PathFormat("{0}/{1}/{2}", cfg.pkg_path, pkg.GetBaseFolder(), dest); File.Copy(from, to, true); return true; }
public override bool BuildLibrary(Package pkg, Library lib) { ProcessStartInfo info = new ProcessStartInfo(); string path = Config.PathFormat("{0}/{1}", cfg.source_path, lib.source_path); /* PlatformExt ignored for us */ string binName = lib.binary_name; if (!lib.is_executable) { if (lib.has_platform_ext) { binName += "_i486.so"; } else { binName += ".so"; } } string output_folder = (lib.release_mode == ReleaseMode.ReleaseMode_Release) ? "Release" : "Debug"; if (lib.build_mode == BuildMode.BuildMode_Episode2) { output_folder += ".orangebox"; } else if (lib.build_mode == BuildMode.BuildMode_OldMetamod) { output_folder += ".original"; } else if (lib.build_mode == BuildMode.BuildMode_Left4Dead) { output_folder += ".left4dead"; } string binpath = Config.PathFormat("{0}/{1}/{2}", path, output_folder, binName); if (File.Exists(binpath)) { File.Delete(binpath); } string makefile_args = "CPP=gcc-4.1 "; if (lib.build_mode == BuildMode.BuildMode_Episode1) { } else if (lib.build_mode == BuildMode.BuildMode_Episode2) { makefile_args += "ENGINE=\"orangebox\" "; } else if (lib.build_mode == BuildMode.BuildMode_OldMetamod) { makefile_args = "ENGINE=\"original\""; } else if (lib.build_mode == BuildMode.BuildMode_Left4Dead) { makefile_args = "ENGINE=\"left4dead\""; } /* Clean the project first */ info.WorkingDirectory = path; info.FileName = cfg.builder_path; info.Arguments = makefile_args + " clean"; info.UseShellExecute = false; Process p = Process.Start(info); p.WaitForExit(); p.Close(); /* Now build it */ info.WorkingDirectory = path; info.FileName = cfg.builder_path; info.Arguments = makefile_args; info.UseShellExecute = false; if (cfg.build_options != null) { info.Arguments += " " + cfg.build_options; } p = Process.Start(info); p.WaitForExit(); p.Close(); if (!File.Exists(binpath)) { return false; } path = Config.PathFormat("{0}/{1}/{2}/{3}", cfg.pkg_path, pkg.GetBaseFolder(), lib.package_path, binName); File.Copy(binpath, path, true); return true; }
public override bool BuildLibrary(Package pkg, Library lib) { ProcessStartInfo info = new ProcessStartInfo(); string path = Config.PathFormat("{0}/{1}/msvc9", cfg.source_path, lib.source_path); /* PlatformExt ignored for us */ string binName = lib.binary_name + (lib.is_executable ? ".exe" : ".dll"); string config_name = "Unknown"; if (lib.release_mode == ReleaseMode.ReleaseMode_Release) { config_name = "Release"; } else if (lib.release_mode == ReleaseMode.ReleaseMode_Debug) { config_name = "Debug"; } if (lib.build_mode == BuildMode.BuildMode_DarkMessiah) { config_name = config_name + " - Dark Messiah"; } if (lib.build_mode == BuildMode.BuildMode_Episode1) { config_name = config_name + " - Episode 1"; } else if (lib.build_mode == BuildMode.BuildMode_Episode2) { config_name = config_name + " - Orange Box"; } else if (lib.build_mode == BuildMode.BuildMode_OldMetamod) { config_name = config_name + " - Old Metamod"; } else if (lib.build_mode == BuildMode.BuildMode_Left4Dead) { config_name = config_name + " - Left 4 Dead"; } string binpath = Config.PathFormat("{0}/{1}/{2}", path, config_name, binName); if (File.Exists(binpath)) { File.Delete(binpath); } string project_file = null; if (lib.vcproj_name != null) { project_file = lib.vcproj_name + ".vcproj"; } else { project_file = lib.binary_name + ".vcproj"; } info.WorkingDirectory = path; info.FileName = cfg.builder_path; info.UseShellExecute = false; info.RedirectStandardOutput = true; info.RedirectStandardError = true; if (cfg.build_options != null) { info.Arguments = cfg.build_options + " "; } info.Arguments += "/rebuild \"" + project_file + "\" \"" + config_name + "\""; Process p = Process.Start(info); Console.WriteLine(p.StandardOutput.ReadToEnd()); p.WaitForExit(); p.Close(); if (!File.Exists(binpath)) { return false; } path = Config.PathFormat("{0}/{1}/{2}/{3}", cfg.pkg_path, pkg.GetBaseFolder(), lib.package_path, binName); File.Copy(binpath, path, true); /* On Windows we optionally log the PDB path */ if (!lib.is_executable && cfg.pdb_log_file != null) { FileStream fs = File.Open(cfg.pdb_log_file, FileMode.Append, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); sw.WriteLine(binpath.Replace(".dll", ".pdb")); sw.Close(); } return true; }