ScriptCompiler should now compile scripts with /optimize flag when -debug is NOT enabled.

This commit is contained in:
asayre 2012-01-02 21:17:48 +00:00
parent b90d8fdb8d
commit 22557eef9f

View file

@ -78,26 +78,29 @@ namespace Server
return list.ToArray(); return list.ToArray();
} }
public static string GetDefines() public static string GetCompilerOptions( bool debug )
{ {
StringBuilder sb = null; StringBuilder sb = null;
if( !debug )
AppendCompilerOption( ref sb, "/optimize" );
#if MONO #if MONO
AppendDefine( ref sb, "/d:MONO" ); AppendDefine( ref sb, "/d:MONO" );
#endif #endif
//These following defines are legacy, ie, depreciated. //These following defines are legacy, ie, depreciated.
if( Core.Is64Bit ) if( Core.Is64Bit )
AppendDefine( ref sb, "/d:x64" ); AppendCompilerOption( ref sb, "/d:x64" );
AppendDefine( ref sb, "/d:Framework_2_0" ); AppendCompilerOption( ref sb, "/d:Framework_2_0" );
AppendDefine( ref sb, "/d:Framework_4_0" ); AppendCompilerOption( ref sb, "/d:Framework_4_0" );
return (sb == null ? null : sb.ToString()); return (sb == null ? null : sb.ToString());
} }
public static void AppendDefine( ref StringBuilder sb, string define ) private static void AppendCompilerOption( ref StringBuilder sb, string define )
{ {
if( sb == null ) if( sb == null )
sb = new StringBuilder(); sb = new StringBuilder();
@ -217,10 +220,10 @@ namespace Server
CompilerParameters parms = new CompilerParameters( GetReferenceAssemblies(), path, debug ); CompilerParameters parms = new CompilerParameters( GetReferenceAssemblies(), path, debug );
string defines = GetDefines(); string options = GetCompilerOptions( debug );
if( defines != null ) if( options != null )
parms.CompilerOptions = defines; parms.CompilerOptions = options;
if( Core.HaltOnWarning ) if( Core.HaltOnWarning )
parms.WarningLevel = 4; parms.WarningLevel = 4;
@ -357,10 +360,10 @@ namespace Server
CompilerParameters parms = new CompilerParameters( GetReferenceAssemblies(), path, debug ); CompilerParameters parms = new CompilerParameters( GetReferenceAssemblies(), path, debug );
string defines = GetDefines(); string options = GetCompilerOptions( debug );
if( defines != null ) if( options != null )
parms.CompilerOptions = String.Format( "/D:{0}", defines ); parms.CompilerOptions = options;
if( Core.HaltOnWarning ) if( Core.HaltOnWarning )
parms.WarningLevel = 4; parms.WarningLevel = 4;