diff --git a/compiler/module_cmds.m b/compiler/module_cmds.m index bb603d725..56d413ce7 100644 --- a/compiler/module_cmds.m +++ b/compiler/module_cmds.m @@ -9,8 +9,40 @@ % % File: module_cmds.m. % -% This module handles the most of the commands generated by the -% parse_tree package. +% This module handles several tasks that deal with files that the compiler +% generates with certain extensions. +% +% - The first group of predicates deals with module-specific files whose +% updates result in the exact sane file contents a significant fraction +% of the time. In such cases, we want to update the timestamp of that file +% only if its contents actually changed. +% +% - The second group deals with the files in whose filesystem timestamps +% we record information of the form "when was the contents of the +% corresponding file last found to be up-to-date?". For example, when +% we rebuild A.int and find that its new contents is the same as its +% old contents, we leave A.int's timestamp unchanged (in order to avoid +% requiring the rebuild of every file that depends on A.int), but +% record the fact that A.int was found to be up-to-date right now +% by setting the datestamp of A.date (the timestamp file for A.int) +% to now. +% +% - The third groups handles symlinks, including simulating them on +% platforms that do not support symlinks. +% +% - A fourth group creates launcher scripts for Java and C#. +% +% - A fifth group contains utility predicates for Java. +% +% - A sixth group (a single predicate) sets the exit status if needeed. +% +% XXX The current order does not match the above more logical order. +% +% XXX Only the first two groups shoild be here; the others do not belong here. +% +% XXX Most users of most of these predicates deal with target language files. +% They do not need to know their contents, so they do not belong any +% backend or even backend_lib, but they do not belong in parse_tree either. % %-----------------------------------------------------------------------------% @@ -97,8 +129,16 @@ % touch_module_ext_datestamp(Globals, ProgressStream, % ModuleName, Ext, Succeeded, !IO): % - % Touch the datestamp file `ModuleName.Ext'. Datestamp files are used - % to record when each of the interface files was last updated. + % Touch the datestamp file `ModuleName.Ext'. (The only valid values of Ext + % in such calls are those that represent timestamp files.) + % + % We use datestamp files to record in the filesystem + % when the non-timestamp file corresponding to the timestamp file + % (which may be e.g. an interface file or a target file) was last modified. + % A rebuild of e.g. A.int that leaves its contents unchanged should + % also leave its timestamp unchanged, but he fact that the old contents + % of A.int file was still up-to-date when the rebuild happened + % is recorded by updating the timestamp of A.date. % :- pred touch_module_ext_datestamp(globals::in, io.text_output_stream::in, module_name::in, ext::in, maybe_succeeded::out, io::di, io::uo) is det. @@ -108,6 +148,9 @@ % Update the modification time for the given file, % clobbering the contents of the file. % + % Filename should have an extension that indicates that it is a + % datestanp file, though this predicate does not enforce that. + % :- pred touch_file_datestamp(globals::in, io.text_output_stream::in, file_name::in, maybe_succeeded::out, io::di, io::uo) is det. @@ -151,9 +194,11 @@ % Get the value of the Java class path from the environment. (Normally % it will be obtained from the CLASSPATH environment variable, but if - % that isn't present then the java.class.path variable may be used instead. - % This is used for the Java back-end, which doesn't support environment - % variables properly.) + % that isn't present, then we use the value of the java.class.path + % environment variable used instead. + % + % This is used for the Java back-end, which does not support environment + % variables properly. % :- pred get_env_classpath(string::out, io::di, io::uo) is det. @@ -163,10 +208,6 @@ globals::in, module_name::in, string::in, maybe_succeeded::out, io::di, io::uo) is det. -:- pred create_launcher_batch_file(io.text_output_stream::in, - globals::in, module_name::in, string::in, maybe_succeeded::out, - io::di, io::uo) is det. - %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -210,7 +251,7 @@ copy_dot_tmp_to_base_file_report_any_error(ProgressStream, Globals, ( Result = dot_tmp_copy_error, Succeeded = did_not_succeed, - % XXX The call about should have told us: what was the actual problem? + % XXX The call above should have told us: what was the actual problem? string.format("problem updating %s files.", [s(FileKindStr)], Msg), report_arbitrary_error(ProgressStream, Msg, !IO) ; @@ -564,8 +605,10 @@ construct_java_batch_file(Globals, MainModuleName, JarFileName, ContentStr) :- Java, " %MERCURY_JAVA_OPTIONS% jmercury.", ClassName, " %*\n" ]). +%-----------------------------------------------------------------------------% + get_mercury_std_libs_for_java(Globals, !:StdLibs) :- - % NOTE: changes here may require changes to get_mercury_std_libs. + % NOTE: changes here may require changes to get_mercury_std_libs_for_c_cs. !:StdLibs = [], globals.lookup_maybe_string_option(Globals, @@ -780,7 +823,9 @@ create_launcher_shell_script(ProgressStream, Globals, MainModuleName, Succeeded = did_not_succeed ). -%-----------------------------------------------------------------------------% +:- pred create_launcher_batch_file(io.text_output_stream::in, + globals::in, module_name::in, string::in, maybe_succeeded::out, + io::di, io::uo) is det. create_launcher_batch_file(ProgressStream, Globals, MainModuleName, ContentStr, Succeeded, !IO) :-