[m-rev.] diff: Setting the Java classpath automatically.

James Goddard goddardjames at yahoo.com
Thu Feb 12 13:49:53 AEDT 2004


Estimated hours taken: 1.5
Branches: main

Simplify use of the Java grade by automatically setting the classpath.

scripts/Mercury.config.in:
scripts/Mercury.config.bootstrap.in:
	Set the --java-classpath option in DEFAULT_MC_FLAGS.
	Define STD_LIB_NAME, RT_LIB_NAME.

scripts/c2init.in:
	Add the above two files to the list of those which use STD_LIB_NAME and
	RT_LIB_NAME.

library/Mmakefile:
	Use RT_LIB_NAME instead of STD_LIB_NAME.runtime

compiler/modules.m:
	Remove the XXX comment that worries about this issue.

README.Java:
	Remove instructions relating to setting the classpath manually.

------------------------------------------------------------------------------
Index: scripts/Mercury.config.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mercury.config.in,v
retrieving revision 1.8
diff -u -d -r1.8 Mercury.config.in
--- scripts/Mercury.config.in	11 Feb 2004 03:50:06 -0000	1.8
+++ scripts/Mercury.config.in	12 Feb 2004 02:38:18 -0000
@@ -29,6 +29,14 @@
 # be used by the substitution for SHARED_LIBS.
 MATH_LIB=$(MERCURY_MATH_LIB)
 
+# This needed for Java classpath.
+INSTALL_JAVA_LIBRARY_DIR=$(MERCURY_STDLIB_DIR)/lib/java
+
+# If you change these, you will also need to change the files indicated in
+# scripts/c2init.in.
+RT_LIB_NAME=mer_rt
+STD_LIB_NAME=mer_std
+
 DEFAULT_MERCURY_LINKAGE=@DEFAULT_LINKAGE@
 
 # The default optimization level should be after
@@ -49,6 +57,8 @@
 		--cflags-for-gotos "@CFLAGS_FOR_GOTOS@" \
 		--cflags-for-pic "@CFLAGS_FOR_PIC@" \
 		--c-flag-to-name-object-file "@OBJFILE_OPT@" \
+		--java-classpath "$(INSTALL_JAVA_LIBRARY_DIR)/$(RT_LIB_NAME).jar" \
+		--java-classpath "$(INSTALL_JAVA_LIBRARY_DIR)/$(STD_LIB_NAME).jar" \
 		--object-file-extension ". at OBJ_SUFFIX@" \
 		--pic-object-file-extension ". at EXT_FOR_PIC_OBJECTS@" \
 		--link-with-pic-object-file-extension ". at EXT_FOR_LINK_WITH_PIC_OBJECTS@" \
Index: scripts/Mercury.config.bootstrap.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mercury.config.bootstrap.in,v
retrieving revision 1.3
diff -u -d -r1.3 Mercury.config.bootstrap.in
--- scripts/Mercury.config.bootstrap.in	11 Feb 2004 04:28:09 -0000	1.3
+++ scripts/Mercury.config.bootstrap.in	12 Feb 2004 02:38:38 -0000
@@ -30,6 +30,14 @@
 # be used by the substitution for SHARED_LIBS.
 MATH_LIB=$(MERCURY_MATH_LIB)
 
+# This needed for Java classpath.
+INSTALL_JAVA_LIBRARY_DIR=$(MERCURY_STDLIB_DIR)/lib/java
+
+# If you change these, you will also need to change the files indicated in
+# scripts/c2init.in.
+RT_LIB_NAME=mer_rt
+STD_LIB_NAME=mer_std
+
 DEFAULT_MERCURY_LINKAGE=@DEFAULT_LINKAGE@
 
 # The default optimization level should be after
@@ -52,6 +60,8 @@
 		--cflags-for-gotos "@CFLAGS_FOR_GOTOS@" \
 		--cflags-for-pic "@CFLAGS_FOR_PIC@" \
 		--c-flag-to-name-object-file "@OBJFILE_OPT@" \
+		--java-classpath "$(INSTALL_JAVA_LIBRARY_DIR)/$(RT_LIB_NAME).jar" \
+		--java-classpath "$(INSTALL_JAVA_LIBRARY_DIR)/$(STD_LIB_NAME).jar" \
 		--object-file-extension ". at OBJ_SUFFIX@" \
 		--pic-object-file-extension ". at EXT_FOR_PIC_OBJECTS@" \
 		--link-with-pic-object-file-extension ". at EXT_FOR_LINK_WITH_PIC_OBJECTS@" \
Index: scripts/c2init.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/c2init.in,v
retrieving revision 1.41
diff -u -d -r1.41 c2init.in
--- scripts/c2init.in	27 Oct 2003 06:00:41 -0000	1.41
+++ scripts/c2init.in	12 Feb 2004 02:34:05 -0000
@@ -39,6 +39,8 @@
 #	compiler/compile_target_code.m
 #	scripts/c2init.in
 #	scripts/ml.in
+#	scripts/Mercury.config.in
+#	scripts/Mercury.config.bootstrap.in
 #	tools/bootcheck,
 #	tools/binary
 #	tools/binary_step
Index: library/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/library/Mmakefile,v
retrieving revision 1.131
diff -u -d -r1.131 Mmakefile
--- library/Mmakefile	11 Feb 2004 03:50:18 -0000	1.131
+++ library/Mmakefile	12 Feb 2004 02:42:38 -0000
@@ -246,7 +246,7 @@
 # ensure that the path names are correct within the jar files.
 # We also compile NATIVE_SO here and copy it into the library directory.
 
-JARS = $(STD_LIB_NAME).jar $(STD_LIB_NAME).runtime.jar
+JARS = $(STD_LIB_NAME).jar $(RT_LIB_NAME).jar
 
 # We ignore the exit status of the last two commands because NATIVE_SO is not
 # an essential part of the Mercury standard library for the Java
@@ -255,8 +255,7 @@
 .PHONY:	jars
 jars:	classes
 	$(JAR) $(JAR_CREATE_FLAGS) $(STD_LIB_NAME).jar mercury/*.class
-	$(JAR) $(JAR_CREATE_FLAGS) $(STD_LIB_NAME).runtime.jar \
-			mercury/runtime/*.class
+	$(JAR) $(JAR_CREATE_FLAGS) $(RT_LIB_NAME).jar mercury/runtime/*.class
 	-+cd mercury/runtime && mmake $(NATIVE_SO)
 	-cp mercury/runtime/$(NATIVE_SO) .
 
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.289
diff -u -d -r1.289 modules.m
--- compiler/modules.m	9 Feb 2004 12:13:28 -0000	1.289
+++ compiler/modules.m	12 Feb 2004 02:30:30 -0000
@@ -7196,12 +7196,8 @@
 
 	% XXX PathSeparator should be ";" on Windows
 	{ PathSeparator = ":" },
-	% XXX The correct classpath needs to be set somewhere.
-	%     It should take the form:
-	%     DirName:<path>/mer_std.jar:<path>/mer_std.runtime.jar:.
-	%     Currently this variable is empty, which causes problems, so
-	%     we prepend the .class files' directory and the current CLASSPATH.
 	globals__io_lookup_accumulating_option(java_classpath, Java_Incl_Dirs0),
+	% We prepend the .class files' directory and the current CLASSPATH.
 	{ Java_Incl_Dirs = [DirName, "$CLASSPATH" | Java_Incl_Dirs0] },
 	{ ClassPath = string.join_list(PathSeparator, Java_Incl_Dirs) },
 
Index: README.Java
===================================================================
RCS file: /home/mercury1/repository/mercury/README.Java,v
retrieving revision 1.4
diff -u -d -r1.4 README.Java
--- README.Java	11 Feb 2004 23:52:56 -0000	1.4
+++ README.Java	11 Feb 2004 23:54:03 -0000
@@ -37,21 +37,8 @@
 bytecode.  The java grade is enabled by using any of the options
 `--grade java', `--target java', or just `--java'.
 
-Support for building and installation of this grade
-is still somewhat rudimentary.
-
 To run a Mercury program using the java grade, you need to build the Mercury
 library and runtime in the java grade, using the Mercury source distribution.
-
-You will also need to set the environment variable CLASSPATH to include the
-mercury standard and runtime libraries for java, as well as the current
-directory.  You should use a command of the form:
-
-	CLASSPATH=<prefix>/mer_std.jar:<prefix>/mer_std.runtime.jar:.
-	export CLASSPATH
-
-where <prefix> is the location of the installed jar files, which will probably
-be /usr/local/mercury/lib/mercury/lib/java or something similar.
 
 You can now build programs such as hello.m or calculator.m in the samples
 directory.
--------------------------------------------------------------------------
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