Skip to content

Commit

Permalink
Match higher target player version to sdk version
Browse files Browse the repository at this point in the history
If the specified target player version is higher than the current SDK version,
lower the target player version to match the current SDK version.

Update some code to the new C# 7.0 syntax.

Set the default target player version to 99.0 to target the highest
available version.
  • Loading branch information
wise0704 committed Apr 2, 2017
1 parent 3927850 commit 6e6c2ab
Show file tree
Hide file tree
Showing 16 changed files with 1,825 additions and 1,839 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<movie fps="0" />
<movie width="0" />
<movie height="0" />
<movie version="23" />
<movie version="99" />
<movie minorVersion="0" />
<movie platform="Flash Player" />
<movie background="#FFFFFF" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
An ActionScript 3 library project to compile as a SWC file
An ActionScript 3 library project to compile as a SWC file (SWCBuild)
50 changes: 25 additions & 25 deletions SwcBuild/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@

namespace SwcBuild
{
using static Attribute;
using static Console;
using static Attribute;
using static Console;

internal static class Program
{
{
private static int Main(string[] args)
{
using (var swcBuild = new SwcBuild())
{
int exitCode = (int) swcBuild.Run(args);
WriteLine($"{Assembly.Description} exited with code: {exitCode}");
{
using (var swcBuild = new SwcBuild())
{
int exitCode = (int) swcBuild.Run(args);
WriteLine($"{Assembly.Description} exited with code: {exitCode}");

return exitCode;
}
}
return exitCode;
}
}

internal static class Assembly
{
private static readonly System.Reflection.Assembly assembly = typeof(Program).Assembly;
internal static class Assembly
{
private static readonly System.Reflection.Assembly assembly = typeof(Program).Assembly;

public static string Title { get; } = Get<AssemblyTitleAttribute>().Title;
public static string Description { get; } = Get<AssemblyDescriptionAttribute>().Description;
public static string Configuration { get; } = Get<AssemblyConfigurationAttribute>().Configuration;
public static string Company { get; } = Get<AssemblyCompanyAttribute>().Company;
public static string Product { get; } = Get<AssemblyProductAttribute>().Product;
public static string Copyright { get; } = Get<AssemblyCopyrightAttribute>().Copyright;
public static string Trademark { get; } = Get<AssemblyTrademarkAttribute>().Trademark;
public static Version Version { get; } = assembly.GetName().Version;
public static string Title { get; } = Get<AssemblyTitleAttribute>().Title;
public static string Description { get; } = Get<AssemblyDescriptionAttribute>().Description;
public static string Configuration { get; } = Get<AssemblyConfigurationAttribute>().Configuration;
public static string Company { get; } = Get<AssemblyCompanyAttribute>().Company;
public static string Product { get; } = Get<AssemblyProductAttribute>().Product;
public static string Copyright { get; } = Get<AssemblyCopyrightAttribute>().Copyright;
public static string Trademark { get; } = Get<AssemblyTrademarkAttribute>().Trademark;
public static Version Version { get; } = assembly.GetName().Version;

private static T Get<T>() where T : class => GetCustomAttribute(assembly, typeof(T)) as T;
}
}
private static T Get<T>() where T : class => GetCustomAttribute(assembly, typeof(T)) as T;
}
}
}
6 changes: 3 additions & 3 deletions SwcBuild/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Daniel Jeong")]
[assembly: AssemblyProduct("swcbuild.exe")]
[assembly: AssemblyCopyright("Copyright © Daniel Jeong 2016")]
[assembly: AssemblyCopyright("Copyright © Daniel Jeong 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.0.*")]
[assembly: AssemblyFileVersion("1.5.0.0")]
[assembly: AssemblyVersion("1.5.1.*")]
[assembly: AssemblyFileVersion("1.5.1.0")]
2 changes: 1 addition & 1 deletion SwcBuild/SwcBuild.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<DebugSymbols>false</DebugSymbols>
<UseVSHostingProcess>false</UseVSHostingProcess>
<LangVersion>6</LangVersion>
<LangVersion>default</LangVersion>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
Expand Down
272 changes: 136 additions & 136 deletions SwcBuild/src/ActionScriptCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,154 +3,154 @@

namespace SwcBuild
{
using static Platform;
using static Utilities;
using static Platform;
using static Utilities;

internal class ActionScriptCompiler : CompilerProcess
{
public static ActionScriptCompiler ASC1 => new ActionScriptCompiler(ASCVersions.ASC1);
{
public static ActionScriptCompiler ASC1 => new ActionScriptCompiler(ASCVersions.ASC1);

public static ActionScriptCompiler ASC2 => new ActionScriptCompiler(ASCVersions.ASC2);
public static ActionScriptCompiler ASC2 => new ActionScriptCompiler(ASCVersions.ASC2);

private ActionScriptCompiler(ASCVersions v) : base(true, true)
{
Version = v;
}
{
Version = v;
}

public Version SdkVersion { get; set; }
public Version SdkVersion { get; set; }

public Version TargetPlayer { get; set; }
public Version TargetPlayer { get; set; }

public ASCVersions Version { get; }
public ASCVersions Version { get; }

public bool BuildArguments(BuildOptions options, bool debug, bool incremental, out ExitCodes exitCode)
{
if (string.IsNullOrEmpty(options.Path))
return ErrorHelper.InvalidPathToOutput(out exitCode);

Output = FixOutputPath(options.Path, debug);

string configname = GetConfigname(options.Platform);
//string defaultConfig = Path.Combine(CompilerDirectory, "frameworks", $"{configname}-config.xml");

string[] additional = ParseArguments(options.Additional);
bool isConfignameDefined = false;
bool isSwfVersionDefined = false;

foreach (string argument in additional)
{
if (!isConfignameDefined && argument.Length > 12 && argument.Substring(0, 12) == "+configname=")
{
isConfignameDefined = true;
if (isSwfVersionDefined) break;
continue;
}
if (!isSwfVersionDefined && argument.Length > 13 && argument.Substring(0, 13) == "-swf-version=")
{
isSwfVersionDefined = true;
if (isConfignameDefined) break;
}
}

if (!isConfignameDefined && configname != "flex")
Arguments.Configname = configname;

//if (File.Exists(defaultConfig))
// Arguments.LoadConfig = Q(defaultConfig);

if (File.Exists(options.LoadConfig))
Arguments.LoadConfig = Q(options.LoadConfig);

Arguments.LoadConfig = Q(ConfigFile);

if (debug)
Arguments.Debug = true;

switch (Version)
{
case ASCVersions.ASC1:
if (incremental)
Arguments.Incremental = true;
break;

case ASCVersions.ASC2:
if (options.AdvancedTelemetry)
{
Arguments.AdvancedTelemetry = true;

if (!string.IsNullOrEmpty(options.AdvancedTelemetryPassword))
Arguments.AdvancedTelemetryPassword = Q(options.AdvancedTelemetryPassword);
}

if (options.Inline)
Arguments.Inline = true;
break;
}

if (!string.IsNullOrEmpty(options.LinkReport))
Arguments.LinkReport = options.LinkReport;

if (!string.IsNullOrEmpty(options.LoadExterns))
Arguments.LoadExterns = options.LoadExterns;

if (!isSwfVersionDefined)
{
int swfVersion = ResolveSwfVersion(TargetPlayer, options.Platform != FlashPlayer);

if (swfVersion != -1)
Arguments.SwfVersion = swfVersion;
}

if (options.Classpaths != null)
foreach (string classpath in options.Classpaths)
Arguments.Sources = Q(classpath);

foreach (string arg in additional)
Arguments.Additionals = arg;

Arguments.Output = Q(Output);

exitCode = 0;
return false;
}

public bool Run(out ExitCodes exitCode)
{
try
{
Run(Arguments.CompcArgs);

exitCode = ExitCode == 0 ? 0 : ExitCodes.ErrorRunningCompiler;
return false;
}
catch (Exception e)
{
return ErrorHelper.ErrorRunningCompiler(out exitCode, e);
}
}

public string GetAsDocPath()
{
public bool BuildArguments(BuildOptions options, bool debug, bool incremental, out ExitCodes exitCode)
{
if (string.IsNullOrEmpty(options.Path))
return ErrorHelper.InvalidPathToOutput(out exitCode);

Output = FixOutputPath(options.Path, debug);

string configname = GetConfigname(options.Platform);
//string defaultConfig = Path.Combine(CompilerDirectory, "frameworks", $"{configname}-config.xml");

string[] additional = ParseArguments(options.Additional);
bool isConfignameDefined = false;
bool isSwfVersionDefined = false;

foreach (string argument in additional)
{
if (!isConfignameDefined && argument.Length > 12 && argument.Substring(0, 12) == "+configname=")
{
isConfignameDefined = true;
if (isSwfVersionDefined) break;
continue;
}
if (!isSwfVersionDefined && argument.Length > 13 && argument.Substring(0, 13) == "-swf-version=")
{
isSwfVersionDefined = true;
if (isConfignameDefined) break;
}
}

if (!isConfignameDefined && configname != "flex")
Arguments.Configname = configname;

//if (File.Exists(defaultConfig))
// Arguments.LoadConfig = Q(defaultConfig);

if (File.Exists(options.LoadConfig))
Arguments.LoadConfig = Q(options.LoadConfig);

Arguments.LoadConfig = Q(ConfigFile);

if (debug)
Arguments.Debug = true;

switch (Version)
{
case ASCVersions.ASC1:
if (incremental)
Arguments.Incremental = true;
break;

case ASCVersions.ASC2:
if (options.AdvancedTelemetry)
{
Arguments.AdvancedTelemetry = true;

if (!string.IsNullOrEmpty(options.AdvancedTelemetryPassword))
Arguments.AdvancedTelemetryPassword = Q(options.AdvancedTelemetryPassword);
}

if (options.Inline)
Arguments.Inline = true;
break;
}

if (!string.IsNullOrEmpty(options.LinkReport))
Arguments.LinkReport = options.LinkReport;

if (!string.IsNullOrEmpty(options.LoadExterns))
Arguments.LoadExterns = options.LoadExterns;

if (!isSwfVersionDefined)
{
int swfVersion = ResolveSwfVersion(TargetPlayer, options.Platform != FlashPlayer);

if (swfVersion != -1)
Arguments.SwfVersion = swfVersion;
}

if (options.Classpaths != null)
foreach (string classpath in options.Classpaths)
Arguments.Sources = Q(classpath);

foreach (string arg in additional)
Arguments.Additionals = arg;

Arguments.Output = Q(Output);

exitCode = 0;
return false;
}

public bool Run(out ExitCodes exitCode)
{
try
{
Run(Arguments.CompcArgs);

exitCode = ExitCode == 0 ? 0 : ExitCodes.ErrorRunningCompiler;
return false;
}
catch (Exception e)
{
return ErrorHelper.ErrorRunningCompiler(out exitCode, e);
}
}

public string GetAsDocPath()
{
string path = Path.Combine(Path.GetDirectoryName(CompilerPath), String.AsDoc);

switch (Version)
{
case ASCVersions.ASC1:
return $"{path}{String.Exe}";
case ASCVersions.ASC2:
return $"{path}{String.Bat}";
default:
return null;
}
}
switch (Version)
{
case ASCVersions.ASC1:
return $"{path}{String.Exe}";
case ASCVersions.ASC2:
return $"{path}{String.Bat}";
default:
return null;
}
}

private static string Q(string text) => WrapWithQuotes(text);
}
private static string Q(string text) => WrapWithQuotes(text);
}

internal enum ASCVersions
{
None,
ASC1,
ASC2,
}
{
None,
ASC1,
ASC2,
}
}
Loading

0 comments on commit 6e6c2ab

Please sign in to comment.