[m-rev.] for review: Add C# build rules
Peter Ross
petdr at cs.mu.OZ.AU
Thu Jul 19 21:16:37 AEST 2001
Hi,
===================================================================
Estimated hours taken: 2
Branches: main
Add rules to build C# files automatically.
compiler/globals.m:
Add the function foreign_lang_ext which returns the extension to
place on files for the particular foreign language.
compiler/modules.m:
Output the variable REFS-foreign_code_module. This variable holds
the command line argument the C# compiler uses to determine which
assemblies to resolve symbols against.
Use the foreign_lang_ext function to determine the extension
correctly.
scripts/Mmake.rules:
Add a rule to build dlls from C# files.
Index: compiler/globals.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/globals.m,v
retrieving revision 1.44
diff -u -r1.44 globals.m
--- compiler/globals.m 18 Jul 2001 10:20:50 -0000 1.44
+++ compiler/globals.m 19 Jul 2001 11:02:53 -0000
@@ -61,6 +61,9 @@
% for use in machine-readable name mangling.
:- func simple_foreign_language_string(foreign_language) = string.
+ % The extension for files of this foreign language.
+:- func foreign_lang_ext(foreign_language) = string.
+
%-----------------------------------------------------------------------------%
% Access predicates for the `globals' structure.
@@ -215,6 +218,11 @@
simple_foreign_language_string(managed_cplusplus) = "cpp". % XXX mcpp is better
simple_foreign_language_string(csharp) = "csharp".
simple_foreign_language_string(il) = "il".
+
+foreign_lang_ext(c) = "c".
+foreign_lang_ext(managed_cplusplus) = "cpp". % XXX mcpp is better
+foreign_lang_ext(csharp) = "cs".
+foreign_lang_ext(il) = "il".
convert_gc_method("none", none).
convert_gc_method("conservative", conservative).
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.178
diff -u -r1.178 modules.m
--- compiler/modules.m 18 Jul 2001 12:08:43 -0000 1.178
+++ compiler/modules.m 19 Jul 2001 11:02:59 -0000
@@ -2058,9 +2058,12 @@
->
globals__io_lookup_foreign_language_option(
backend_foreign_language, ForeignLang),
- { ForeignExt = simple_foreign_language_string(
+ { ForeignExt = "." ++ foreign_lang_ext(ForeignLang) },
+ { ForeignStr = simple_foreign_language_string(
ForeignLang) },
- { ForeignCodeExt = "__" ++ ForeignExt ++ "_code." },
+ { ForeignCodeExt = "__" ++ ForeignStr ++ "_code" },
+ module_name_to_file_name(ModuleName, "", no,
+ Name),
module_name_to_file_name(ModuleName,
ForeignCodeExt ++ ForeignExt,
no, ForeignFileName),
@@ -2069,7 +2072,7 @@
module_name_to_file_name(ModuleName, ".dll", no,
DllFileName),
module_name_to_file_name(ModuleName,
- ForeignCodeExt ++ "dll",
+ ForeignCodeExt ++ ".dll",
no, ForeignDllFileName),
io__write_strings(DepStream, [
@@ -2079,13 +2082,22 @@
% in the current directory.
/*
write_dll_dependencies_list(ModuleName,
- AllDeps, DepStream),
+ AllDeps, "", DepStream),
*/
io__nl(DepStream),
io__write_strings(DepStream, [
ForeignDllFileName, " : ", ForeignFileName,"\n",
- ForeignFileName, " : ", IlFileName, "\n\n"])
+ ForeignFileName, " : ", IlFileName, "\n\n"]),
+
+ % Store in the variable REFS-foreign_code_name
+ % the command line argument to reference all the
+ % dlls the foreign code module references.
+ io__write_strings(DepStream,
+ ["REFS-", Name, ForeignCodeExt, "="]),
+ write_dll_dependencies_list(ModuleName,
+ AllDeps, "/r:", DepStream),
+ io__nl(DepStream)
;
[]
),
@@ -2924,7 +2936,7 @@
globals__io_get_target(Target),
globals__io_lookup_foreign_language_option(
backend_foreign_language, ForeignLang),
- { ForeignExt = "." ++ simple_foreign_language_string(ForeignLang) },
+ { ForeignExt = "." ++ foreign_lang_ext(ForeignLang) },
( { Target = il } ->
{ ForeignModules = foreign_modules(ForeignLang,
Modules, DepsMap) }
@@ -3826,11 +3838,11 @@
io__write_string(DepStream, FileName),
write_dependencies_list(Modules, Suffix, DepStream).
-:- pred write_dll_dependencies_list(module_name,
- list(module_name), io__output_stream, io__state, io__state).
-:- mode write_dll_dependencies_list(in, in, in, di, uo) is det.
+:- pred write_dll_dependencies_list(module_name, list(module_name),
+ string, io__output_stream, io__state, io__state).
+:- mode write_dll_dependencies_list(in, in, in, in, di, uo) is det.
-write_dll_dependencies_list(Module, Modules0, DepStream) -->
+write_dll_dependencies_list(Module, Modules0, Prefix, DepStream) -->
% If we are not compiling a module in the mercury
% std library then replace all the std library dlls with
% one reference to mercury.dll.
@@ -3849,15 +3861,16 @@
),
Modules = list__remove_dups(list__map(F, Modules0))
},
- list__foldl(write_dll_dependency(DepStream), Modules).
+ list__foldl(write_dll_dependency(DepStream, Prefix), Modules).
-:- pred write_dll_dependency(io__output_stream, module_name,
+:- pred write_dll_dependency(io__output_stream, string, module_name,
io__state, io__state).
-:- mode write_dll_dependency(in, in, di, uo) is det.
+:- mode write_dll_dependency(in, in, in, di, uo) is det.
-write_dll_dependency(DepStream, Module) -->
+write_dll_dependency(DepStream, Prefix, Module) -->
module_name_to_file_name(Module, ".dll", no, FileName),
io__write_string(DepStream, " \\\n\t"),
+ io__write_string(DepStream, Prefix),
io__write_string(DepStream, FileName).
:- pred write_fact_table_dependencies_list(module_name, list(file_name),
Index: scripts/Mmake.rules
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.rules,v
retrieving revision 1.102
diff -u -r1.102 Mmake.rules
--- scripts/Mmake.rules 18 Jul 2001 09:37:34 -0000 1.102
+++ scripts/Mmake.rules 19 Jul 2001 11:03:00 -0000
@@ -22,7 +22,7 @@
.i .s .pic_s \
.ql .pl \
.rlo \
- .il .dll .exe .cpp \
+ .il .dll .exe .cpp .cs \
.c_date .il_date .s_date .pic_s_date
#-----------------------------------------------------------------------------#
@@ -252,6 +252,10 @@
-link -noentry mscoree.lib -dll $(MS_CL_LIBS) -out:$@
rm -f $*.obj
+$(os_subdir)%.dll : %.cs
+ csc /t:library /lib:`cygpath -w $(MERC_DLL_DIR)` /out:$@ \
+ $(REFS-$*) $<
+
$(os_subdir)%.dll : %.il
$(MS_ILASM) $(ALL_MS_ILASMFLAGS) /dll /quiet /OUT=$@ $<
endif
@@ -354,6 +358,10 @@
$(MS_CL) -CLR($MS_CL_NOASM) -I$(MERCURY_LIBRARY_PATH) $< \
-link -noentry mscoree.lib -dll $(MS_CL_LIBS) -out:$@
rm -f $*.obj
+
+.cs.dll:
+ csc /t:library /lib:`cygpath -w $(MERC_DLL_DIR)` /out:$@ \
+ $(REFS-$*) $<
.cpp.exe:
$(MS_CL) -CLR($MS_CL_NOASM) -I$(MERCURY_LIBRARY_PATH) $< -link -entry:main $(MS_CL_LIBS) -out:$@
----
Peter Ross
PhD Student University of Melbourne
http://www.cs.mu.oz.au/~petdr/
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list