зеркало из https://github.com/mono/ikvm-fork.git
Added ikvmc -delaysign option.
This commit is contained in:
Родитель
fad2c41c87
Коммит
bcd5fe602a
|
@ -101,6 +101,10 @@ class IkvmcCompiler
|
|||
rc = ResolveReferences(targets);
|
||||
}
|
||||
if (rc == 0)
|
||||
{
|
||||
rc = ResolveStrongNameKeys(targets);
|
||||
}
|
||||
if (rc == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -134,6 +138,70 @@ class IkvmcCompiler
|
|||
return rc;
|
||||
}
|
||||
|
||||
private static int ResolveStrongNameKeys(List<CompilerOptions> targets)
|
||||
{
|
||||
foreach (CompilerOptions options in targets)
|
||||
{
|
||||
if (options.keyfile != null && options.keycontainer != null)
|
||||
{
|
||||
Console.Error.WriteLine("Error: you cannot specify both a key file and container");
|
||||
return 1;
|
||||
}
|
||||
if (options.keyfile == null && options.keycontainer == null && options.delaysign)
|
||||
{
|
||||
Console.Error.WriteLine("Error: you cannot delay sign without a key file or container");
|
||||
return 1;
|
||||
}
|
||||
if (options.keyfile != null)
|
||||
{
|
||||
if (options.delaysign)
|
||||
{
|
||||
byte[] buf;
|
||||
try
|
||||
{
|
||||
buf = File.ReadAllBytes(options.keyfile);
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
Console.Error.WriteLine("Error: unable to read key file: {0}", x.Message);
|
||||
return 1;
|
||||
}
|
||||
try
|
||||
{
|
||||
// maybe it is a key pair, if so we need to extract just the public key
|
||||
buf = new StrongNameKeyPair(buf).PublicKey;
|
||||
}
|
||||
catch { }
|
||||
options.publicKey = buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!SetStrongNameKeyPair(ref options.keyPair, options.keyfile, true))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StrongNameKeyPair keyPair = null;
|
||||
if (!SetStrongNameKeyPair(ref keyPair, options.keycontainer, false))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (options.delaysign)
|
||||
{
|
||||
options.publicKey = keyPair.PublicKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
options.keyPair = keyPair;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static string GetVersionAndCopyrightInfo()
|
||||
{
|
||||
System.Reflection.Assembly asm = System.Reflection.Assembly.GetEntryAssembly();
|
||||
|
@ -171,6 +239,7 @@ class IkvmcCompiler
|
|||
Console.Error.WriteLine(" Itanium, x64, or anycpu. The default is anycpu.");
|
||||
Console.Error.WriteLine(" -keyfile:<keyfilename> Use keyfile to sign the assembly");
|
||||
Console.Error.WriteLine(" -key:<keycontainer> Use keycontainer to sign the assembly");
|
||||
Console.Error.WriteLine(" -delaysign Delay-sign the assembly");
|
||||
Console.Error.WriteLine(" -version:<M.m.b.r> Assembly version");
|
||||
Console.Error.WriteLine(" -fileversion:<version> File version");
|
||||
Console.Error.WriteLine(" -main:<class> Specify the class containing the main method");
|
||||
|
@ -507,17 +576,15 @@ class IkvmcCompiler
|
|||
}
|
||||
else if(s.StartsWith("-keyfile:"))
|
||||
{
|
||||
if (!SetStrongNameKeyPair(ref options.key, s.Substring(9), true))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
options.keyfile = s.Substring(9);
|
||||
}
|
||||
else if(s.StartsWith("-key:"))
|
||||
{
|
||||
if (!SetStrongNameKeyPair(ref options.key, s.Substring(5), false))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
options.keycontainer = s.Substring(5);
|
||||
}
|
||||
else if(s == "-delaysign")
|
||||
{
|
||||
options.delaysign = true;
|
||||
}
|
||||
else if(s == "-debug")
|
||||
{
|
||||
|
|
|
@ -139,7 +139,14 @@ namespace IKVM.Internal
|
|||
{
|
||||
AssemblyName name = new AssemblyName();
|
||||
name.Name = assemblyName;
|
||||
name.KeyPair = options.key;
|
||||
if (options.keyPair != null)
|
||||
{
|
||||
name.KeyPair = options.keyPair;
|
||||
}
|
||||
else if (options.publicKey != null)
|
||||
{
|
||||
name.SetPublicKey(options.publicKey);
|
||||
}
|
||||
name.Version = options.version;
|
||||
assemblyBuilder =
|
||||
StaticCompiler.Universe
|
||||
|
@ -2771,7 +2778,7 @@ namespace IKVM.Internal
|
|||
loader.AddReference(AssemblyClassLoader.FromAssembly(JVM.CoreAssembly));
|
||||
}
|
||||
|
||||
if(options.key != null && !allReferencesAreStrongNamed)
|
||||
if((options.keyPair != null || options.publicKey != null) && !allReferencesAreStrongNamed)
|
||||
{
|
||||
Console.Error.WriteLine("Error: all referenced assemblies must be strong named, to be able to sign the output assembly");
|
||||
return 1;
|
||||
|
@ -3086,7 +3093,11 @@ namespace IKVM.Internal
|
|||
class CompilerOptions
|
||||
{
|
||||
internal string path;
|
||||
internal StrongNameKeyPair key;
|
||||
internal string keyfile;
|
||||
internal string keycontainer;
|
||||
internal bool delaysign;
|
||||
internal byte[] publicKey;
|
||||
internal StrongNameKeyPair keyPair;
|
||||
internal Version version;
|
||||
internal string fileversion;
|
||||
internal bool targetIsModule;
|
||||
|
|
Загрузка…
Ссылка в новой задаче