[m-rev.] For review: Set Java classpath automatically.
James Goddard
goddardjames at yahoo.com
Wed Feb 11 17:13:31 AEDT 2004
Estimated hours taken: 2
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.
compiler/modules.m:
Remove the XXX comment that worrys about this issue.
README.Java:
Remove instructions relating to setting the classpath manually.
-------------------------------------------------------------------
diff -u README.Java README.Java
--- README.Java 11 Feb 2004 04:09:33 -0000
+++ README.Java 11 Feb 2004 05:11:41 -0000
@@ -37,22 +37,9 @@
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.
only in patch2:
--- compiler/modules.m 9 Feb 2004 12:13:28 -0000 1.289
+++ compiler/modules.m 11 Feb 2004 05:49:44 -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) },
only in patch2:
--- scripts/Mercury.config.bootstrap.in 11 Feb 2004 04:28:09 -0000 1.3
+++ scripts/Mercury.config.bootstrap.in 11 Feb 2004 06:09:38 -0000
@@ -29,6 +29,10 @@
# $(MATH_LIB) needs to be defined because it may
# 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
+# XXX Should this be derived from elsewhere?
+STD_LIB_NAME=mer_std
DEFAULT_MERCURY_LINKAGE=@DEFAULT_LINKAGE@
@@ -52,6 +56,9 @@
--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)/$(STD_LIB_NAME).runtime.jar" \
+ --java-classpath "$(INSTALL_JAVA_LIBRARY_DIR)/$(STD_LIB_NAME).jar" \
+ --java-classpath "." \
--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@" \
only in patch2:
--- scripts/Mercury.config.in 11 Feb 2004 03:50:06 -0000 1.8
+++ scripts/Mercury.config.in 11 Feb 2004 06:09:29 -0000
@@ -28,6 +28,10 @@
# $(MATH_LIB) needs to be defined because it may
# 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
+# XXX Should this be derived from elsewhere?
+STD_LIB_NAME=mer_std
DEFAULT_MERCURY_LINKAGE=@DEFAULT_LINKAGE@
@@ -49,6 +53,9 @@
--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)/$(STD_LIB_NAME).runtime.jar" \
+ --java-classpath "$(INSTALL_JAVA_LIBRARY_DIR)/$(STD_LIB_NAME).jar" \
+ --java-classpath "." \
--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@" \
--------------------------------------------------------------------------
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