[m-rev.] for review: support signing assemblies in the C# backend
Julien Fischer
jfischer at opturion.com
Tue Apr 9 15:57:03 AEST 2013
For review by anyone.
Support signing assemblies in the C# backend.
Add a new option, `--sign-assembly', to the Mercury compiler that causes it to
sign library assemblies generated by the C# backend with a user-specified
strong name. There was an existing undocumented option of the same name for
use by the IL backend; it has been renamed to --il-sign-assembly.
compiler/options.m:
Add the new option.
Rename the existing `--sign-assembly' option to `--il-sign-assembly'.
compiler/compile_target_code.m:
Optionally sign library assemblies.
compiler/mlds_to_il.m:
compiler/mlds_to_managed.m:
compiler/write_deps_file.m:
Conform to the above changes.
doc/user_guide.texi:
Document the new option
NEWS:
Announce the new option.
Julien.
diff --git a/NEWS b/NEWS
index 601a61b..a536ebe 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,9 @@ Changes to the Mercury compiler:
is now supported, i.e. the x86_64-w64-mingw32 architecture is now
supported.
+* A new option, `--sign-assembly', provides supports for signing
+ assemblies generated by the C# backend with a strong name.
+
NEWS for Mercury 12.08
----------------------
diff --git a/compiler/compile_target_code.m b/compiler/compile_target_code.m
index e139538..1c1c453 100644
--- a/compiler/compile_target_code.m
+++ b/compiler/compile_target_code.m
@@ -2841,10 +2841,16 @@ create_csharp_exe_or_lib(Globals, ErrorStream,
LinkTargetType, MainModuleName,
globals.lookup_accumulating_option(Globals, csharp_flags, CSCFlagsList),
(
LinkTargetType = csharp_executable,
- TargetOption = "-target:exe"
+ TargetOption = "-target:exe",
+ SignAssemblyOpt = ""
;
LinkTargetType = csharp_library,
- TargetOption = "-target:library"
+ TargetOption = "-target:library",
+ globals.lookup_string_option(Globals, sign_assembly, KeyFile),
+ ( if KeyFile = ""
+ then SignAssemblyOpt = ""
+ else SignAssemblyOpt = "-keyfile:" ++ KeyFile ++ " "
+ )
;
( LinkTargetType = executable
; LinkTargetType = static_library
@@ -2888,6 +2894,7 @@ create_csharp_exe_or_lib(Globals, ErrorStream,
LinkTargetType, MainModuleName,
DebugOpt,
TargetOption,
"-out:" ++ OutputFileName,
+ SignAssemblyOpt,
LinkLibraryDirectories,
LinkLibraries,
MercuryStdLibs] ++
diff --git a/compiler/mlds_to_il.m b/compiler/mlds_to_il.m
index a7ea120..9082431 100644
--- a/compiler/mlds_to_il.m
+++ b/compiler/mlds_to_il.m
@@ -272,7 +272,7 @@ generate_il(Globals, MLDS0, Version, ILAsm, ForeignLangs) :-
globals.lookup_bool_option(Globals, debug_il_asm, DebugIlAsm),
globals.lookup_bool_option(Globals, verifiable_code, VerifiableCode),
globals.lookup_bool_option(Globals, il_byref_tailcalls, ByRefTailCalls),
- globals.lookup_bool_option(Globals, sign_assembly, SignAssembly),
+ globals.lookup_bool_option(Globals, il_sign_assembly, SignAssembly),
globals.lookup_bool_option(Globals, separate_assemblies,
SeparateAssemblies),
globals.lookup_bool_option(Globals, support_ms_clr, MsCLR),
diff --git a/compiler/mlds_to_managed.m b/compiler/mlds_to_managed.m
index 584f0ec..1df06a1 100644
--- a/compiler/mlds_to_managed.m
+++ b/compiler/mlds_to_managed.m
@@ -152,7 +152,7 @@ output_csharp_header_code(Globals, !IO) :-
% in the C# code anymore.
io.write_string("using mercury;\n\n", !IO),
- globals.lookup_bool_option(Globals, sign_assembly, SignAssembly),
+ globals.lookup_bool_option(Globals, il_sign_assembly, SignAssembly),
(
SignAssembly = yes,
io.write_string("[assembly:System.Reflection." ++
diff --git a/compiler/options.m b/compiler/options.m
index d234076..d9d1f62 100644
--- a/compiler/options.m
+++ b/compiler/options.m
@@ -279,7 +279,7 @@
; prop_mode_constraints
; benchmark_modes
; benchmark_modes_repeat
- ; sign_assembly
+ ; il_sign_assembly
; separate_assemblies
% Language semantics options
@@ -914,6 +914,7 @@
; extra_initialization_functions
; frameworks
; framework_directories
+ ; sign_assembly
% Auto-configured options.
; shared_library_extension
@@ -1256,7 +1257,7 @@ option_defaults_2(aux_output_option, [
prop_mode_constraints - bool(no),
benchmark_modes - bool(no),
benchmark_modes_repeat - int(1),
- sign_assembly - bool(no),
+ il_sign_assembly - bool(no),
% XXX should default to no but currently broken
separate_assemblies - bool(yes)
]).
@@ -1815,6 +1816,7 @@ option_defaults_2(link_option, [
extra_initialization_functions - bool(no),
frameworks - accumulating([]),
framework_directories - accumulating([]),
+ sign_assembly - string(""),
shared_library_extension - string(".so"),
% The `mmc' script will override the
@@ -2162,7 +2164,7 @@ long_option("dump-mlds", dump_mlds).
long_option("mlds-dump", dump_mlds).
long_option("verbose-dump-mlds", verbose_dump_mlds).
long_option("verbose-mlds-dump", verbose_dump_mlds).
-long_option("sign-assembly", sign_assembly).
+long_option("il-sign-assembly", il_sign_assembly).
long_option("separate-assemblies", separate_assemblies).
long_option("mode-constraints", mode_constraints).
long_option("simple-mode-constraints", simple_mode_constraints).
@@ -2786,6 +2788,7 @@ long_option("extra-initialization-functions",
long_option("extra-inits", extra_initialization_functions).
long_option("framework", frameworks).
long_option("framework-directory", framework_directories).
+long_option("sign-assembly", sign_assembly).
long_option("shared-library-extension", shared_library_extension).
long_option("library-extension", library_extension).
@@ -4053,7 +4056,7 @@ options_help_aux_output -->
% "\tUse the new propagation solver for constraints based",
% "\tmode analysis.",
% IL options are commented out to reduce confusion.
-% "--sign-assembly",
+% "--il-sign-assembly",
% "\tSign the current assembly with the Mercury strong name.",
% "\tTo use assemblies created with this command all the Mercury",
% "\tmodules must be compiled with this option enabled.",
@@ -5668,7 +5671,13 @@ options_help_link -->
"\t(Mac OS X only.)",
"-F <directory>, --framework-directory <directory>",
"\tAppend the specified directory to the framework search path.",
- "\t(Mac OS X only.)"
+ "\t(Mac OS X only.)",
+
+ "--sign-assembly <keyfile>",
+ "\tSign the current assembly with the strong name contained",
+ "\tin the specified key file.",
+ "\t(This option is only meaningful when generating library assemblies",
+ "\twith the C# backend.)"
% The --shared-library-extension,
% --library-extension, --executable-file-extension
diff --git a/compiler/write_deps_file.m b/compiler/write_deps_file.m
index 5497055..bc7e0f9 100644
--- a/compiler/write_deps_file.m
+++ b/compiler/write_deps_file.m
@@ -485,7 +485,7 @@ write_dependency_file(Globals, Module, AllDepsSet,
MaybeTransOptDeps, !IO) :-
),
globals.get_target(Globals, Target),
- globals.lookup_bool_option(Globals, sign_assembly, SignAssembly),
+ globals.lookup_bool_option(Globals, il_sign_assembly, SignAssembly),
% If we are on the IL backend, add the dependency that the
% top level dll of a nested module hierachy depends on all
diff --git a/doc/user_guide.texi b/doc/user_guide.texi
index 562d9e1..1488669 100644
--- a/doc/user_guide.texi
+++ b/doc/user_guide.texi
@@ -10103,6 +10103,14 @@ Build and link against the specified framework.
Append the specified directory to the framework search path.
(Mac OS X only.)
+ at sp 1
+ at item --sign-assembly @var{keyfile}
+ at findex --sign-assembly
+Sign the current assembly with the strong name contained in the
+specified key file.
+(This option is only meaningful when generating library assemblies
+with the C# backend.)
+
@end table
@c ----------------------------------------------------------------------------
More information about the reviews
mailing list