Added compression support
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40409
This commit is contained in:
parent
0234b51a9f
commit
7a8d164b25
@ -12,8 +12,48 @@ namespace builder
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract string CompressPackage(Package pkg);
|
||||||
|
|
||||||
public abstract bool BuildLibrary(Package pkg, Library lib, ref string _binName, ref string _binPath);
|
public abstract bool BuildLibrary(Package pkg, Library lib, ref string _binName, ref string _binPath);
|
||||||
|
|
||||||
|
public string GetRevsionOfPath(string path)
|
||||||
|
{
|
||||||
|
ProcessStartInfo info = new ProcessStartInfo();
|
||||||
|
|
||||||
|
info.WorkingDirectory = path;
|
||||||
|
info.FileName = cfg.SVNVersion;
|
||||||
|
info.Arguments = "--committed " + path;
|
||||||
|
info.UseShellExecute = false;
|
||||||
|
info.RedirectStandardOutput = true;
|
||||||
|
|
||||||
|
Process p = Process.Start(info);
|
||||||
|
string output = p.StandardOutput.ReadToEnd();
|
||||||
|
p.WaitForExit();
|
||||||
|
p.Close();
|
||||||
|
|
||||||
|
string [] revs = output.Split(":".ToCharArray(), 2);
|
||||||
|
if (revs.Length < 1)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
string rev = null;
|
||||||
|
if (revs.Length == 1)
|
||||||
|
{
|
||||||
|
rev = revs[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rev = revs[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
rev = rev.Trim();
|
||||||
|
rev = rev.Replace("M", "");
|
||||||
|
rev = rev.Replace("S", "");
|
||||||
|
|
||||||
|
return rev;
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateRevisionInfo(Package pkg, Library lib)
|
public void UpdateRevisionInfo(Package pkg, Library lib)
|
||||||
{
|
{
|
||||||
string path = Config.PathFormat("{0}/{1}", cfg.SourceBase, lib.LocalPath);
|
string path = Config.PathFormat("{0}/{1}", cfg.SourceBase, lib.LocalPath);
|
||||||
@ -25,13 +65,63 @@ namespace builder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateRevisionInfo(string path, string file)
|
||||||
|
{
|
||||||
|
string vers = cfg.ProductVersion.Replace(".", ",");
|
||||||
|
string rev = GetRevsionOfPath(path);
|
||||||
|
|
||||||
|
File.Delete(file);
|
||||||
|
StreamWriter sw = File.CreateText(file);
|
||||||
|
|
||||||
|
sw.WriteLine("/** This file is autogenerated by build scripts */");
|
||||||
|
sw.WriteLine("");
|
||||||
|
sw.WriteLine("#ifndef _INCLUDE_SVN_VERSION_H_");
|
||||||
|
sw.WriteLine("#define _INCLUDE_SVN_VERSION_H_");
|
||||||
|
sw.WriteLine("");
|
||||||
|
sw.WriteLine("#define SVN_REVISION {0}", rev);
|
||||||
|
sw.WriteLine("#define SVN_REVISION_STRING \"{0}\"", rev);
|
||||||
|
sw.WriteLine("#define SVN_FILE_VERSION {0},{1}", vers, rev);
|
||||||
|
sw.WriteLine("");
|
||||||
|
sw.WriteLine("#endif //_INCLUDE_SVN_VERSION_H_");
|
||||||
|
sw.WriteLine("");
|
||||||
|
|
||||||
|
sw.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CopyFile(Package pkg, string source, string dest)
|
||||||
|
{
|
||||||
|
string from = Config.PathFormat("{0}/{1}",
|
||||||
|
cfg.SourceBase,
|
||||||
|
source);
|
||||||
|
string to = Config.PathFormat("{0}/{1}/{2}",
|
||||||
|
cfg.OutputBase,
|
||||||
|
pkg.GetBaseFolder(),
|
||||||
|
dest);
|
||||||
|
|
||||||
|
File.Copy(from, to, true);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** dest can be null to mean root base folder */
|
||||||
public void CopyFolder(Package pkg, string source, string dest, string [] omits)
|
public void CopyFolder(Package pkg, string source, string dest, string [] omits)
|
||||||
{
|
{
|
||||||
string from_base = Config.PathFormat("{0}/{1}", cfg.SourceBase, source);
|
string from_base = Config.PathFormat("{0}/{1}", cfg.SourceBase, source);
|
||||||
string to_base = Config.PathFormat("{0}/{1}/{2}",
|
string to_base = null;
|
||||||
cfg.OutputBase,
|
|
||||||
pkg.GetBaseFolder(),
|
if (dest == null)
|
||||||
dest);
|
{
|
||||||
|
to_base = Config.PathFormat("{0}/{1}",
|
||||||
|
cfg.OutputBase,
|
||||||
|
pkg.GetBaseFolder());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
to_base = Config.PathFormat("{0}/{1}/{2}",
|
||||||
|
cfg.OutputBase,
|
||||||
|
pkg.GetBaseFolder(),
|
||||||
|
dest);
|
||||||
|
}
|
||||||
|
|
||||||
string [] files = Directory.GetFiles(from_base);
|
string [] files = Directory.GetFiles(from_base);
|
||||||
string file;
|
string file;
|
||||||
@ -61,59 +151,15 @@ namespace builder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateRevisionInfo(string path, string file)
|
public string PackageBuildName(Package pkg)
|
||||||
{
|
{
|
||||||
ProcessStartInfo info = new ProcessStartInfo();
|
return pkg.GetPackageName()
|
||||||
|
+ "-"
|
||||||
info.WorkingDirectory = path;
|
+ DateTime.Now.Day.ToString("00")
|
||||||
info.FileName = cfg.SVNVersion;
|
+ DateTime.Now.Month.ToString("00")
|
||||||
info.Arguments = "--committed " + path;
|
+ DateTime.Now.Year
|
||||||
info.UseShellExecute = false;
|
+ "-r"
|
||||||
info.RedirectStandardOutput = true;
|
+ GetRevsionOfPath(cfg.SourceBase);
|
||||||
|
|
||||||
Process p = Process.Start(info);
|
|
||||||
string output = p.StandardOutput.ReadToEnd();
|
|
||||||
p.WaitForExit();
|
|
||||||
p.Close();
|
|
||||||
|
|
||||||
string [] revs = output.Split(":".ToCharArray(), 2);
|
|
||||||
if (revs.Length < 1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string rev = null;
|
|
||||||
if (revs.Length == 1)
|
|
||||||
{
|
|
||||||
rev = revs[0];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rev = revs[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
rev = rev.Trim();
|
|
||||||
rev = rev.Replace("M", "");
|
|
||||||
rev = rev.Replace("S", "");
|
|
||||||
|
|
||||||
string vers = cfg.ProductVersion.Replace(".", ",");
|
|
||||||
|
|
||||||
File.Delete(file);
|
|
||||||
StreamWriter sw = File.CreateText(file);
|
|
||||||
|
|
||||||
sw.WriteLine("/** This file is autogenerated by build scripts */");
|
|
||||||
sw.WriteLine("");
|
|
||||||
sw.WriteLine("#ifndef _INCLUDE_SVN_VERSION_H_");
|
|
||||||
sw.WriteLine("#define _INCLUDE_SVN_VERSION_H_");
|
|
||||||
sw.WriteLine("");
|
|
||||||
sw.WriteLine("#define SVN_REVISION {0}", rev);
|
|
||||||
sw.WriteLine("#define SVN_REVISION_STRING \"{0}\"", rev);
|
|
||||||
sw.WriteLine("#define SVN_FILE_VERSION {0},{1}", vers, rev);
|
|
||||||
sw.WriteLine("");
|
|
||||||
sw.WriteLine("#endif //_INCLUDE_SVN_VERSION_H_");
|
|
||||||
sw.WriteLine("");
|
|
||||||
|
|
||||||
sw.Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BuildPackage(Package pkg)
|
public void BuildPackage(Package pkg)
|
||||||
@ -138,7 +184,7 @@ namespace builder
|
|||||||
|
|
||||||
/* Do primitive copies */
|
/* Do primitive copies */
|
||||||
pkg.OnCopyFolders(this);
|
pkg.OnCopyFolders(this);
|
||||||
pkg.OnCopyFiles();
|
pkg.OnCopyFiles(this);
|
||||||
|
|
||||||
/* Do libraries */
|
/* Do libraries */
|
||||||
Library [] libs = pkg.GetLibraries();
|
Library [] libs = pkg.GetLibraries();
|
||||||
@ -160,6 +206,27 @@ namespace builder
|
|||||||
throw new System.Exception("Failed to compile library: " + libs[i].Name);
|
throw new System.Exception("Failed to compile library: " + libs[i].Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string pkg_file = null;
|
||||||
|
if ((pkg_file=CompressPackage(pkg)) == null)
|
||||||
|
{
|
||||||
|
throw new System.Exception("Failed to compress package: " + pkg.GetPackageName());
|
||||||
|
}
|
||||||
|
|
||||||
|
string lpath = null, ltarget = null;
|
||||||
|
pkg.GetCompressBases(ref lpath, ref ltarget);
|
||||||
|
lpath = Config.PathFormat("{0}/{1}/{2}",
|
||||||
|
cfg.OutputBase,
|
||||||
|
lpath,
|
||||||
|
pkg_file);
|
||||||
|
ltarget = Config.PathFormat("{0}/{1}", cfg.OutputBase, pkg_file);
|
||||||
|
|
||||||
|
if (File.Exists(ltarget))
|
||||||
|
{
|
||||||
|
File.Delete(ltarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
File.Move(lpath, ltarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,10 @@ namespace builder
|
|||||||
public string SourceBase;
|
public string SourceBase;
|
||||||
public string OutputBase;
|
public string OutputBase;
|
||||||
public string BuilderPath;
|
public string BuilderPath;
|
||||||
public string CompressPath;
|
|
||||||
public string CompressOptions;
|
public string CompressOptions;
|
||||||
public string SVNVersion;
|
public string SVNVersion;
|
||||||
public string ProductVersion;
|
public string ProductVersion;
|
||||||
|
public string Compressor;
|
||||||
public builder.BasePlatform Platform;
|
public builder.BasePlatform Platform;
|
||||||
|
|
||||||
public Config()
|
public Config()
|
||||||
@ -84,10 +84,6 @@ namespace builder
|
|||||||
{
|
{
|
||||||
BuilderPath = val;
|
BuilderPath = val;
|
||||||
}
|
}
|
||||||
else if (key.CompareTo("CompressPath") == 0)
|
|
||||||
{
|
|
||||||
CompressPath = val;
|
|
||||||
}
|
|
||||||
else if (key.CompareTo("CompressOptions") == 0)
|
else if (key.CompareTo("CompressOptions") == 0)
|
||||||
{
|
{
|
||||||
CompressOptions = val;
|
CompressOptions = val;
|
||||||
@ -99,6 +95,10 @@ namespace builder
|
|||||||
else if (key.CompareTo("ProductVersion") == 0)
|
else if (key.CompareTo("ProductVersion") == 0)
|
||||||
{
|
{
|
||||||
ProductVersion = val;
|
ProductVersion = val;
|
||||||
|
}
|
||||||
|
else if (key.CompareTo("Compressor") == 0)
|
||||||
|
{
|
||||||
|
Compressor = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,38 @@ namespace builder
|
|||||||
cfg = _cfg;
|
cfg = _cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string CompressPackage(Package pkg)
|
||||||
|
{
|
||||||
|
string lpath = null, ltarget = null;
|
||||||
|
|
||||||
|
pkg.GetCompressBases(ref lpath, ref ltarget);
|
||||||
|
|
||||||
|
string local_dir = Config.PathFormat("{0}/{1}",
|
||||||
|
cfg.OutputBase,
|
||||||
|
lpath);
|
||||||
|
|
||||||
|
string name = PackageBuildName(pkg) + ".tar.gz";
|
||||||
|
|
||||||
|
ProcessStartInfo info = new ProcessStartInfo();
|
||||||
|
info.FileName = cfg.Compressor;
|
||||||
|
info.WorkingDirectory = local_dir;
|
||||||
|
info.Arguments = "zcvf \"" + name + "\" \"" + ltarget + "\"";
|
||||||
|
info.UseShellExecute = false;
|
||||||
|
|
||||||
|
Process p = Process.Start(info);
|
||||||
|
p.WaitForExit();
|
||||||
|
|
||||||
|
local_dir = Config.PathFormat("{0}/{1}", local_dir, name);
|
||||||
|
|
||||||
|
if (!File.Exists(local_dir))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public override bool BuildLibrary(Package pkg, Library lib, ref string _binName, ref string _binPath)
|
public override bool BuildLibrary(Package pkg, Library lib, ref string _binName, ref string _binPath)
|
||||||
{
|
{
|
||||||
ProcessStartInfo info = new ProcessStartInfo();
|
ProcessStartInfo info = new ProcessStartInfo();
|
||||||
|
@ -24,7 +24,12 @@ namespace builder
|
|||||||
public abstract class Package
|
public abstract class Package
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Must return the base package folder.
|
* Must return the root compression point.
|
||||||
|
*/
|
||||||
|
public abstract void GetCompressBases(ref string path, ref string folder);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Must return the base package output folder.
|
||||||
*/
|
*/
|
||||||
public abstract string GetBaseFolder();
|
public abstract string GetBaseFolder();
|
||||||
|
|
||||||
@ -36,7 +41,7 @@ namespace builder
|
|||||||
/**
|
/**
|
||||||
* Called when file to file copies must be performed
|
* Called when file to file copies must be performed
|
||||||
*/
|
*/
|
||||||
public abstract void OnCopyFiles();
|
public abstract void OnCopyFiles(ABuilder builder);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when dir to dir copies must be performed
|
* Called when dir to dir copies must be performed
|
||||||
@ -47,5 +52,10 @@ namespace builder
|
|||||||
* Called to build libraries
|
* Called to build libraries
|
||||||
*/
|
*/
|
||||||
public abstract Library [] GetLibraries();
|
public abstract Library [] GetLibraries();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to get package name
|
||||||
|
*/
|
||||||
|
public abstract string GetPackageName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,17 @@ namespace builder
|
|||||||
return "base/addons/sourcemod";
|
return "base/addons/sourcemod";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void GetCompressBases(ref string path, ref string folder)
|
||||||
|
{
|
||||||
|
path = "base";
|
||||||
|
folder = "addons";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string GetPackageName()
|
||||||
|
{
|
||||||
|
return "sourcemod-core";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Must return the list of folders to create.
|
* Must return the list of folders to create.
|
||||||
*/
|
*/
|
||||||
@ -34,7 +45,7 @@ namespace builder
|
|||||||
/**
|
/**
|
||||||
* Called when file to file copies must be performed
|
* Called when file to file copies must be performed
|
||||||
*/
|
*/
|
||||||
public override void OnCopyFiles()
|
public override void OnCopyFiles(ABuilder builder)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +62,7 @@ namespace builder
|
|||||||
builder.CopyFolder(this, "plugins", "scripting", plugin_omits);
|
builder.CopyFolder(this, "plugins", "scripting", plugin_omits);
|
||||||
builder.CopyFolder(this, "plugins/include", "scripting/include", null);
|
builder.CopyFolder(this, "plugins/include", "scripting/include", null);
|
||||||
builder.CopyFolder(this, "translations", "translations", null);
|
builder.CopyFolder(this, "translations", "translations", null);
|
||||||
|
builder.CopyFolder(this, "public/licenses", null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,6 +11,37 @@ namespace builder
|
|||||||
cfg = _cfg;
|
cfg = _cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string CompressPackage(Package pkg)
|
||||||
|
{
|
||||||
|
string lpath = null, ltarget = null;
|
||||||
|
|
||||||
|
pkg.GetCompressBases(ref lpath, ref ltarget);
|
||||||
|
|
||||||
|
string local_dir = Config.PathFormat("{0}/{1}",
|
||||||
|
cfg.OutputBase,
|
||||||
|
lpath);
|
||||||
|
|
||||||
|
string name = PackageBuildName(pkg) + ".zip";
|
||||||
|
|
||||||
|
ProcessStartInfo info = new ProcessStartInfo();
|
||||||
|
info.FileName = cfg.Compressor;
|
||||||
|
info.WorkingDirectory = local_dir;
|
||||||
|
info.Arguments = "-r \"" + name + "\" \"" + ltarget + "\"";
|
||||||
|
info.UseShellExecute = false;
|
||||||
|
|
||||||
|
Process p = Process.Start(info);
|
||||||
|
p.WaitForExit();
|
||||||
|
|
||||||
|
local_dir = Config.PathFormat("{0}/{1}", local_dir, name);
|
||||||
|
|
||||||
|
if (!File.Exists(local_dir))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
public override bool BuildLibrary(Package pkg, Library lib, ref string _binName, ref string _binPath)
|
public override bool BuildLibrary(Package pkg, Library lib, ref string _binName, ref string _binPath)
|
||||||
{
|
{
|
||||||
ProcessStartInfo info = new ProcessStartInfo();
|
ProcessStartInfo info = new ProcessStartInfo();
|
||||||
|
@ -3,3 +3,4 @@ SourceBase = /home/users/dvander/sourcemod/trunk
|
|||||||
BuilderPath = /usr/bin/make
|
BuilderPath = /usr/bin/make
|
||||||
SVNVersion = /usr/bin/svnversion
|
SVNVersion = /usr/bin/svnversion
|
||||||
ProductVersion = 1.0.0
|
ProductVersion = 1.0.0
|
||||||
|
Compressor = /bin/tar
|
@ -3,3 +3,4 @@ SourceBase = r:\sourcemod\trunk
|
|||||||
BuilderPath = C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.com
|
BuilderPath = C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.com
|
||||||
SVNVersion = C:\Program Files\Subversion\bin\svnversion.exe
|
SVNVersion = C:\Program Files\Subversion\bin\svnversion.exe
|
||||||
ProductVersion = 1.0.0
|
ProductVersion = 1.0.0
|
||||||
|
Compressor = c:\Windows\zip.exe
|
||||||
|
Loading…
Reference in New Issue
Block a user