[m-rev.] for review: Mmake support for Java
Fergus Henderson
fjh at cs.mu.OZ.AU
Tue Feb 19 16:50:06 AEDT 2002
Estimated hours taken: 2
Branches: main
Add Mmake support for the Java back-end.
XXX TODO: Document it.
compiler/modules.m:
Add rules for generating `foo.javas' and `foo.classes' targets
and variables.
scripts/Mmake.rules:
compiler/modules.m:
Add rules for building .java, .java_date, and .class files.
scripts/Mmake.vars.in:
Add variables JAVAC, ALL_JAVACFLAGS, JAVACFLAGS, EXTRA_JAVACFLAGS,
TARGET_JAVACFLAGS, LIB_JAVACFLAGS, javas_subdir, java_dates_subdir,
and classes_subdir.
Also add some comments.
Workspace: /home/ceres/fjh/mercury
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.218
diff -u -d -r1.218 modules.m
--- compiler/modules.m 16 Feb 2002 18:19:11 -0000 1.218
+++ compiler/modules.m 19 Feb 2002 05:43:34 -0000
@@ -779,6 +779,8 @@
; Ext = ".ss"
; Ext = ".pic_ss"
; Ext = ".ils"
+ ; Ext = ".javas"
+ ; Ext = ".classes"
; Ext = ".opts"
; Ext = ".trans_opts"
% The current interface to `mercury_update_interface'
@@ -1904,6 +1906,8 @@
module_name_to_file_name(ModuleName, ".rlo", no, RLOFileName),
module_name_to_file_name(ModuleName, ".il_date", no,
ILDateFileName),
+ module_name_to_file_name(ModuleName, ".java_date", no,
+ JavaDateFileName),
module_name_to_file_name(ModuleName, ".pic_o", no,
PicObjFileName),
module_name_to_file_name(ModuleName, ".int0", no,
@@ -1919,7 +1923,8 @@
PicAsmDateFileName, " ",
SplitObjPattern, " ",
RLOFileName, " ",
- ILDateFileName
+ ILDateFileName, " ",
+ JavaDateFileName
] ),
write_dependencies_list(ParentDeps, ".optdate", DepStream),
write_dependencies_list(ParentDeps,
@@ -1930,6 +1935,7 @@
write_dependencies_list(ParentDeps, ".dir/*.$O", DepStream),
write_dependencies_list(ParentDeps, ".rlo", DepStream),
write_dependencies_list(ParentDeps, ".il_date", DepStream),
+ write_dependencies_list(ParentDeps, ".java_date", DepStream),
io__write_strings(DepStream, [" : ", SourceFileName]),
% If the module contains nested sub-modules then `.int0'
% file must first be built.
@@ -1970,7 +1976,8 @@
PicAsmDateFileName, " ",
SplitObjPattern, " ",
RLOFileName, " ",
- ILDateFileName, " : "
+ ILDateFileName, " ",
+ JavaDateFileName, " : "
]),
% The target (e.g. C) file only depends on the .opt files
@@ -2002,7 +2009,8 @@
PicAsmDateFileName, " ",
SplitObjPattern, " ",
RLOFileName, " ",
- ILDateFileName, " : "
+ ILDateFileName, " ",
+ JavaDateFileName, " : "
]),
write_dependencies_list(TransOptDeps,
".trans_opt", DepStream)
@@ -2302,6 +2310,10 @@
"\t$(MCG) $(ALL_GRADEFLAGS) $(ALL_MCGFLAGS) ",
"--il-only $< > ", ErrFileName,
" 2>&1\n",
+ JavaDateFileName, " : ", SourceFileName, "\n",
+ "\t$(MCG) $(ALL_GRADEFLAGS) $(ALL_MCGFLAGS) ",
+ "--java-only $< > ", ErrFileName,
+ " 2>&1\n",
RLOFileName, " : ", SourceFileName, "\n",
"\t$(MCG) $(ALL_GRADEFLAGS) $(ALL_MCGFLAGS) ",
"--aditi-only $< > ", ErrFileName,
@@ -3398,6 +3410,18 @@
io__write_string(DepStream, "\n"),
io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".javas = "),
+ write_compact_dependencies_list(Modules, "$(javas_subdir)", ".java",
+ Basis, DepStream),
+ io__write_string(DepStream, "\n"),
+
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".classes = "),
+ write_compact_dependencies_list(Modules, "$(classes_subdir)", ".class",
+ Basis, DepStream),
+ io__write_string(DepStream, "\n"),
+
+ io__write_string(DepStream, MakeVarName),
io__write_string(DepStream, ".dirs = "),
write_compact_dependencies_list(Modules, "$(dirs_subdir)", ".dir",
Basis, DepStream),
@@ -3452,6 +3476,12 @@
io__write_string(DepStream, "\n"),
io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".java_dates = "),
+ write_compact_dependencies_list(Modules, "$(java_dates_subdir)",
+ ".java_date", Basis, DepStream),
+ io__write_string(DepStream, "\n"),
+
+ io__write_string(DepStream, MakeVarName),
io__write_string(DepStream, ".ds = "),
write_compact_dependencies_list(Modules, "$(ds_subdir)", ".d",
Basis, DepStream),
@@ -3860,6 +3890,10 @@
RLOsTargetName),
module_name_to_file_name(ModuleName, ".ils", no,
ILsTargetName),
+ module_name_to_file_name(ModuleName, ".javas", no,
+ JavasTargetName),
+ module_name_to_file_name(ModuleName, ".classes", no,
+ ClassesTargetName),
% We need to explicitly mention
% $(foo.pic_ss) somewhere in the Mmakefile, otherwise it
@@ -3887,7 +3921,11 @@
".PHONY : ", RLOsTargetName, "\n",
RLOsTargetName, " : $(", MakeVarName, ".rlos)\n\n",
".PHONY : ", ILsTargetName, "\n",
- ILsTargetName, " : $(", MakeVarName, ".ils)\n\n"
+ ILsTargetName, " : $(", MakeVarName, ".ils)\n\n",
+ ".PHONY : ", JavasTargetName, "\n",
+ JavasTargetName, " : $(", MakeVarName, ".javas)\n\n",
+ ".PHONY : ", ClassesTargetName, "\n",
+ ClassesTargetName, " : $(", MakeVarName, ".classes)\n\n"
]),
@@ -3923,10 +3961,12 @@
InitPicObjFileName, " | xargs rm -f\n",
"\t-echo $(", MakeVarName, ".c_dates) | xargs rm -f\n",
"\t-echo $(", MakeVarName, ".il_dates) | xargs rm -f\n",
+ "\t-echo $(", MakeVarName, ".java_dates) | xargs rm -f\n",
"\t-echo $(", MakeVarName, ".all_s_dates) | xargs rm -f\n",
"\t-echo $(", MakeVarName, ".all_pic_s_dates) | xargs rm -f\n",
"\t-echo $(", MakeVarName, ".useds) | xargs rm -f\n",
"\t-echo $(", MakeVarName, ".ils) | xargs rm -f\n",
+ "\t-echo $(", MakeVarName, ".javas) | xargs rm -f\n",
"\t-echo $(", MakeVarName, ".profs) | xargs rm -f\n",
"\t-echo $(", MakeVarName, ".errs) | xargs rm -f\n",
"\t-echo $(", MakeVarName, ".foreign_cs) | xargs rm -f\n",
@@ -3957,6 +3997,7 @@
"\t-echo $(", MakeVarName, ".all_hs) | xargs rm -f\n",
"\t-echo $(", MakeVarName, ".dlls) | xargs rm -f\n",
"\t-echo $(", MakeVarName, ".foreign_dlls) | xargs rm -f\n",
+ "\t-echo $(", MakeVarName, ".classes) | xargs rm -f\n",
"\t-echo $(", MakeVarName, ".rlos) | xargs rm -f\n"
]),
io__write_strings(DepStream, [
Index: scripts/Mmake.rules
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.rules,v
retrieving revision 1.114
diff -u -d -r1.114 Mmake.rules
--- scripts/Mmake.rules 7 Jan 2002 06:27:17 -0000 1.114
+++ scripts/Mmake.rules 19 Feb 2002 04:18:42 -0000
@@ -22,8 +22,9 @@
.i .s .pic_s \
.ql .pl \
.rlo \
+ .java .class \
.il .dll .exe .cpp .cs \
- .c_date .il_date .s_date .pic_s_date
+ .c_date .il_date .java_date .s_date .pic_s_date
#-----------------------------------------------------------------------------#
#
@@ -49,6 +50,7 @@
.PRECIOUS: $(trans_opt_dates_subdir)%.trans_opt_date
.PRECIOUS: $(c_dates_subdir)%.c_date
.PRECIOUS: $(il_dates_subdir)%.il_date
+.PRECIOUS: $(java_dates_subdir)%.java_date
.PRECIOUS: $(s_dates_subdir)%.s_date
.PRECIOUS: $(pic_s_dates_subdir)%.pic_s_date
@@ -236,6 +238,24 @@
# Aditi-RL back-end
$(rlos_subdir)%.rlo : %.m
$(MCG) $(ALL_GRADEFLAGS) $(ALL_MCGFLAGS) --aditi-only $< > $*.err 2>&1
+
+# Java back-end
+
+# XXX Need to fix this rule to work properly with --use-subdirs,
+# i.e. put the .class file in the $(classes_subdir) directory
+# (since javac doesn't have a `-o' option to name the object file,
+# we may need to use `mv' to move it?)
+$(classes_subdir)%.class: $(javas_subdir)%.java
+ $(JAVAC) $<
+
+# When smart recompilation finds that a module does not need to be
+# recompiled, it only touches the `.java_date' file.
+# XXX does smart recompilation actually work for the Java back-end??
+$(javas_subdir)%.java: $(java_dates_subdir)%.java_date
+ @:
+
+$(java_dates_subdir)%.java_date : %.m
+ $(MCG) $(ALL_GRADEFLAGS) $(ALL_MCGFLAGS) --java-only $< > $*.err 2>&1
# .NET back-end
Index: scripts/Mmake.vars.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.vars.in,v
retrieving revision 1.62
diff -u -d -r1.62 Mmake.vars.in
--- scripts/Mmake.vars.in 7 Feb 2002 03:10:59 -0000 1.62
+++ scripts/Mmake.vars.in 19 Feb 2002 04:16:00 -0000
@@ -56,6 +56,18 @@
ASM_OPT =
endif
+#-----------------------------------------------------------------------------#
+#-----------------------------------------------------------------------------#
+#
+# The following variables hold the names of various programs and
+# the options which should be passed to them.
+#
+#-----------------------------------------------------------------------------#
+#-----------------------------------------------------------------------------#
+#
+# Stuff which is not specific to any back-end
+#
+
ALL_GRADEFLAGS = $(USUAL_GRADEFLAGS) $(ASM_OPT)
USUAL_GRADEFLAGS = $(GRADEFLAGS) $(EXTRA_GRADEFLAGS) $(TARGET_GRADEFLAGS)
GRADEFLAGS = --grade $(GRADE)
@@ -113,10 +125,11 @@
EXTRA_MCGFLAGS = $(EXTRA_MCFLAGS)
EXTRA_MCSFLAGS = $(EXTRA_MCFLAGS)
+#-----------------------------------------------------------------------------#
#
-# The following variables hold the names of various programs and
-# the options which should be passed to them.
+# Stuff which is specific to the C back-ends
#
+
MGNUC = mgnuc
ALL_MGNUCFLAGS = $(MGNUCFLAGS) $(EXTRA_MGNUCFLAGS) $(TARGET_MGNUCFLAGS) \
$(LIB_MGNUCFLAGS) -- $(ALL_CFLAGS)
@@ -128,6 +141,11 @@
CFLAGS =
EXTRA_CFLAGS =
+#-----------------------------------------------------------------------------#
+#
+# Stuff for the .NET back-end
+#
+
# MS_CL is the command line version of Microsoft Visual C++, which we
# use to compile Managed C++ code in the .NET backend.
MS_CL = @MS_CL@
@@ -169,6 +187,26 @@
EXTRA_MS_CSCFLAGS =
LIB_MS_CSCFLAGS =
+#-----------------------------------------------------------------------------#
+#
+# Stuff for the Java back-end
+#
+
+# JAVAC is the command line java compiler;
+# it should generate .class files from .java files.
+JAVAC = javac
+ALL_JAVACFLAGS = $(JAVACFLAGS) $(EXTRA_JAVACFLAGS) $(TARGET_JAVACFLAGS) \
+ $(LIB_JAVACFLAGS)
+JAVACFLAGS =
+EXTRA_JAVACFLAGS =
+# XXX Should we set LIB_JAVACFLAGS?
+LIB_JAVACFLAGS =
+
+#-----------------------------------------------------------------------------#
+#
+# Stuff related to linking (for the C and assembler back-ends).
+#
+
C2INIT = c2init
ALL_C2INITFLAGS = $(C2INIT_AND_MLFLAGS)
C2INITFLAGS =
@@ -218,6 +256,12 @@
EXTRA_MLLIBS =
LIB_MLLIBS = $(patsubst %,-l%,$(ALL_EXTRA_LIBRARIES))
+#-----------------------------------------------------------------------------#
+#
+# Stuff related to the Prolog back-ends
+# (XXX This is all obsolete and should probably be deleted)
+#
+
MNC = mnc
ALL_MNCFLAGS = $(MNCFLAGS) $(EXTRA_MNCFLAGS) $(TARGET_MNCFLAGS)
MNCFLAGS =
@@ -248,6 +292,11 @@
MSPFLAGS =
EXTRA_MSPFLAGS =
+#-----------------------------------------------------------------------------#
+#
+# Stuff related to creating libraries
+#
+
AR = @AR@
ALL_ARFLAGS = $(ARFLAGS) $(EXTRA_ARFLAGS) $(TARGET_ARFLAGS)
ARFLAGS = @ARFLAGS@
@@ -436,6 +485,11 @@
maybe-target-ILASM_KEYFLAG- = $(ILASM_KEYFLAG-$*)
maybe-target-ILASM_KEYFLAG-undefined =
+TARGET_JAVACFLAGS = \
+ $(maybe-base-JAVACFLAGS-$(findstring undefined,$(origin JAVACFLAGS-$*)))
+maybe-base-JAVACFLAGS- = $(JAVACFLAGS-$*)
+maybe-base-JAVACFLAGS-undefined =
+
# Support for compiling Mercury programs with Prolog will probably be
# dropped one of these days, so it's probably not worth bothering with these.
TARGET_MNCFLAGS =
@@ -484,11 +538,14 @@
# doesn't know about `--use-subdirs'.
rlos_subdir=
ils_subdir=$(SUBDIR)ils/
+javas_subdir=$(SUBDIR)javas/
dirs_subdir=$(SUBDIR)dirs/
c_dates_subdir=$(SUBDIR)c_dates/
s_dates_subdir=$(SUBDIR)s_dates/
pic_s_dates_subdir=$(SUBDIR)pic_s_dates/
il_dates_subdir=$(SUBDIR)il_dates/
+java_dates_subdir=$(SUBDIR)java_dates/
+classes_subdir=$(SUBDIR)classs/
else
@@ -517,11 +574,14 @@
os_subdir=
rlos_subdir=
ils_subdir=
+javas_subdir=
dirs_subdir=
c_dates_subdir=
s_dates_subdir=
pic_s_dates_subdir=
il_dates_subdir=
+java_dates_subdir=
+classes_subdir=
endif
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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