[m-rev.] for review: hacks to build standard library in java grade
Peter Wang
novalazy at gmail.com
Thu Apr 30 15:35:59 AEST 2009
Branches: main
Introduce hacks to make it possible to build the standard library in the Java
grade, even though sub-modules aren't yet supported by the Java backend.
library/Mmakefile:
Copy submodule source files into package directories as expected by
javac, e.g. thread.mvar.java -> thread_/mvar.java
Make `jars' target include source files in package directories.
diff --git a/library/Mmakefile b/library/Mmakefile
index 07f0b94..cd54653 100644
--- a/library/Mmakefile
+++ b/library/Mmakefile
@@ -248,17 +248,25 @@ endif
# likewise use `mr_enum'. Since Java implementations often assume that
# a class foo is located in a file foo.java, we similarly mangle the
# Java file names for these standard library modules.
+# We also need to fix up the file names for nested modules.
JAVAS = ` echo $($(STD_LIB_NAME).javas) | sed \
-e 's/ int.java/ mr_int.java/' \
-e 's/ float.java/ mr_float.java/' \
-e 's/ char.java/ mr_char.java/' \
- -e 's/ enum.java/ mr_enum.java/' `
+ -e 's/ enum.java/ mr_enum.java/' \
+ -e 's: bit_buffer.read.java: bit_buffer_/read.java:' \
+ -e 's: bit_buffer.write.java: bit_buffer_/write.java:' \
+ -e 's: stream.string_writer.java: stream_/string_writer.java:' \
+ -e 's: string.builder.java: string_/builder.java:' \
+ -e 's: thread.channel.java: thread_/channel.java:' \
+ -e 's: thread.mvar.java: thread_/mvar.java:' \
+ -e 's: thread.semaphore.java: thread_/semaphore.java:' `
# We need to invoke javac on all of the classes at the same time,
# rather than compiling them separately. This is needed because
# otherwise javac doesn't handle cyclic dependencies between different
# modules.
-classes: javas java_symlinks
+classes: javas java_symlinks java_subdir_copies
$(JAVAC) $(ALL_JAVACFLAGS) $(JAVAS)
# javac expects to find the sources for symbols named mercury.* in
@@ -272,6 +280,22 @@ java_symlinks:
[ -d mercury ] || ln -s . mercury
[ -d runtime ] || ln -s $(MERCURY_DIR)/java/runtime .
+# Mercury doesn't yet put .java files in the directory hierarchies that Java
+# expects. For now we copy a few files manually.
+.PHONY: java_subdir_copies
+java_subdir_copies:
+ [ -d bit_buffer_ ] || mkdir bit_buffer_
+ [ -d stream_ ] || mkdir stream_
+ [ -d string_ ] || mkdir string_
+ [ -d thread_ ] || mkdir thread_
+ cp bit_buffer.read.java bit_buffer_/read.java
+ cp bit_buffer.write.java bit_buffer_/write.java
+ cp stream.string_writer.java stream_/string_writer.java
+ cp string.builder.java string_/builder.java
+ cp thread.channel.java thread_/channel.java
+ cp thread.mvar.java thread_/mvar.java
+ cp thread.semaphore.java thread_/semaphore.java
+
# Once all of the library classes have been compiled, we put them in a single
# jar file. At this point we also add the runtime classes to a jar file.
# Note that this stage makes use of the symbolic links created earlier to
@@ -286,7 +310,11 @@ JARS = $(STD_LIB_NAME).jar $(RT_LIB_NAME).jar
# any architecture-specific objects.
.PHONY: jars
jars: classes
- $(JAR) $(JAR_CREATE_FLAGS) $(STD_LIB_NAME).jar mercury/*.class
+ $(JAR) $(JAR_CREATE_FLAGS) $(STD_LIB_NAME).jar mercury/*.class \
+ mercury/bit_buffer_/*.class \
+ mercury/stream_/*.class \
+ mercury/string_/*.class \
+ mercury/thread_/*.class
$(JAR) $(JAR_CREATE_FLAGS) $(RT_LIB_NAME).jar mercury/runtime/*.class
-+cd mercury/runtime && mmake $(NATIVE_SO)
-cp mercury/runtime/$(NATIVE_SO) .
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list