From 7f44c014ae1f85c42a7fc490777541dac2be42ec Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 27 Jan 2007 03:10:31 +0000 Subject: [PATCH] added build tool --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40394 --- core/svn_version.h | 6 +- sourcepawn/jit/x86/svn_version.h | 6 +- tools/builder/ABuilder.cs | 165 +++++++++++++++++++++++++++++++ tools/builder/AssemblyInfo.cs | 58 +++++++++++ tools/builder/Config.cs | 120 ++++++++++++++++++++++ tools/builder/LinuxBuilder.cs | 93 +++++++++++++++++ tools/builder/Main.cs | 39 ++++++++ tools/builder/Package.cs | 51 ++++++++++ tools/builder/PkgCore.cs | 96 ++++++++++++++++++ tools/builder/Win32Builder.cs | 65 ++++++++++++ tools/builder/build-win32.cfg | 0 tools/builder/builder.csproj | 130 ++++++++++++++++++++++++ tools/builder/builder.sln | 23 +++++ 13 files changed, 846 insertions(+), 6 deletions(-) create mode 100644 tools/builder/ABuilder.cs create mode 100644 tools/builder/AssemblyInfo.cs create mode 100644 tools/builder/Config.cs create mode 100644 tools/builder/LinuxBuilder.cs create mode 100644 tools/builder/Main.cs create mode 100644 tools/builder/Package.cs create mode 100644 tools/builder/PkgCore.cs create mode 100644 tools/builder/Win32Builder.cs create mode 100644 tools/builder/build-win32.cfg create mode 100644 tools/builder/builder.csproj create mode 100644 tools/builder/builder.sln diff --git a/core/svn_version.h b/core/svn_version.h index 95cf2d96..c4478d50 100644 --- a/core/svn_version.h +++ b/core/svn_version.h @@ -3,9 +3,9 @@ #ifndef _INCLUDE_SVN_VERSION_H_ #define _INCLUDE_SVN_VERSION_H_ -#define SVN_REVISION 390 -#define SVN_REVISION_STRING "390" -#define SVN_FILE_VERSION 1,0,0,390 +#define SVN_REVISION 392 +#define SVN_REVISION_STRING "392" +#define SVN_FILE_VERSION 1,0,0,392 #endif //_INCLUDE_SVN_VERSION_H_ diff --git a/sourcepawn/jit/x86/svn_version.h b/sourcepawn/jit/x86/svn_version.h index 46a4d57a..c4478d50 100644 --- a/sourcepawn/jit/x86/svn_version.h +++ b/sourcepawn/jit/x86/svn_version.h @@ -3,9 +3,9 @@ #ifndef _INCLUDE_SVN_VERSION_H_ #define _INCLUDE_SVN_VERSION_H_ -#define SVN_REVISION 390 -#define SVN_REVISION_STRING "390" -#define SVN_FILE_VERSION 1,0,0,390 +#define SVN_REVISION 392 +#define SVN_REVISION_STRING "392" +#define SVN_FILE_VERSION 1,0,0,392 #endif //_INCLUDE_SVN_VERSION_H_ diff --git a/tools/builder/ABuilder.cs b/tools/builder/ABuilder.cs new file mode 100644 index 00000000..5400f846 --- /dev/null +++ b/tools/builder/ABuilder.cs @@ -0,0 +1,165 @@ +using System; +using System.IO; +using System.Diagnostics; + +namespace builder +{ + public abstract class ABuilder + { + public Config cfg; + + public ABuilder() + { + } + + public abstract bool BuildLibrary(Package pkg, Library lib, ref string _binName, ref string _binPath); + + public void UpdateRevisionInfo(Package pkg, Library lib) + { + string path = Config.PathFormat("{0}/{1}", cfg.SourceBase, lib.LocalPath); + string file = Config.PathFormat("{0}/svn_version.h", path); + + if (File.Exists(file)) + { + UpdateRevisionInfo(path, file); + } + } + + public void CopyFolder(Package pkg, string source, string dest, string [] omits) + { + string from_base = Config.PathFormat("{0}/{1}", cfg.SourceBase, source); + string to_base = Config.PathFormat("{0}/{1}/{2}", + cfg.OutputBase, + pkg.GetBaseFolder(), + dest); + + string [] files = Directory.GetFiles(from_base); + string file; + + for (int i=0; i. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/tools/builder/Config.cs b/tools/builder/Config.cs new file mode 100644 index 00000000..bb52ad95 --- /dev/null +++ b/tools/builder/Config.cs @@ -0,0 +1,120 @@ +using System; +using System.IO; +using System.Text; + +namespace builder +{ + public enum BasePlatform + { + Platform_Windows, + Platform_Linux + }; + + public class Config + { + public string SourceBase; + public string OutputBase; + public string BuilderPath; + public string CompressPath; + public string CompressOptions; + public string SVNVersion; + public string ProductVersion; + public builder.BasePlatform Platform; + + public Config() + { + if ((int)System.Environment.OSVersion.Platform == 128) + { + Platform = BasePlatform.Platform_Linux; + } + else + { + Platform = BasePlatform.Platform_Windows; + } + } + + public static string PathFormat(string format, params string [] args) + { + string temp = string.Format(format, args); + return temp.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); + } + + public bool ReadFromFile(string file) + { + bool read = true; + StreamReader sr = null; + try + { + sr = new StreamReader(file); + + string line; + string delim = "\t \n\r\v"; + string split = "="; + + while ( (line = sr.ReadLine()) != null ) + { + line = line.Trim(delim.ToCharArray()); + if (line.Length < 1 || line[0] == ';') + { + continue; + } + string [] s = line.Split(split.ToCharArray()); + string key, val = ""; + if (s.GetLength(0) >= 1) + { + key = s[0]; + if (s.GetLength(0) >= 2) + { + for (int i=1; i"); + return; + } + + Config cfg = new Config(); + if (!cfg.ReadFromFile(args[0])) + { + return; + } + + /* :TODO: Add path validation */ + + ABuilder bld = null; + + if (cfg.Platform == BasePlatform.Platform_Linux) + { + bld = new LinuxBuilder(cfg); + } + else if (cfg.Platform == BasePlatform.Platform_Windows) + { + bld = new Win32Builder(cfg); + } + + bld.BuildPackage(new PkgCore()); + } + } +} diff --git a/tools/builder/Package.cs b/tools/builder/Package.cs new file mode 100644 index 00000000..a9965d52 --- /dev/null +++ b/tools/builder/Package.cs @@ -0,0 +1,51 @@ +using System; + +namespace builder +{ + public class Library + { + public Library() + { + PlatformExt = false; + ProjectFile = null; + IsExecutable = false; + ReleaseBuild = "Release"; + } + public string Name; /* Name of binary */ + public string LocalPath; /* Local path to library build scripts */ + public string ReleaseBuild; /* Release build name */ + public string Destination; /* Final relative path */ + public bool PlatformExt; /* Extra platform extension */ + public string ProjectFile; /* Project file, NULL for standard */ + public bool IsExecutable; /* If this is an EXE instead of a DLL */ + //string DebugBuild; /* Debug build name */ + }; + + public abstract class Package + { + /** + * Must return the base package folder. + */ + public abstract string GetBaseFolder(); + + /** + * Must return the list of folders to create. + */ + public abstract string [] GetFolders(); + + /** + * Called when file to file copies must be performed + */ + public abstract void OnCopyFiles(); + + /** + * Called when dir to dir copies must be performed + */ + public abstract void OnCopyFolders(ABuilder builder); + + /** + * Called to build libraries + */ + public abstract Library [] GetLibraries(); + } +} diff --git a/tools/builder/PkgCore.cs b/tools/builder/PkgCore.cs new file mode 100644 index 00000000..35cd3e28 --- /dev/null +++ b/tools/builder/PkgCore.cs @@ -0,0 +1,96 @@ +using System; + +namespace builder +{ + public class PkgCore : Package + { + public PkgCore() + { + } + + public override string GetBaseFolder() + { + return "base/addons/sourcemod"; + } + + /** + * Must return the list of folders to create. + */ + public override string [] GetFolders() + { + string [] folders = new string[7]; + + folders[0] = "bin"; + folders[1] = "plugins/disabled"; + folders[2] = "configs"; + folders[3] = "translations"; + folders[4] = "logs"; + folders[5] = "extensions"; + folders[6] = "scripting/include"; + + return folders; + } + + /** + * Called when file to file copies must be performed + */ + public override void OnCopyFiles() + { + } + + /** + * Called when dir to dir copies must be performed + */ + public override void OnCopyFolders(ABuilder builder) + { + builder.CopyFolder(this, "configs", "configs", null); + + string [] plugin_omits = new string[1]; + plugin_omits[0] = "spcomp.exe"; + + builder.CopyFolder(this, "plugins", "scripting", plugin_omits); + builder.CopyFolder(this, "plugins/include", "scripting/include", null); + builder.CopyFolder(this, "translations", "translations", null); + } + + /** + * Called to build libraries + */ + public override Library [] GetLibraries() + { + Library [] libs = new Library[5]; + + for (int i=0; i + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/builder/builder.sln b/tools/builder/builder.sln new file mode 100644 index 00000000..a621b833 --- /dev/null +++ b/tools/builder/builder.sln @@ -0,0 +1,23 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "builder", "builder.csproj", "{BFC4EB78-4C3E-4C81-8EAD-5A1A2F126512}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {BFC4EB78-4C3E-4C81-8EAD-5A1A2F126512}.Debug.ActiveCfg = Debug|.NET + {BFC4EB78-4C3E-4C81-8EAD-5A1A2F126512}.Debug.Build.0 = Debug|.NET + {BFC4EB78-4C3E-4C81-8EAD-5A1A2F126512}.Release.ActiveCfg = Release|.NET + {BFC4EB78-4C3E-4C81-8EAD-5A1A2F126512}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal