[m-rev.] for review: mmc --make for external foreign files improvements
Peter Ross
pro at missioncriticalit.com
Fri Dec 20 20:38:56 AEDT 2002
--- zzlog.make2 2002-12-20 10:32:39.000000000 +0100
+++ zzlog.make3 2002-12-20 10:35:37.000000000 +0100
@@ -40,10 +40,6 @@
compilation_task_type.
compiler/make.module_target.m:
- Always create a directory to hold the target file before
- building the target file. This fixes a bug where the target
- directory wasn't always being created before building the
- target file.
Add rules to build the foreign_code_to_object_code and
fact_table_code_to_object_code.
@@ -61,6 +57,9 @@
`compile_target_code.m'.
Don't place dlls in a sub-directory because on the IL backend
the dlls are `part' of the executable file.
+ Add a `MkDir' argument to fact_table_file_name which
+ optionally creates a directory to store the generated
+ file_name in.
tests/hard_coded/foreign_proc_make.exp:
tests/hard_coded/foreign_proc_make.m:
diff -u compiler/make.module_target.m compiler/make.module_target.m
--- compiler/make.module_target.m
+++ compiler/make.module_target.m
@@ -241,7 +241,6 @@
build_target(CompilationTask, TargetFile, Imports, TouchedTargetFiles,
TouchedFiles, Succeeded, Info0, Info) -->
maybe_make_target_message(TargetFile),
- maybe_make_directory_for_target_file(TargetFile),
{ TargetFile = ModuleName - _FileType },
{ CompilationTask = Task - TaskOptions },
{ Cleanup =
@@ -398,21 +397,6 @@
%-----------------------------------------------------------------------------%
-:- pred maybe_make_directory_for_target_file(target_file::in,
- io::di, io::uo) is det.
-
-maybe_make_directory_for_target_file(_ModuleName - TargetType) -->
- globals__io_get_globals(Globals),
- { Extension = target_extension(Globals, TargetType) },
- { string__first_char(Extension, '.', Ext0) ->
- Ext = Ext0
- ;
- unexpected(this_file, "extension doesn't have leading '.'")
- },
- make_directory("Mercury/" ++ Ext ++ "s").
-
-%-----------------------------------------------------------------------------%
-
:- pred foreign_code_file(module_name::in, pic::in, foreign_language::in,
foreign_code_file::out, io::di, io::uo) is det.
@@ -440,8 +424,8 @@
ForeignCodeFile) -->
globals__io_get_globals(Globals),
{ ObjExt = get_object_extension(Globals, PIC) },
- fact_table_file_name(ModuleName, FactTableName, ".c", CFile),
- fact_table_file_name(ModuleName, FactTableName, ObjExt, ObjFile),
+ fact_table_file_name(ModuleName, FactTableName, ".c", yes, CFile),
+ fact_table_file_name(ModuleName, FactTableName, ObjExt, yes, ObjFile),
{ ForeignCodeFile = foreign_code_file(c, CFile, ObjFile) }.
:- func get_object_extension(globals, pic) = string.
@@ -813,10 +797,10 @@
->
module_name_to_file_name(
foreign_language_module_name(ModuleName, c), ".c",
- yes, CCodeFileName),
+ no, CCodeFileName),
module_name_to_file_name(
foreign_language_module_name(ModuleName, c), ObjExt,
- yes, ObjFileName),
+ no, ObjFileName),
{ ForeignFiles0 =
[foreign_code_file(c, CCodeFileName, ObjFileName) ] }
;
@@ -838,9 +822,9 @@
(pred(FactTableFile::in, FactTableForeignFile::out,
di, uo) is det -->
fact_table_file_name(ModuleName, FactTableFile,
- ".c", FactTableCFile),
+ ".c", no, FactTableCFile),
fact_table_file_name(ModuleName, FactTableFile,
- ObjExt, FactTableObjFile),
+ ObjExt, no, FactTableObjFile),
{ FactTableForeignFile = foreign_code_file(c,
FactTableCFile, FactTableObjFile) }
), Imports ^ fact_table_deps, FactTableForeignFiles),
diff -u compiler/make.util.m compiler/make.util.m
--- compiler/make.util.m
+++ compiler/make.util.m
@@ -626,24 +626,24 @@
target_extension(Globals, foreign_object(PIC, c)) = Ext :-
maybe_pic_object_file_extension(Globals, PIC, Ext).
- % Note we use the bogus extension "XXX bogus ext" so that
- % this predicate remains nondet.
-target_extension(_, foreign_object(PIC, csharp)) = "XXX bogus ext" :-
+ % Note we use the bogus extension "bogus ext" so that
+ % the reverse mode of this function remains nondet.
+target_extension(_, foreign_object(PIC, csharp)) = "bogus ext" :-
( PIC = pic
; PIC = non_pic
),
unexpected(this_file, "C# foreign_object").
-target_extension(_, foreign_object(PIC, managed_cplusplus)) = "XXX bogus ext" :-
+target_extension(_, foreign_object(PIC, managed_cplusplus)) = "bogus ext" :-
( PIC = pic
; PIC = non_pic
),
unexpected(this_file, "MC++ foreign_object").
-target_extension(_, foreign_object(PIC, il)) = "XXX bogus ext" :-
+target_extension(_, foreign_object(PIC, il)) = "bogus ext" :-
( PIC = pic
; PIC = non_pic
),
unexpected(this_file, "il foreign_object").
-target_extension(_, foreign_il_asm(c)) = "XXX bogus ext" :-
+target_extension(_, foreign_il_asm(c)) = "bogus ext" :-
unexpected(this_file, "C foreign_il_asm").
target_extension(_, foreign_il_asm(csharp)) = ".dll".
diff -u compiler/modules.m compiler/modules.m
--- compiler/modules.m
+++ compiler/modules.m
@@ -130,12 +130,13 @@
io__state, io__state).
:- mode module_name_to_split_c_file_pattern(in, in, out, di, uo) is det.
- % fact_table_file_name(Module, FactTableFileName, Ext, FileName):
+ % fact_table_file_name(Module, FactTableFileName, Ext, MkDir, FileName):
% Returns the filename to use when compiling fact table
- % files.
-:- pred fact_table_file_name(module_name, file_name, string, file_name,
+ % files. If 'MkDir' is yes, then create any directories
+ % needed.
+:- pred fact_table_file_name(module_name, file_name, string, bool, file_name,
io__state, io__state).
-:- mode fact_table_file_name(in, in, in, out, di, uo) is det.
+:- mode fact_table_file_name(in, in, in, in, out, di, uo) is det.
% convert a file name (excluding the trailing `.m')
% to the corresponding module name
@@ -849,19 +850,22 @@
{ string__append_list([Prefix, BaseFileName, Ext], BaseName) },
choose_file_name(ModuleName, BaseName, Ext, no, MkDir, FileName).
-fact_table_file_name(ModuleName, FactTableFileName, Ext, FileName) -->
- extra_link_obj_file_name(ModuleName, FactTableFileName, Ext, FileName).
+fact_table_file_name(ModuleName, FactTableFileName, Ext, MkDir, FileName) -->
+ extra_link_obj_file_name(ModuleName, FactTableFileName,
+ Ext, MkDir, FileName).
- % extra_link_obj_file_name(Module, ExtraLinkObjName, Ext, FileName):
+ % extra_link_obj_file_name(Module, ExtraLinkObjName,
+ % Ext, MkDir, FileName):
% Returns the filename to use when compiling extra objects
% that must be linked into the executable
% (currently used only for fact tables).
-:- pred extra_link_obj_file_name(module_name, file_name, string, file_name,
- io__state, io__state).
-:- mode extra_link_obj_file_name(in, in, in, out, di, uo) is det.
-extra_link_obj_file_name(ModuleName, ExtraLinkObjName, Ext, FileName) -->
+ % If `MkDir' is yes, make any directories necessary.
+:- pred extra_link_obj_file_name(module_name, file_name, string, bool,
+ file_name, io__state, io__state).
+:- mode extra_link_obj_file_name(in, in, in, in, out, di, uo) is det.
+extra_link_obj_file_name(ModuleName, ExtraLinkObjName, Ext, MkDir, FileName) -->
{ string__append(ExtraLinkObjName, Ext, BaseName) },
- choose_file_name(ModuleName, BaseName, Ext, no, no, FileName).
+ choose_file_name(ModuleName, BaseName, Ext, no, MkDir, FileName).
:- pred choose_file_name(module_name, string, string, bool, bool, file_name,
io__state, io__state).
@@ -4986,7 +4990,7 @@
write_fact_table_dependencies_list(_, [], _, _) --> [].
write_fact_table_dependencies_list(Module, [FactTable | FactTables], Suffix,
DepStream) -->
- fact_table_file_name(Module, FactTable, Suffix, FileName),
+ fact_table_file_name(Module, FactTable, Suffix, no, FileName),
io__write_string(DepStream, " \\\n\t"),
io__write_string(DepStream, FileName),
write_fact_table_dependencies_list(Module, FactTables, Suffix,
@@ -4999,7 +5003,7 @@
write_extra_link_dependencies_list([], _, _) --> [].
write_extra_link_dependencies_list([ExtraLink - Module | ExtraLinks], Suffix,
DepStream) -->
- extra_link_obj_file_name(Module, ExtraLink, Suffix, FileName),
+ extra_link_obj_file_name(Module, ExtraLink, Suffix, no, FileName),
io__write_string(DepStream, " \\\n\t"),
io__write_string(DepStream, FileName),
write_extra_link_dependencies_list(ExtraLinks, Suffix, DepStream).
--------------------------------------------------------------------------
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