[m-rev.] diff: make --smart-recompilation work with the compiler
Simon Taylor
stayl at cs.mu.OZ.AU
Mon Jun 10 04:06:56 AEST 2002
Estimated hours taken: 1
Branches: main
Make smart recompilation work where the module name doesn't
match the file name (e.g. in the compiler).
compiler/modules.m:
Where the module name doesn't match the file name
and there is a Mercury.modules file, pass the
module name to mmc, not the file name.
compiler/source_file_map.m:
Add a predicate `have_source_file_map' for use
by modules.m.
Don't write put the Mercury.modules file in the
Mercury subdirectory. It's the user's responsibility
to clean it up, so it should be in the main directory.
compiler/mercury_compile.m:
Suggest creating the Mercury.modules file if passed
a file name which doesn't match the module name.
compiler/Mmakefile:
browser/Mmakefile:
Generate the Mercury.modules file.
tests/hard_coded/Mmakefile:
The Mercury.modules file is no longer generated in
the Mercury subdirectory.
Index: browser/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/Mmakefile,v
retrieving revision 1.20
diff -u -u -r1.20 Mmakefile
--- browser/Mmakefile 13 May 2002 08:09:38 -0000 1.20
+++ browser/Mmakefile 8 Jun 2002 17:48:19 -0000
@@ -73,9 +73,13 @@
all : library browse_test declarative_test
.PHONY: depend
-depend : $(BROWSER_LIB_NAME).depend \
+depend : Mercury.modules $(BROWSER_LIB_NAME).depend \
browse_test.depend declarative_test.depend
+.PHONY: Mercury.modules
+Mercury.modules:
+ $(MC) -f *.m
+
.PHONY: check
check : $(BROWSER_LIB_NAME).check
@@ -128,7 +132,7 @@
# libmer_browser.* to the files.
realclean_local:
rm -rf libmdb.so libmdb.a mdb.init
- rm -f tags
+ rm -f Mercury.modules tags
#-----------------------------------------------------------------------------#
Index: compiler/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Mmakefile,v
retrieving revision 1.56
diff -u -u -r1.56 Mmakefile
--- compiler/Mmakefile 11 May 2002 22:28:39 -0000 1.56
+++ compiler/Mmakefile 8 Jun 2002 17:48:02 -0000
@@ -164,7 +164,11 @@
.PHONY: depend
depend: $(MC_PROG).depend
-$(MC_PROG).depend: regenerate_preprocessed_files
+$(MC_PROG).depend: regenerate_preprocessed_files Mercury.modules
+
+.PHONY: Mercury.modules
+Mercury.modules:
+ $(MC) -f *.m
.PHONY: all
all: mercury
@@ -267,7 +271,7 @@
rm -f ../main.$O $(PREPROCESSED_M_FILES) $(PP_DATE_FILES)
realclean_local:
- rm -f tags $(MC_PROG).stats
+ rm -f tags $(MC_PROG).stats Mercury.modules
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.252
diff -u -u -r1.252 mercury_compile.m
--- compiler/mercury_compile.m 30 May 2002 12:55:01 -0000 1.252
+++ compiler/mercury_compile.m 9 Jun 2002 18:04:42 -0000
@@ -648,7 +648,9 @@
prog_out__write_sym_name(ModuleName),
io__write_string(".\n"),
io__write_string(
- " Smart recompilation will not work with this module.\n"),
+ " Smart recompilation will not work unless a module name\n"),
+ io__write_string(
+ " to file name mapping is created using `mmc -f *.m'.\n"),
( { Halt = yes } ->
io__set_exit_status(1)
;
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.233
diff -u -u -r1.233 modules.m
--- compiler/modules.m 30 May 2002 12:55:09 -0000 1.233
+++ compiler/modules.m 8 Jun 2002 12:20:23 -0000
@@ -1875,7 +1875,7 @@
%-----------------------------------------------------------------------------%
write_dependency_file(Module, AllDepsSet, MaybeTransOptDeps) -->
- { Module = module_imports(SourceFileName, _SourceFileModuleName,
+ { Module = module_imports(SourceFileName, SourceFileModuleName,
ModuleName, ParentDeps, IntDeps, ImplDeps,
IndirectDeps, _Children, InclDeps, _NestDeps,
FactDeps0, ContainsForeignCode, ForeignImports0,
@@ -2410,47 +2410,64 @@
% changes to scripts/Mmake.rules. See that
% file for documentation on these rules.
%
+
+ %
+ % If we can pass the module name rather than the
+ % file name then do so. `--smart-recompilation'
+ % doesn't work if the file name is passed and the
+ % module name doesn't match the file name.
+ %
+ have_source_file_map(HaveMap),
+ { HaveMap = yes,
+ prog_out__sym_name_to_string(
+ SourceFileModuleName, ".", ModuleArg)
+ ; HaveMap = no,
+ ModuleArg = SourceFileName
+ },
+
io__write_strings(DepStream, [
"\n",
Date0FileName, " : ", SourceFileName, "\n",
- "\t$(MCPI) $(ALL_MCPIFLAGS) $<\n",
+ "\t$(MCPI) $(ALL_MCPIFLAGS) ", ModuleArg, "\n",
DateFileName, " : ", SourceFileName, "\n",
- "\t$(MCI) $(ALL_MCIFLAGS) $<\n",
+ "\t$(MCI) $(ALL_MCIFLAGS) ", ModuleArg, "\n",
Date3FileName, " : ", SourceFileName, "\n",
- "\t$(MCSI) $(ALL_MCSIFLAGS) $<\n",
+ "\t$(MCSI) $(ALL_MCSIFLAGS) ", ModuleArg, "\n",
OptDateFileName, " : ", SourceFileName, "\n",
- "\t$(MCOI) $(ALL_MCOIFLAGS) $<\n",
+ "\t$(MCOI) $(ALL_MCOIFLAGS) ", ModuleArg, "\n",
TransOptDateFileName, " : ", SourceFileName,
"\n",
- "\t$(MCTOI) $(ALL_MCTOIFLAGS) $<\n",
+ "\t$(MCTOI) $(ALL_MCTOIFLAGS) ", ModuleArg,
+ "\n",
CDateFileName, " : ", SourceFileName, "\n",
"\t$(MCG) $(ALL_GRADEFLAGS) $(ALL_MCGFLAGS) ",
- "$< > ", ErrFileName, " 2>&1\n",
+ ModuleArg, " > ", ErrFileName,
+ " 2>&1\n",
"ifeq ($(TARGET_ASM),yes)\n",
AsmDateFileName, " : ", SourceFileName, "\n",
"\t$(MCG) $(ALL_GRADEFLAGS) $(ALL_MCGFLAGS) ",
- "--target-code-only $< > ", ErrFileName,
- " 2>&1\n",
+ "--target-code-only ", ModuleArg,
+ " > ", ErrFileName, " 2>&1\n",
PicAsmDateFileName, " : ", SourceFileName, "\n",
"\t$(MCG) $(ALL_GRADEFLAGS) $(ALL_MCGFLAGS) ",
"--target-code-only --pic ",
"\\\n",
"\t\t--cflags ""$(GCCFLAGS_FOR_PIC)"" ",
- "$< > ", ErrFileName,
+ ModuleArg, " > ", ErrFileName,
" 2>&1\n",
"endif # TARGET_ASM\n",
ILDateFileName, " : ", SourceFileName, "\n",
"\t$(MCG) $(ALL_GRADEFLAGS) $(ALL_MCGFLAGS) ",
- "--il-only $< > ", ErrFileName,
- " 2>&1\n",
+ "--il-only ", ModuleArg, " > ",
+ ErrFileName, " 2>&1\n",
JavaDateFileName, " : ", SourceFileName, "\n",
"\t$(MCG) $(ALL_GRADEFLAGS) $(ALL_MCGFLAGS) ",
- "--java-only $< > ", ErrFileName,
- " 2>&1\n",
+ "--java-only ", ModuleArg, " > ",
+ ErrFileName, " 2>&1\n",
RLOFileName, " : ", SourceFileName, "\n",
"\t$(MCG) $(ALL_GRADEFLAGS) $(ALL_MCGFLAGS) ",
- "--aditi-only $< > ", ErrFileName,
- " 2>&1\n"
+ "--aditi-only ", ModuleArg, " > ",
+ ErrFileName, " 2>&1\n"
])
;
[]
Index: compiler/source_file_map.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/source_file_map.m,v
retrieving revision 1.2
diff -u -u -r1.2 source_file_map.m
--- compiler/source_file_map.m 8 Jun 2002 13:51:26 -0000 1.2
+++ compiler/source_file_map.m 8 Jun 2002 17:50:04 -0000
@@ -13,7 +13,7 @@
:- interface.
:- import_module parse_tree__prog_data, parse_tree__prog_io.
-:- import_module io, list.
+:- import_module bool, io, list.
% lookup_module_source_file(ModuleName, FileName, FileNameIsMapped).
%
@@ -22,6 +22,9 @@
:- pred lookup_module_source_file(module_name::in, file_name::out,
io__state::di, io__state::uo) is det.
+ % Return `yes' if there is a valid Mercury.modules file.
+:- pred have_source_file_map(bool::out, io__state::di, io__state::uo) is det.
+
% Return the default fully-qualified source file name.
:- func default_source_file(module_name) = file_name.
@@ -36,7 +39,7 @@
:- import_module parse_tree__prog_out, parse_tree__prog_util.
:- import_module parse_tree__modules.
:- import_module libs__globals, libs__options.
-:- import_module bool, char, dir, map, std_util, string.
+:- import_module char, dir, map, std_util, string.
lookup_module_source_file(ModuleName, FileName) -->
get_source_file_map(SourceFileMap),
@@ -49,6 +52,16 @@
default_source_file(ModuleName) = BaseFileName ++ ".m" :-
prog_out__sym_name_to_string(ModuleName, ".", BaseFileName).
+have_source_file_map(HaveMap) -->
+ get_source_file_map(_),
+ globals__io_get_globals(Globals),
+ { globals__get_source_file_map(Globals, MaybeSourceFileMap) },
+ { MaybeSourceFileMap = yes(Map), \+ map__is_empty(Map) ->
+ HaveMap = yes
+ ;
+ HaveMap = no
+ }.
+
% Read the Mercury.modules file (if it exists) to find
% the mapping from module name to file name.
:- pred get_source_file_map(source_file_map::out,
@@ -60,8 +73,7 @@
( { MaybeSourceFileMap0 = yes(SourceFileMap0) } ->
{ SourceFileMap = SourceFileMap0 }
;
- globals__io_lookup_bool_option(use_subdirs, UseSubdirs),
- io__open_input(modules_file_name(UseSubdirs), OpenRes),
+ io__open_input(modules_file_name, OpenRes),
(
{ OpenRes = ok(Stream) },
io__set_input_stream(Stream, OldStream),
@@ -143,13 +155,7 @@
).
write_source_file_map(FileNames) -->
- globals__io_lookup_bool_option(use_subdirs, UseSubdirs),
- ( { UseSubdirs = yes } ->
- make_directory("Mercury")
- ;
- []
- ),
- { ModulesFileName = modules_file_name(UseSubdirs) },
+ { ModulesFileName = modules_file_name },
io__open_output(ModulesFileName, OpenRes),
(
{ OpenRes = ok(Stream) },
@@ -198,7 +204,6 @@
{ MaybeModuleName = no }
).
-:- func modules_file_name(bool) = string.
+:- func modules_file_name = string.
-modules_file_name(yes) = "Mercury/Mercury.modules".
-modules_file_name(no) = "Mercury.modules".
+modules_file_name = "Mercury.modules".
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.151
diff -u -u -r1.151 Mmakefile
--- tests/hard_coded/Mmakefile 7 May 2002 11:02:42 -0000 1.151
+++ tests/hard_coded/Mmakefile 7 Jun 2002 19:32:00 -0000
@@ -317,7 +317,7 @@
RESS= $(PROGS:%=%.res) $(SPLIT_PROGS:%=%.split.res)
dep_local: $(DEPS)
-depend_local: $(SUBDIR)/Mercury.modules $(DEPENDS)
+depend_local: Mercury.modules $(DEPENDS)
check_local: $(OUTS) $(RESS)
all_local: $(PROGS) $(SPLIT_PROGS:%=%.split)
@@ -325,13 +325,14 @@
rm -f target_mlobjs_c.o
realclean_local:
- rm -f $(SUBDIR)/Mercury.modules
+ rm -f Mercury.modules
#-----------------------------------------------------------------------------#
SUBDIRS = typeclasses sub-modules exceptions purity
-$(SUBDIR)/Mercury.modules:
+.PHONY: Mercury.modules
+Mercury.modules:
$(MC) -f $(ALL_MCFLAGS) source_file_map.m
dep_subdirs:
--------------------------------------------------------------------------
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