Fix the handling of header files with `mmc --make'.

Estimated hours taken: 3
Branches: main

Fix the handling of header files with `mmc --make'.

compiler/make.module_target.m:
	Check that all files made by the command are present
	(for example, previously only the `.c_date' files were
	checked, not the `.c' files).

compiler/make.util.m:
	In high-level C grades, don't rebuild the `.o' file if an
	irrelevant part of a `.mih' file has changed. If a relevant
	part of a `.mih' file changed, the interface files of the
	imported module must have changed in a way that would force
	the `.c' and `.o' files of the current module to be rebuilt.

	When finding the timestamps for header files, make sure
	the current directory is searched.

	Header files are created using mercury_update_interface,
	so to check whether a header file is up to date we need
	to check the timestamp on the `.c_date' or `.s_date' file,
	not the header file itself.

compiler/make.dependencies.m:
	Add some more debugging messages.
	Fix the format of some error messages.
This commit is contained in:
Simon Taylor
2002-06-21 16:52:46 +00:00
parent b87367d7de
commit be92cdb69a
3 changed files with 112 additions and 48 deletions

View File

@@ -146,7 +146,7 @@
% Find the extension for the timestamp file for the
% given target type, if one exists.
:- func timestamp_extension(module_target_type) = string is semidet.
:- func timestamp_extension(globals, module_target_type) = string is semidet.
%-----------------------------------------------------------------------------%
% Debugging, verbose and error messages.
@@ -395,7 +395,7 @@ write_error_char(FullOutputStream, PartialOutputStream, LineLimit,
get_timestamp_file_timestamp(ModuleName - FileType,
MaybeTimestamp, Info0, Info) -->
globals__io_get_globals(Globals),
{ TimestampExt = timestamp_extension(FileType) ->
{ TimestampExt = timestamp_extension(Globals, FileType) ->
Ext = TimestampExt
;
Ext = target_extension(Globals, FileType)
@@ -420,7 +420,17 @@ get_dependency_timestamp(file(FileName, MaybeOption), MaybeTimestamp,
),
get_file_timestamp(SearchDirs, FileName, MaybeTimestamp, Info0, Info).
get_dependency_timestamp(target(Target), MaybeTimestamp, Info0, Info) -->
get_target_timestamp(Target, MaybeTimestamp, Info0, Info).
get_target_timestamp(Target, MaybeTimestamp0, Info0, Info),
{ Target = _ - c_header(mih), MaybeTimestamp0 = ok(_) ->
% Don't rebuild the `.o' file if an irrelevant part of a
% `.mih' file has changed. If a relevant part of a `.mih'
% file changed, the interface files of the imported module
% must have changed in a way that would force the `.c' and
% `.o' files of the current module to be rebuilt.
MaybeTimestamp = ok(oldest_timestamp)
;
MaybeTimestamp = MaybeTimestamp0
}.
get_target_timestamp(ModuleName - FileType, MaybeTimestamp, Info0, Info) -->
get_file_name(ModuleName - FileType, FileName, Info0, Info1),
@@ -516,7 +526,15 @@ get_file_timestamp(SearchDirs, FileName, MaybeTimestamp, Info0, Info) -->
get_search_directories(FileType, SearchDirs) -->
( { yes(SearchDirOpt) = search_for_file_type(FileType) } ->
globals__io_lookup_accumulating_option(SearchDirOpt,
SearchDirs)
SearchDirs0),
% Make sure the current directory is searched
% for C headers and libraries.
{ SearchDirs =
( list__member(dir__this_directory, SearchDirs0) ->
SearchDirs0
;
[dir__this_directory | SearchDirs0]
) }
;
{ SearchDirs = [dir__this_directory] }
).
@@ -535,7 +553,7 @@ remove_target_file(ModuleName, FileType, Info0, Info) -->
globals__io_get_globals(Globals),
remove_file(ModuleName, target_extension(Globals, FileType),
Info0, Info1),
( { TimestampExt = timestamp_extension(FileType) } ->
( { TimestampExt = timestamp_extension(Globals, FileType) } ->
remove_file(ModuleName, TimestampExt, Info1, Info)
;
{ Info = Info1 }
@@ -591,17 +609,21 @@ linked_target_file_name(ModuleName, shared_library, FileName) -->
% Note that we need a timestamp file for `.err' files because
% errors are written to the `.err' file even when writing interfaces.
% The timestamp is only updated when compiling to target code.
timestamp_extension(errors) = ".err_date".
timestamp_extension(private_interface) = ".date0".
timestamp_extension(long_interface) = ".date".
timestamp_extension(short_interface) = ".date".
timestamp_extension(unqualified_short_interface) = ".date3".
timestamp_extension(intermodule_interface) = ".optdate".
timestamp_extension(c_code) = ".c_date".
timestamp_extension(il_code) = ".il_date".
timestamp_extension(java_code) = ".java_date".
timestamp_extension(asm_code(non_pic)) = ".s_date".
timestamp_extension(asm_code(pic)) = ".pic_s_date".
timestamp_extension(_, errors) = ".err_date".
timestamp_extension(_, private_interface) = ".date0".
timestamp_extension(_, long_interface) = ".date".
timestamp_extension(_, short_interface) = ".date".
timestamp_extension(_, unqualified_short_interface) = ".date3".
timestamp_extension(_, intermodule_interface) = ".optdate".
timestamp_extension(_, c_code) = ".c_date".
timestamp_extension(Globals, c_header(_)) = Ext :-
globals__get_target(Globals, Target),
Ext = timestamp_extension(Globals,
(Target = asm -> asm_code(non_pic) ; c_code)).
timestamp_extension(_, il_code) = ".il_date".
timestamp_extension(_, java_code) = ".java_date".
timestamp_extension(_, asm_code(non_pic)) = ".s_date".
timestamp_extension(_, asm_code(pic)) = ".pic_s_date".
:- func search_for_file_type(module_target_type) = maybe(option).