[m-rev.] trivial diff: cleanup mmc --make
Julien Fischer
juliensf at cs.mu.OZ.AU
Tue Apr 26 09:50:24 AEST 2005
Estimated hours taken: 0.5
Branches: main
Minor cleanups for mmc --make. There are no algorithmic
changes.
compiler/make.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/process_util.m:
Bring these modules into line with our current coding
standard.
Julien.
Workspace:/home/earth/juliensf/ws70
Index: compiler/make.dependencies.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.dependencies.m,v
retrieving revision 1.19
diff -u -r1.19 make.dependencies.m
--- compiler/make.dependencies.m 30 Mar 2005 00:50:20 -0000 1.19
+++ compiler/make.dependencies.m 25 Apr 2005 23:41:05 -0000
@@ -16,6 +16,8 @@
:- interface.
+%-----------------------------------------------------------------------------%
+
% find_module_deps(ModuleName, Succeeded, Deps, !Info, !IO).
%
% The reason we don't return maybe(Deps) is that with `--keep-going'
@@ -99,6 +101,7 @@
:- func init_cached_transitive_dependencies = cached_transitive_dependencies.
%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- implementation.
@@ -114,6 +117,7 @@
% This is important because the calls to get_module_dependencies
% from the dependency calculation predicates can result in
% every module in the program being read.
+ %
:- func combine_deps(find_module_deps(T)::in(find_module_deps),
find_module_deps(T)::in(find_module_deps)) =
(find_module_deps(T)::out(find_module_deps)) is det.
@@ -644,7 +648,7 @@
%-----------------------------------------------------------------------------%
- %
+
% foreign_imports(Lang, ModuleName, Success, Modules, !Info, !IO)
%
% From the module, ModuleName, extract the set of modules, Modules,
@@ -690,13 +694,13 @@
Modules = set__filter((pred(M::in) is semidet :- Filter(ModuleName, M)),
Modules0).
-%
-% If the current module we are compiling is not in the standard library
-% and the module we are importing is then remove it, otherwise keep it.
-% When compiling with `--target il', if the current module is not in the
-% standard library, we link with mercury.dll rather than the DLL file for
-% the imported module.
-%
+
+ % If the current module we are compiling is not in the standard
+ % library and the module we are importing is then remove it,
+ % otherwise keep it. When compiling with `--target il', if the
+ % current module is not in the standard library, we link with
+ % mercury.dll rather than the DLL file for the imported module.
+ %
:- pred maybe_keep_std_lib_module(module_name::in, module_name::in) is semidet.
maybe_keep_std_lib_module(CurrentModule, ImportedModule) :-
@@ -868,10 +872,10 @@
io__write_string(TargetFileName, !IO),
io__write_string(": dependencies could not be built.\n\t", !IO),
io__write_list(UnbuiltDependencies, ",\n\t",
- (pred((DepTarget - DepStatus)::in, di, uo) is det -->
- write_dependency_file(DepTarget),
- io__write_string(" - "),
- io__write(DepStatus)
+ (pred((DepTarget - DepStatus)::in, !.IO::di, !:IO::uo) is det :-
+ write_dependency_file(DepTarget, !IO),
+ io__write_string(" - ", !IO),
+ io__write(DepStatus, !IO)
), !IO),
io__nl(!IO).
@@ -891,9 +895,9 @@
;
UnbuiltDependencies = [],
debug_msg(
- (pred(di, uo) is det -->
- io__write_string(TargetFileName),
- io__write_string(": finished dependencies\n")
+ (pred(!.IO::di, !:IO::uo) is det :-
+ io__write_string(TargetFileName, !IO),
+ io__write_string(": finished dependencies\n", !IO)
), !IO),
list__map_foldl2(get_dependency_timestamp, DepFiles,
DepTimestamps, !Info, !IO),
@@ -933,9 +937,9 @@
MaybeTimestamp = error(_),
DepsResult = out_of_date,
debug_msg(
- (pred(di, uo) is det -->
- io__write_string(TargetFileName),
- io__write_string(" does not exist.\n")
+ (pred(!.IO::di, !:IO::uo) is det :-
+ io__write_string(TargetFileName, !IO),
+ io__write_string(" does not exist.\n", !IO)
), !IO)
;
MaybeTimestamp = ok(Timestamp),
@@ -1055,9 +1059,8 @@
MaybeImports = yes(Imports),
( Imports ^ module_dir \= dir__this_directory ->
%
- % Targets from libraries are always
- % considered to be up-to-date if they
- % exist.
+ % Targets from libraries are always considered to be
+ % up-to-date if they exist.
%
get_target_timestamp(yes, Target, MaybeTimestamp, !Info, !IO),
(
@@ -1085,4 +1088,6 @@
this_file = "make.dependencies.m".
+%-----------------------------------------------------------------------------%
+:- end_module make.dependencies.
%-----------------------------------------------------------------------------%
Index: compiler/make.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.m,v
retrieving revision 1.27
diff -u -r1.27 make.m
--- compiler/make.m 30 Mar 2005 00:50:20 -0000 1.27
+++ compiler/make.m 22 Apr 2005 03:31:26 -0000
@@ -17,6 +17,7 @@
% - parallel/distributed builds
%
%-----------------------------------------------------------------------------%
+
:- module make.
:- interface.
@@ -34,6 +35,8 @@
:- import_module io.
:- import_module list.
+%-----------------------------------------------------------------------------%
+
% make__process_args(OptionArgs, NonOptionArgs).
%
:- pred make__process_args(options_variables::in, list(string)::in,
@@ -47,6 +50,7 @@
:- type make_info.
%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- implementation.
@@ -74,10 +78,8 @@
:- import_module libs__timestamp.
:- import_module parse_tree__error_util.
:- import_module parse_tree__mercury_to_mercury.
-:- import_module parse_tree__modules.
:- import_module parse_tree__prog_data.
:- import_module parse_tree__prog_foreign.
-:- import_module parse_tree__prog_io.
:- import_module parse_tree__prog_io_util.
:- import_module parse_tree__prog_out.
:- import_module top_level__mercury_compile. % XXX unwanted dependency
@@ -89,7 +91,6 @@
:- import_module exception.
:- import_module getopt_io.
:- import_module int.
-:- import_module list.
:- import_module map.
:- import_module parser.
:- import_module require.
@@ -99,6 +100,8 @@
:- import_module term.
:- import_module term_io.
+%-----------------------------------------------------------------------------%
+
:- type make_info --->
make_info(
% The items field of each module_imports structure should be empty
@@ -417,4 +420,6 @@
search_backwards_for_dot(String, Index - 1, DotIndex)
).
+%-----------------------------------------------------------------------------%
+:- end_module make.
%-----------------------------------------------------------------------------%
Index: compiler/make.module_dep_file.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.module_dep_file.m,v
retrieving revision 1.12
diff -u -r1.12 make.module_dep_file.m
--- compiler/make.module_dep_file.m 30 Mar 2005 00:50:20 -0000 1.12
+++ compiler/make.module_dep_file.m 22 Apr 2005 03:34:55 -0000
@@ -21,19 +21,25 @@
:- import_module io.
:- import_module std_util.
+%-----------------------------------------------------------------------------%
+
% Get the dependencies for a given module.
% Dependencies are generated on demand, not by a `mmc --make depend'
% command, so this predicate may need to read the source for
% the module.
+ %
:- pred get_module_dependencies(module_name::in, maybe(module_imports)::out,
make_info::in, make_info::out, io::di, io::uo) is det.
:- pred write_module_dep_file(module_imports::in, io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- implementation.
+%-----------------------------------------------------------------------------%
+
get_module_dependencies(ModuleName, MaybeImports, !Info, !IO) :-
RebuildDeps = !.Info ^ rebuild_dependencies,
( ModuleName = unqualified(_) ->
@@ -617,4 +623,6 @@
prog_out__write_sym_name(ImportingModuleName, !IO),
io__write_string("'.\n", !IO).
+%-----------------------------------------------------------------------------%
+:- end_module make.module_dep_file.
%-----------------------------------------------------------------------------%
Index: compiler/make.module_target.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.module_target.m,v
retrieving revision 1.30
diff -u -r1.30 make.module_target.m
--- compiler/make.module_target.m 30 Mar 2005 00:50:20 -0000 1.30
+++ compiler/make.module_target.m 22 Apr 2005 04:01:31 -0000
@@ -16,9 +16,12 @@
:- interface.
+%-----------------------------------------------------------------------------%
+
% make_module_target(Target, Success, Info0, Info).
%
% Make a target corresponding to a single module.
+ %
:- pred make_module_target(dependency_file::in, bool::out,
make_info::in, make_info::out, io::di, io::uo) is det.
@@ -28,6 +31,7 @@
% Makes sure any timestamps for files which may have changed
% in building the target are recomputed next time they are needed.
% Exported for use by make__module_dep_file__write_module_dep_file.
+ %
:- pred record_made_target(target_file::in, compilation_task_type::in,
bool::in, make_info::in, make_info::out, io::di, io::uo) is det.
@@ -46,15 +50,19 @@
% Find the foreign code files generated when a module is processed.
% The `pic' field is only used for C foreign code.
+ %
:- pred external_foreign_code_files(pic::in, module_imports::in,
list(foreign_code_file)::out, io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- implementation.
:- import_module hlds__passes_aux.
+%-----------------------------------------------------------------------------%
+
:- pred make_module_target(dependency_file::in, bool::in, bool::out,
make_info::in, make_info::out, io::di, io::uo) is det.
@@ -123,11 +131,12 @@
DepFiles = set__to_sorted_list(DepFiles0),
debug_msg(
- (pred(di, uo) is det -->
- write_target_file(TargetFile),
- io__write_string(": dependencies:\n"),
- io__write_list(DepFiles, ", ", write_dependency_file),
- io__nl
+ (pred(!.IO::di, !:IO::uo) is det :-
+ write_target_file(TargetFile, !IO),
+ io__write_string(": dependencies:\n", !IO),
+ io__write_list(DepFiles, ", ", write_dependency_file,
+ !IO),
+ io__nl(!IO)
), !IO),
globals__io_lookup_bool_option(keep_going, KeepGoing, !IO),
@@ -766,16 +775,16 @@
),
globals__io_get_globals(Globals, !IO),
list__foldl2(
- (pred((TargetModuleName - TargetFileType)::in, TimestampFiles0::in,
- TimestampFiles1::out, di, uo) is det -->
+ (pred((TargetModuleName - TargetFileType)::in, !.TimestampFiles::in,
+ !:TimestampFiles::out, !.IO::di, !:IO::uo) is det :-
(
- { TimestampExt = timestamp_extension(Globals, TargetFileType) }
+ TimestampExt = timestamp_extension(Globals, TargetFileType)
->
module_name_to_file_name(TargetModuleName, TimestampExt, no,
- TimestampFile),
- { TimestampFiles1 = [TimestampFile | TimestampFiles0] }
+ TimestampFile, !IO),
+ list.cons(TimestampFile, !TimestampFiles)
;
- { TimestampFiles1 = TimestampFiles0 }
+ true
)
), TouchedTargetFiles, [], TimestampFileNames, !IO),
TouchedFileNames = list__condense([ForeignCodeFiles, TimestampFileNames]).
@@ -883,6 +892,9 @@
%-----------------------------------------------------------------------------%
:- func this_file = string.
+
this_file = "make.module_target.m".
+%-----------------------------------------------------------------------------%
+:- end_module make.module_target.
%-----------------------------------------------------------------------------%
Index: compiler/make.program_target.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.program_target.m,v
retrieving revision 1.29
diff -u -r1.29 make.program_target.m
--- compiler/make.program_target.m 30 Mar 2005 00:50:20 -0000 1.29
+++ compiler/make.program_target.m 22 Apr 2005 06:24:25 -0000
@@ -13,9 +13,12 @@
:- interface.
+%-----------------------------------------------------------------------------%
+
% make_linked_target(Target, Success, Info0, Info).
%
% Build a library or an executable.
+ %
:- pred make_linked_target(linked_target_file::in, bool::out,
make_info::in, make_info::out, io::di, io::uo) is det.
@@ -24,15 +27,19 @@
% Handle miscellaneous target types, including clean-up, library
% installation, and building all files of a given type for all
% modules in the program.
+ %
:- pred make_misc_target(pair(module_name, misc_target_type)::in,
bool::out, make_info::in, make_info::out, io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- implementation.
:- import_module hlds__passes_aux.
+%-----------------------------------------------------------------------------%
+
make_linked_target(MainModuleName - FileType, Succeeded, !Info, !IO) :-
( FileType = shared_library ->
ExtraOptions = ["--compile-to-shared-lib"]
@@ -687,13 +694,14 @@
%
Cleanup = make_grade_clean(ModuleName, AllModules),
build_with_check_for_interrupt(
- (pred(GradeSuccess::out, MInfo::in, MInfo::out, di, uo) is det -->
+ (pred(GradeSuccess::out, MInfo::in, MInfo::out, !.IO::di, !:IO::uo)
+ is det :-
call_in_forked_process(
- (pred(GradeSuccess0::out, di, uo) is det -->
+ (pred(GradeSuccess0::out, !.IO::di, !:IO::uo) is det :-
install_library_grade_2(LinkSucceeded0,
Grade, ModuleName, AllModules,
- MInfo, GradeSuccess0)
- ), GradeSuccess)
+ MInfo, GradeSuccess0, !IO)
+ ), GradeSuccess, !IO)
), Cleanup, Succeeded, !Info, !IO).
:- pred install_library_grade_2(bool::in, string::in, module_name::in,
@@ -712,10 +720,10 @@
OptionArgs = OptionArgs0 ++ ["--grade", Grade, "--use-grade-subdirs"],
verbose_msg(
- (pred(di, uo) is det -->
- io__write_string("Installing grade "),
- io__write_string(Grade),
- io__nl
+ (pred(!.IO::di, !:IO::uo) is det :-
+ io__write_string("Installing grade ", !IO),
+ io__write_string(Grade, !IO),
+ io__nl(!IO)
), !IO),
lookup_mmc_options(Info0 ^ options_variables, MaybeMCFlags, !IO),
@@ -769,6 +777,7 @@
% Install the `.a', `.so', `.jar', `.opt' and `.mih' files
% for the current grade.
+ %
:- pred install_library_grade_files(bool::in, string::in, module_name::in,
list(module_name)::in, bool::out, make_info::in, make_info::out,
io::di, io::uo) is det.
@@ -814,6 +823,7 @@
).
% Install the `.opt' and `.mih' files for the current grade.
+ %
:- pred install_grade_ints_and_headers(bool::in, string::in, module_name::in,
bool::out, make_info::in, make_info::out, io::di, io::uo) is det.
@@ -874,6 +884,7 @@
% Install a file in the given directory, and in
% directory/Mercury/exts if the symlinks for the
% subdirectories couldn't be created (e.g. on Windows).
+ %
:- pred install_subdir_file(bool::in, dir_name::in, module_name::in,
string::in, bool::out, io::di, io::uo) is det.
@@ -896,12 +907,12 @@
install_file(FileName, InstallDir, Succeeded, !IO) :-
verbose_msg(
- (pred(di, uo) is det -->
- io__write_string("Installing file "),
- io__write_string(FileName),
- io__write_string(" in "),
- io__write_string(InstallDir),
- io__nl
+ (pred(!.IO::di, !:IO::uo) is det :-
+ io__write_string("Installing file ", !IO),
+ io__write_string(FileName, !IO),
+ io__write_string(" in ", !IO),
+ io__write_string(InstallDir, !IO),
+ io__nl(!IO)
), !IO),
globals__io_lookup_string_option(install_command, InstallCommand, !IO),
Command = string__join_list(" ", list__map(quote_arg,
@@ -932,9 +943,10 @@
;
LinkResult = no,
list__map_foldl(
- (pred(Ext::in, MkDirResult::out, di, uo) is det -->
+ (pred(Ext::in, MkDirResult::out, !.IO::di, !:IO::uo)
+ is det:-
make_directory(IntsSubdir/(Ext ++ "s"),
- MkDirResult)
+ MkDirResult, !IO)
), Subdirs, MkDirResults, !IO),
Results = Results0 ++ MkDirResults
),
@@ -993,6 +1005,7 @@
%-----------------------------------------------------------------------------%
% Clean up grade-dependent files.
+ %
:- pred make_grade_clean(module_name::in, list(module_name)::in,
make_info::in, make_info::out, io::di, io::uo) is det.
@@ -1083,16 +1096,19 @@
% Remove object and assembler files.
%
list__foldl2(
- (pred(PIC::in, !.Info::in, !:Info::out, di, uo) is det -->
- remove_target_file(ModuleName, object_code(PIC), !Info),
- remove_target_file(ModuleName, asm_code(PIC), !Info),
- remove_target_file(ModuleName, foreign_object(PIC, c), !Info),
+ (pred(PIC::in, !.Info::in, !:Info::out, !.IO::di, !:IO::uo)
+ is det :-
+ remove_target_file(ModuleName, object_code(PIC), !Info, !IO),
+ remove_target_file(ModuleName, asm_code(PIC), !Info, !IO),
+ remove_target_file(ModuleName, foreign_object(PIC, c), !Info,
+ !IO),
list__foldl2(
(pred(FactTableFile::in, !.Info::in, !:Info::out,
- di, uo) is det -->
+ !.IO::di, !:IO::uo) is det :-
remove_target_file(ModuleName,
- fact_table_object(PIC, FactTableFile), !Info)
- ), FactTableFiles, !Info)
+ fact_table_object(PIC, FactTableFile), !Info,
+ !IO)
+ ), FactTableFiles, !Info, !IO)
),
[pic, link_with_pic, non_pic], !Info, !IO),
@@ -1131,4 +1147,6 @@
this_file = "make.program_target.m".
+%-----------------------------------------------------------------------------%
+:- end_module make.program_target.
%-----------------------------------------------------------------------------%
Index: compiler/make.util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.util.m,v
retrieving revision 1.23
diff -u -r1.23 make.util.m
--- compiler/make.util.m 30 Mar 2005 00:50:20 -0000 1.23
+++ compiler/make.util.m 25 Apr 2005 23:36:35 -0000
@@ -13,11 +13,11 @@
:- interface.
- %
- % Versions of foldl which stop if the supplied predicate returns `no'
- % for any element of the list.
- %
-
+%-----------------------------------------------------------------------------%
+%
+% Versions of foldl which stop if the supplied predicate returns `no'
+% for any element of the list.
+%
% foldl2_pred_with_status(T, Succeeded, !Info).
%
:- type foldl2_pred_with_status(T, Info, IO) ==
@@ -111,8 +111,9 @@
bool::out, make_info::in, make_info::out, io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
-
- % Timestamp handling.
+%
+% Timestamp handling.
+%
% Find the timestamp updated when a target is produced.
%
@@ -159,8 +160,9 @@
maybe_error(timestamp)) = maybe_error(timestamp).
%-----------------------------------------------------------------------------%
-
- % Remove file a file, deleting the cached timestamp.
+%
+% Remove file a file, deleting the cached timestamp.
+%
% Remove the target file and the corresponding timestamp file.
%
@@ -202,8 +204,9 @@
:- pred target_is_grade_or_arch_dependent(module_target_type::in) is semidet.
%-----------------------------------------------------------------------------%
-
- % Debugging, verbose and error messages.
+%
+% Debugging, verbose and error messages.
+%
% Apply the given predicate if `--debug-make' is set.
%
@@ -248,9 +251,12 @@
make_info::in, make_info::out, io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- implementation.
+%-----------------------------------------------------------------------------%
+
foldl2_maybe_stop_at_error(KeepGoing, MakeTarget,
Targets, Success, !Info, !IO) :-
foldl2_maybe_stop_at_error_2(KeepGoing, MakeTarget, Targets,
@@ -1002,4 +1008,6 @@
this_file = "make.util.m".
+%-----------------------------------------------------------------------------%
+:- end_module make.util.
%-----------------------------------------------------------------------------%
Index: compiler/process_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/process_util.m,v
retrieving revision 1.14
diff -u -r1.14 process_util.m
--- compiler/process_util.m 22 Mar 2005 06:40:18 -0000 1.14
+++ compiler/process_util.m 22 Apr 2005 04:09:22 -0000
@@ -27,23 +27,24 @@
% build_with_check_for_interrupt(Build, Cleanup,
% Succeeded, Info0, Info)
%
- % Apply `Build' with signal handlers installed to check for signals
- % which would normally kill the process. If a signal occurs call
- % `Cleanup', then restore signal handlers to their defaults and
- % reraise the signal to kill the current process.
+ % Apply `Build' with signal handlers installed to check for
+ % signals which would normally kill the process. If a signal
+ % occurs call `Cleanup', then restore signal handlers to their
+ % defaults and reraise the signal to kill the current process.
% An action being performed in a child process by
% call_in_forked_process will be killed if a fatal signal
% (SIGINT, SIGTERM, SIGHUP or SIGQUIT) is received by the
- % current process.
- % An action being performed within the current process or by
- % system() will run to completion, with the interrupt being taken
- % immediately afterwards.
+ % current process. An action being performed within the current
+ % process or by system() will run to completion, with the
+ % interrupt being taken immediately afterwards.
+ %
:- pred build_with_check_for_interrupt(build0(Info)::in(build0),
post_signal_cleanup(Info)::in(post_signal_cleanup), bool::out,
Info::in, Info::out, io::di, io::uo) is det.
% raise_signal(Signal).
% Send `Signal' to the current process.
+ %
:- pred raise_signal(int::in, io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
@@ -52,6 +53,7 @@
:- inst io_pred == (pred(out, di, uo) is det).
% Does fork() work on the current platform.
+ %
:- pred can_fork is semidet.
% call_in_forked_process(P, AltP, Succeeded)
@@ -65,14 +67,17 @@
%
% If fork() is not supported on the current architecture,
% `AltP' will be called instead in the current process.
+ %
:- pred call_in_forked_process(io_pred::in(io_pred), io_pred::in(io_pred),
bool::out, io::di, io::uo) is det.
% As above, but if fork() is not available, just call the
% predicate in the current process.
+ %
:- pred call_in_forked_process(io_pred::in(io_pred), bool::out,
io::di, io::uo) is det.
+%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
:- implementation.
--------------------------------------------------------------------------
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