[m-rev.] dif: merge csharp build rules into main branch.

Tyson Dowd trd at cs.mu.OZ.AU
Tue Jul 24 23:55:46 AEST 2001


Hi,

The merge had to be done by hand quite a bit, so I post it here for
further reference.

I changed REFS to CSHARP_ASSEMBLY_REFS while making this change.

===================================================================


Estimated hours taken: 4
Branches: main

Merge the changes to support csharp building into the main branch
of the compiler.

compiler/modules.m:
	Write the CSHARP_ASSEMBLY_REFS-modulename for each C# foreign
	module.

scripts/Mmake.rules:
	Add rules to build C# DLLs.


Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.180
diff -u -r1.180 modules.m
--- compiler/modules.m	2001/07/23 12:22:08	1.180
+++ compiler/modules.m	2001/07/24 13:39:53
@@ -2048,7 +2048,7 @@
 		->
 			{ Langs = set__to_sorted_list(LangSet) },
 			list__foldl(write_foreign_dependency_for_il(DepStream,
-				ModuleName), Langs)
+				ModuleName, AllDeps), Langs)
 		;
 			[]
 		),
@@ -2215,14 +2215,18 @@
 	% (the rule to generate .dll from .cpp is a pattern rule in
 	% scripts/Mmake.rules).
 	% 
-:- pred write_foreign_dependency_for_il(io__output_stream::in, sym_name::in,
-		foreign_language::in, io__state::di, io__state::uo) is det.
-write_foreign_dependency_for_il(DepStream, ModuleName, ForeignLang) -->
+:- pred write_foreign_dependency_for_il(io__output_stream::in,sym_name::in,
+		list(module_name)::in, foreign_language::in,
+		io__state::di, io__state::uo) is det.
+write_foreign_dependency_for_il(DepStream, ModuleName, AllDeps, ForeignLang)
+		-->
 	( 
 		{ ForeignModuleName = foreign_language_module_name(
 			ModuleName, ForeignLang) },
 		{ ForeignExt = foreign_language_file_extension(ForeignLang) }
 	->
+		module_name_to_file_name(ForeignModuleName, "", no,
+			ForeignModuleNameString),
 		module_name_to_file_name(ForeignModuleName, ForeignExt, no,
 			ForeignFileName),
 		module_name_to_file_name(ModuleName, ".il", no, IlFileName),
@@ -2230,8 +2234,8 @@
 		module_name_to_file_name(ForeignModuleName, ".dll", no,
 			ForeignDllFileName),
 
-		io__write_strings(DepStream, [ForeignDllFileName,
-			" : ", DllFileName]),
+		io__write_strings(DepStream, [
+			ForeignDllFileName, " : ", DllFileName]),
 			% XXX This change doesn't work correctly because
 			% mmake can't find the dlls which don't reside
 			% in the current directory.
@@ -2241,13 +2245,29 @@
 		io__nl(DepStream),
 
 		io__write_strings(DepStream, [
-			ForeignFileName, " : ", IlFileName, "\n\n"])
+			ForeignFileName, " : ", IlFileName, "\n\n"]),
+
+		( { ForeignLang = csharp } ->
+			% Store in the variable
+			% CSHARP_ASSEMBLY_REFS-foreign_code_name
+			% the command line argument to reference all the
+			% dlls the foreign code module references.
+			io__write_strings(DepStream, 
+				["CSHARP_ASSEMBLY_REFS-", 
+					ForeignModuleNameString, "="]),
+			write_dll_dependencies_list(ModuleName,
+				AllDeps, "/r:", DepStream),
+			io__nl(DepStream)
+		;
+			[]
+		)
 	;
 		% This foreign language doesn't generate an external file
 		% so there are no dependencies to generate.
 		[]
 	).
 
+
 maybe_read_dependency_file(ModuleName, MaybeTransOptDeps) -->
 	globals__io_lookup_bool_option(transitive_optimization, TransOpt),
 	( { TransOpt = yes } ->
@@ -3910,11 +3932,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.
@@ -3933,15 +3955,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	2001/07/18 09:37:34	1.102
+++ scripts/Mmake.rules	2001/07/24 13:39:54
@@ -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:$@ \
+		$(CSHARP_ASSEMBLY_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:$@ \
+		$(CSHARP_ASSEMBLY_REFS-$*) $<
 
 .cpp.exe:
 	$(MS_CL) -CLR($MS_CL_NOASM) -I$(MERCURY_LIBRARY_PATH) $< -link -entry:main $(MS_CL_LIBS) -out:$@

--------------------------------------------------------------------------
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