Added support for Mac OS X and building with clang (bug 5601, r=dvander).

This commit is contained in:
Scott Ehlert
2013-02-13 01:14:37 -06:00
parent b0fe6c83e2
commit 40c1fee55a
191 changed files with 3835 additions and 1946 deletions

View File

@ -2,7 +2,7 @@
; Licensed under the GNU General Public License
; Originally written by -=HaXoMaTiC=-
!define PRODUCT_NAME "AMX Mod X Installer"
!define PRODUCT_VERSION "1.8.1"
!define PRODUCT_VERSION "1.8.2"
!define PRODUCT_PUBLISHER "AMX Mod X Dev Team"
!define PRODUCT_WEB_SITE "http://www.amxmodx.org/"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\Installer.exe"
@ -149,29 +149,41 @@ Section "MainSection" SEC01
File "installer\files\base\addons\amxmodx\data\lang\timeleft.txt"
SetOutPath "$INSTDIR\files\base\dlls"
File "installer\files\base\addons\amxmodx\dlls\amxmodx_mm.dll"
File "installer\files\base\addons\amxmodx\dlls\amxmodx_mm.dylib"
File "installer\files\base\addons\amxmodx\dlls\amxmodx_mm_i386.so"
File "installer\files\base\addons\amxmodx\dlls\metamod.dll"
File "installer\files\base\addons\amxmodx\dlls\metamod_i386.so"
File "installer\files\base\addons\amxmodx\dlls\metamod.dylib"
File "installer\files\base\addons\amxmodx\dlls\metamod.so"
SetOutPath "$INSTDIR\files\base\modules"
File "installer\files\base\addons\amxmodx\modules\nvault_amxx.dll"
File "installer\files\base\addons\amxmodx\modules\nvault_amxx.dylib"
File "installer\files\base\addons\amxmodx\modules\nvault_amxx_i386.so"
File "installer\files\base\addons\amxmodx\modules\engine_amxx.dll"
File "installer\files\base\addons\amxmodx\modules\engine_amxx.dylib"
File "installer\files\base\addons\amxmodx\modules\engine_amxx_i386.so"
File "installer\files\base\addons\amxmodx\modules\fakemeta_amxx.dll"
File "installer\files\base\addons\amxmodx\modules\fakemeta_amxx.dylib"
File "installer\files\base\addons\amxmodx\modules\fakemeta_amxx_i386.so"
File "installer\files\base\addons\amxmodx\modules\fun_amxx.dll"
File "installer\files\base\addons\amxmodx\modules\fun_amxx.dylib"
File "installer\files\base\addons\amxmodx\modules\fun_amxx_i386.so"
File "installer\files\base\addons\amxmodx\modules\geoip_amxx.dll"
File "installer\files\base\addons\amxmodx\modules\geoip_amxx.dylib"
File "installer\files\base\addons\amxmodx\modules\geoip_amxx_i386.so"
File "installer\files\base\addons\amxmodx\modules\sqlite_amxx.dll"
File "installer\files\base\addons\amxmodx\modules\sqlite_amxx.dylib"
File "installer\files\base\addons\amxmodx\modules\sqlite_amxx_i386.so"
File "installer\files\base\addons\amxmodx\modules\mysql_amxx.dll"
File "installer\files\base\addons\amxmodx\modules\mysql_amxx.dylib"
File "installer\files\base\addons\amxmodx\modules\mysql_amxx_i386.so"
File "installer\files\base\addons\amxmodx\modules\regex_amxx.dll"
File "installer\files\base\addons\amxmodx\modules\regex_amxx.dylib"
File "installer\files\base\addons\amxmodx\modules\regex_amxx_i386.so"
File "installer\files\base\addons\amxmodx\modules\sockets_amxx.dll"
File "installer\files\base\addons\amxmodx\modules\sockets_amxx.dylib"
File "installer\files\base\addons\amxmodx\modules\sockets_amxx_i386.so"
File "installer\files\base\addons\amxmodx\modules\hamsandwich_amxx.dll"
File "installer\files\base\addons\amxmodx\modules\hamsandwich_amxx.dylib"
File "installer\files\base\addons\amxmodx\modules\hamsandwich_amxx_i386.so"
SetOutPath "$INSTDIR\files\base\plugins"
File "installer\files\base\addons\amxmodx\plugins\admin.amxx"
@ -207,7 +219,9 @@ Section "MainSection" SEC01
File "installer\files\base\addons\amxmodx\scripting\amxxpc"
File "installer\files\base\addons\amxmodx\scripting\amxxpc.exe"
File "installer\files\base\addons\amxmodx\scripting\amxxpc32.dll"
File "installer\files\base\addons\amxmodx\scripting\amxxpc32.dylib"
File "installer\files\base\addons\amxmodx\scripting\amxxpc32.so"
File "installer\files\base\addons\amxmodx\scripting\amxxpc_osx"
File "installer\files\base\addons\amxmodx\scripting\antiflood.sma"
File "installer\files\base\addons\amxmodx\scripting\cmdmenu.sma"
File "installer\files\base\addons\amxmodx\scripting\compile.exe"
@ -332,8 +346,10 @@ Section "MainSection" SEC01
File "installer\files\cstrike\addons\amxmodx\data\WinCSX.exe"
SetOutPath "$INSTDIR\files\cstrike\modules"
File "installer\files\cstrike\addons\amxmodx\modules\cstrike_amxx.dll"
File "installer\files\cstrike\addons\amxmodx\modules\cstrike_amxx.dylib"
File "installer\files\cstrike\addons\amxmodx\modules\cstrike_amxx_i386.so"
File "installer\files\cstrike\addons\amxmodx\modules\csx_amxx.dll"
File "installer\files\cstrike\addons\amxmodx\modules\csx_amxx.dylib"
File "installer\files\cstrike\addons\amxmodx\modules\csx_amxx_i386.so"
SetOutPath "$INSTDIR\files\cstrike\plugins"
File "installer\files\cstrike\addons\amxmodx\plugins\miscstats.amxx"
@ -356,8 +372,10 @@ Section "MainSection" SEC01
File "installer\files\dod\addons\amxmodx\data\dodstats.amxx"
SetOutPath "$INSTDIR\files\dod\modules"
File "installer\files\dod\addons\amxmodx\modules\dodfun_amxx.dll"
File "installer\files\dod\addons\amxmodx\modules\dodfun_amxx.dylib"
File "installer\files\dod\addons\amxmodx\modules\dodfun_amxx_i386.so"
File "installer\files\dod\addons\amxmodx\modules\dodx_amxx.dll"
File "installer\files\dod\addons\amxmodx\modules\dodx_amxx.dylib"
File "installer\files\dod\addons\amxmodx\modules\dodx_amxx_i386.so"
SetOutPath "$INSTDIR\files\dod\plugins"
File "installer\files\dod\addons\amxmodx\plugins\plmenu.amxx"
@ -415,6 +433,7 @@ Section "MainSection" SEC01
File "installer\files\tfc\addons\amxmodx\data\tfcstats.amxx"
SetOutPath "$INSTDIR\files\tfc\modules"
File "installer\files\tfc\addons\amxmodx\modules\tfcx_amxx.dll"
File "installer\files\tfc\addons\amxmodx\modules\tfcx_amxx.dylib"
File "installer\files\tfc\addons\amxmodx\modules\tfcx_amxx_i386.so"
SetOutPath "$INSTDIR\files\tfc\plugins"
File "installer\files\tfc\addons\amxmodx\plugins\plmenu.amxx"
@ -527,6 +546,7 @@ Section Uninstall
Delete "$INSTDIR\files\tfc\plugins\stats.amxx"
Delete "$INSTDIR\files\tfc\plugins\plmenu.amxx"
Delete "$INSTDIR\files\tfc\modules\tfcx_amxx_i386.so"
Delete "$INSTDIR\files\tfc\modules\tfcx_amxx.dylib"
Delete "$INSTDIR\files\tfc\modules\tfcx_amxx.dll"
Delete "$INSTDIR\files\tfc\data\tfcstats.amxx"
Delete "$INSTDIR\files\tfc\configs\plugins.ini"
@ -567,8 +587,10 @@ Section Uninstall
Delete "$INSTDIR\files\dod\plugins\stats.amxx"
Delete "$INSTDIR\files\dod\plugins\plmenu.amxx"
Delete "$INSTDIR\files\dod\modules\dodx_amxx_i386.so"
Delete "$INSTDIR\files\dod\modules\dodx_amxx.dylib"
Delete "$INSTDIR\files\dod\modules\dodx_amxx.dll"
Delete "$INSTDIR\files\dod\modules\dodfun_amxx_i386.so"
Delete "$INSTDIR\files\dod\modules\dodfun_amxx.dylib"
Delete "$INSTDIR\files\dod\modules\dodfun_amxx.dll"
Delete "$INSTDIR\files\dod\data\dodstats.amxx"
Delete "$INSTDIR\files\dod\configs\plugins.ini"
@ -586,11 +608,13 @@ Section Uninstall
Delete "$INSTDIR\files\cstrike\plugins\restmenu.amxx"
Delete "$INSTDIR\files\cstrike\plugins\miscstats.amxx"
Delete "$INSTDIR\files\cstrike\modules\csx_amxx_i386.so"
Delete "$INSTDIR\files\cstrike\modules\csx_amxx.dylib"
Delete "$INSTDIR\files\cstrike\modules\csx_amxx.dll"
Delete "$INSTDIR\files\cstrike\modules\cstrike_amxx_i386.so"
Delete "$INSTDIR\files\cstrike\modules\cstrike_amxx.dylib"
Delete "$INSTDIR\files\cstrike\modules\cstrike_amxx.dll"
Delete "$INSTDIR\files\cstrike\data\csstats.amxx"
Delete "$INSTDIR\files\cstrike\data\WinCSX.amxx"
Delete "$INSTDIR\files\cstrike\data\WinCSX.exe"
Delete "$INSTDIR\files\cstrike\configs\stats.ini"
Delete "$INSTDIR\files\cstrike\configs\plugins.ini"
Delete "$INSTDIR\files\cstrike\configs\modules.ini"
@ -706,7 +730,9 @@ Section Uninstall
Delete "$INSTDIR\files\base\addons\amxmodx\scripting\compile.exe"
Delete "$INSTDIR\files\base\addons\amxmodx\scripting\cmdmenu.sma"
Delete "$INSTDIR\files\base\addons\amxmodx\scripting\antiflood.sma"
Delete "$INSTDIR\files\base\addons\amxmodx\scripting\amxxpc_osx"
Delete "$INSTDIR\files\base\addons\amxmodx\scripting\amxxpc32.so"
Delete "$INSTDIR\files\base\addons\amxmodx\scripting\amxxpc32.dylib"
Delete "$INSTDIR\files\base\addons\amxmodx\scripting\amxxpc32.dll"
Delete "$INSTDIR\files\base\addons\amxmodx\scripting\amxxpc.exe"
Delete "$INSTDIR\files\base\addons\amxmodx\scripting\amxxpc"
@ -739,28 +765,40 @@ Section Uninstall
Delete "$INSTDIR\files\base\plugins\adminchat.amxx"
Delete "$INSTDIR\files\base\plugins\admin.amxx"
Delete "$INSTDIR\files\base\modules\nvault_amxx_i386.so"
Delete "$INSTDIR\files\base\modules\nvault_amxx.dylib"
Delete "$INSTDIR\files\base\modules\nvault_amxx.dll"
Delete "$INSTDIR\files\base\modules\sockets_amxx_i386.so"
Delete "$INSTDIR\files\base\modules\sockets_amxx.dylib"
Delete "$INSTDIR\files\base\modules\sockets_amxx.dll"
Delete "$INSTDIR\files\base\modules\regex_amxx_i386.so"
Delete "$INSTDIR\files\base\modules\regex_amxx.dylib"
Delete "$INSTDIR\files\base\modules\regex_amxx.dll"
Delete "$INSTDIR\files\base\modules\sqlite_amxx_i386.so"
Delete "$INSTDIR\files\base\modules\sqlite_amxx.dylib"
Delete "$INSTDIR\files\base\modules\sqlite_amxx.dll"
Delete "$INSTDIR\files\base\modules\mysql_amxx_i386.so"
Delete "$INSTDIR\files\base\modules\mysql_amxx.dylib"
Delete "$INSTDIR\files\base\modules\mysql_amxx.dll"
Delete "$INSTDIR\files\base\modules\geoip_amxx_i386.so"
Delete "$INSTDIR\files\base\modules\geoip_amxx.dylib"
Delete "$INSTDIR\files\base\modules\geoip_amxx.dll"
Delete "$INSTDIR\files\base\modules\fun_amxx_i386.so"
Delete "$INSTDIR\files\base\modules\fun_amxx.dylib"
Delete "$INSTDIR\files\base\modules\fun_amxx.dll"
Delete "$INSTDIR\files\base\modules\fakemeta_amxx_i386.so"
Delete "$INSTDIR\files\base\modules\fakemeta_amxx.dylib"
Delete "$INSTDIR\files\base\modules\fakemeta_amxx.dll"
Delete "$INSTDIR\files\base\modules\engine_amxx_i386.so"
Delete "$INSTDIR\files\base\modules\engine_amxx.dylib"
Delete "$INSTDIR\files\base\modules\engine_amxx.dll"
Delete "$INSTDIR\files\base\modules\hamsandwich_amxx_i386.so"
Delete "$INSTDIR\files\base\modules\hamsandwich_amxx.dylib"
Delete "$INSTDIR\files\base\modules\hamsandwich_amxx.dll"
Delete "$INSTDIR\files\base\dlls\metamod_i386.so"
Delete "$INSTDIR\files\base\dlls\metamod.so"
Delete "$INSTDIR\files\base\dlls\metamod.dylib"
Delete "$INSTDIR\files\base\dlls\metamod.dll"
Delete "$INSTDIR\files\base\dlls\amxmodx_mm_i386.so"
Delete "$INSTDIR\files\base\dlls\amxmodx_mm.dylib"
Delete "$INSTDIR\files\base\dlls\amxmodx_mm.dll"
Delete "$INSTDIR\files\base\data\lang\timeleft.txt"
Delete "$INSTDIR\files\base\data\lang\time.txt"

View File

@ -17,21 +17,25 @@ namespace AMXXRelease
CoreMod core = new CoreMod();
ModCstrike cstrike = new ModCstrike();
ModDoD dod = new ModDoD();
ModTFC tfc = new ModTFC();
m_Mods.Add(core);
m_Mods.Add(cstrike);
ModDoD dod = new ModDoD();
ModEsf esf = new ModEsf();
ModNs ns = new ModNs();
ModTFC tfc = new ModTFC();
ModTs ts = new ModTs();
m_Mods.Add(dod);
m_Mods.Add(esf);
m_Mods.Add(ns);
m_Mods.Add(tfc);
m_Mods.Add(ts);
// These mods don't have OS X builds
if (!Releaser.IsOSX)
{
ModEsf esf = new ModEsf();
ModNs ns = new ModNs();
ModTs ts = new ModTs();
m_Mods.Add(esf);
m_Mods.Add(ns);
m_Mods.Add(ts);
}
}
public virtual int GetMods()

View File

@ -31,14 +31,17 @@ namespace AMXXRelease
public override sealed bool ExcludeCopy(string file)
{
if ( ((file.IndexOf(".so")!=-1) || (ABuilder.GetFileName(file).CompareTo("amxxpc")==0))
&& (Releaser.IsWindows) )
&& (Releaser.IsWindows || Releaser.IsOSX) )
return true;
if ( ((file.IndexOf(".dylib")!=-1) || (ABuilder.GetFileName(file).CompareTo("amxxpc_osx")==0))
&& (!Releaser.IsOSX) )
return true;
if ( (file.IndexOf(".sh")!=-1) && Releaser.IsWindows )
return true;
if ( ((file.IndexOf(".exe")!=-1) || (file.IndexOf(".dll")!=-1))
&& (!Releaser.IsWindows) )
return true;
if ( (file.IndexOf("dlsym")!=-1) && Releaser.IsWindows )
if ( (file.IndexOf("dlsym")!=-1) && (Releaser.IsWindows || Releaser.IsOSX) )
return true;
if (ABuilder.GetFileName(file).CompareTo("svn_version.tpl") == 0)
{

View File

@ -39,7 +39,7 @@ namespace AMXXRelease
c.Close();
info.Arguments = "zcvf \"" + target + ".tar.gz\" " + file_list;
info.Arguments = "zcvf \"" + target + "-linux.tar.gz\" " + file_list;
info.UseShellExecute = false;
Process p = Process.Start(info);

View File

@ -0,0 +1,111 @@
using System;
using System.Diagnostics;
using System.IO;
namespace AMXXRelease
{
//Build process for Mac OS X
public class MacBuilder : ABuilder
{
private string m_AmxxPc;
public override void OnBuild()
{
m_AmxxPc = PropSlashes(m_Cfg.GetSourceTree() + "/plugins/amxxpc_osx");
}
public override void CompressDir(string target, string dir)
{
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = m_Cfg.CompressPath();
info.WorkingDirectory = dir;
string [] files = Directory.GetFiles(dir);
string file_list = "";
for (int i=0; i<files.Length; i++)
file_list += GetFileName(files[i]) + " ";
files = Directory.GetDirectories(dir);
for (int i=0; i<files.Length; i++)
file_list += GetFileName(files[i]) + " ";
ProcessStartInfo chmod = new ProcessStartInfo();
chmod.FileName = "/bin/chmod";
chmod.WorkingDirectory = dir;
chmod.Arguments = "-R 755 " + file_list;
chmod.UseShellExecute = false;
Process c = Process.Start(chmod);
c.WaitForExit();
c.Close();
info.Arguments = "-r \"" + target + "-mac.zip\" " + ".";
info.UseShellExecute = false;
Process p = Process.Start(info);
p.WaitForExit();
p.Close();
}
public override void AmxxPc(string inpath, string args)
{
ProcessStartInfo info = new ProcessStartInfo();
info.WorkingDirectory = PropSlashes(m_Cfg.GetSourceTree() + "\\plugins");
info.FileName = (string)m_AmxxPc.Clone();
info.Arguments = inpath + ".sma";
if (args != null)
info.Arguments += " " + args;
info.UseShellExecute = false;
Process p = Process.Start(info);
p.WaitForExit();
p.Close();
}
public override string GetLibExt()
{
return ".dylib";
}
public override string BuildModule(Module module)
{
ProcessStartInfo info = new ProcessStartInfo();
string dir = m_Cfg.GetSourceTree() + "\\" + module.sourcedir;
string file = dir;
file += "\\" + "Release" + "\\" + module.projname + GetLibExt();
file = PropSlashes(file);
if (File.Exists(file))
File.Delete(file);
Console.WriteLine(PropSlashes(dir));
info.WorkingDirectory = PropSlashes(dir);
info.FileName = m_Cfg.DevenvPath();
info.Arguments = "clean";
info.UseShellExecute = false;
Process p = Process.Start(info);
p.WaitForExit();
p.Close();
info.WorkingDirectory = PropSlashes(dir);
info.FileName = m_Cfg.DevenvPath();
info.Arguments = m_Cfg.MakeOpts();
info.UseShellExecute = false;
p = Process.Start(info);
p.WaitForExit();
p.Close();
if (!File.Exists(file))
{
Console.WriteLine("Output file failed: " + file);
return null;
}
return file;
}
}
}

View File

@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
namespace AMXXRelease
{
@ -13,6 +14,7 @@ namespace AMXXRelease
{
private Config m_Cfg;
public static bool IsWindows;
public static bool IsOSX;
[STAThread]
static void Main(string[] args)
@ -47,13 +49,21 @@ namespace AMXXRelease
}
ABuilder builder = null;
if (System.Environment.OSVersion.Platform == System.PlatformID.Unix)
if (IsMacOSX())
{
builder = new MacBuilder();
Releaser.IsWindows = false;
Releaser.IsOSX = true;
}
else if (System.Environment.OSVersion.Platform == System.PlatformID.Unix)
{
builder = new LinuxBuilder();
Releaser.IsWindows = false;
Releaser.IsOSX = false;
} else {
builder = new Win32Builder();
Releaser.IsWindows = true;
Releaser.IsOSX = false;
}
Build build = new Build(m_Cfg);
@ -96,6 +106,40 @@ namespace AMXXRelease
return true;
}
[DllImport("libc")]
static extern int uname(IntPtr buf);
// Environment.OSVersion.Platform returns PlatformID.Unix under Mono on OS X
// Code adapted from Mono: mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs
private bool IsMacOSX()
{
IntPtr buf = IntPtr.Zero;
try
{
// The size of the utsname struct varies from system to system, but this _seems_ more than enough
buf = Marshal.AllocHGlobal(4096);
if (uname(buf) == 0)
{
string sys = Marshal.PtrToStringAnsi(buf);
if (sys == "Darwin")
return true;
}
}
catch
{
// Do nothing
}
finally
{
if (buf != IntPtr.Zero)
Marshal.FreeHGlobal(buf);
}
return false;
}
}
}

View File

@ -1,4 +1,4 @@
#(C)2004-2008 AMX Mod X Development Team
#(C)2004-2013 AMX Mod X Development Team
# Makefile written by David "BAILOPAN" Anderson
### EDIT BELOW FOR OTHER PROJECTS ###
@ -9,7 +9,7 @@ BINARY = $(NAME).exe
OBJECTS = Main.cs Config.cs ABuilder.cs AMod.cs Build.cs Win32Builder.cs LinuxBuilder.cs \
CoreMod.cs ModDoD.cs ModEsf.cs ModCstrike.cs ModTFC.cs \
ModTs.cs ModNs.cs
ModTs.cs ModNs.cs MacBuilder.cs
default: all

View File

@ -20,7 +20,7 @@ namespace AMXXRelease
info.FileName = m_Cfg.CompressPath();
info.WorkingDirectory = dir;
info.Arguments = "-r \"" + target + ".zip\" " + "*.*";
info.Arguments = "-r \"" + target + "-windows.zip\" " + "*.*";
info.UseShellExecute = false;
Process p = Process.Start(info);

View File

@ -48,6 +48,7 @@
<Compile Include="CoreMod.cs" />
<Compile Include="LinuxBuilder.cs" />
<Compile Include="Main.cs" />
<Compile Include="MacBuilder.cs" />
<Compile Include="ModCstrike.cs" />
<Compile Include="ModDoD.cs" />
<Compile Include="ModEsf.cs" />
@ -65,4 +66,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

View File

@ -0,0 +1,6 @@
compress = /usr/bin/zip
source = /Users/Scott/Code/hl/amxmodx-central
makeopts =
output = /Users/Scott/Code/hl/amxmodx-bin
devenv = /usr/bin/make
release = amxmodx-1.8.2