[m-rev.] diff: java grade on cygwin

Peter Wang novalazy at gmail.com
Wed Oct 21 16:41:38 AEDT 2009


[two patches]

Branches: main

library/Mmakefile:
        Copy java/runtime directory rather than creating a symbolic link.
        Under Cygwin, the symlink won't be understood by the Java compiler.


diff --git a/library/Mmakefile b/library/Mmakefile
index 545fcc0..5353f22 100644
--- a/library/Mmakefile
+++ b/library/Mmakefile
@@ -170,7 +170,7 @@ mercury: lib_std
 #-----------------------------------------------------------------------------#
 
 .PHONY: depend
-depend:	LIB_FLAGS java_symlinks $(STD_LIB_NAME).depend
+depend:	LIB_FLAGS copy_java_runtime_files $(STD_LIB_NAME).depend
 
 .PHONY: check
 check:	$(STD_LIB_NAME).check
@@ -250,14 +250,14 @@ endif
 # jmercury/runtime/*, but in our sources those symbols actually come from
 # java/runtime/*.  So we set up a symbolic link to help javac find the way to
 # the sources.
-.PHONY: java_symlinks
+.PHONY: copy_java_runtime_files
 .PHONY: install_mer_rt
 
 ifeq ("$(findstring java,$(GRADE))","java")
 
-java_symlinks:
+copy_java_runtime_files:
 	[ -d jmercury ] || mkdir jmercury
-	[ -d jmercury/runtime ] || ln -s ../../java/runtime jmercury/runtime
+	[ -d jmercury/runtime ] || cp -r ../java/runtime jmercury
 
 install_mer_rt: $(RT_LIB_NAME).jar
 	mkdir -p $(INSTALL_JAVA_LIBRARY_DIR)
@@ -265,7 +265,7 @@ install_mer_rt: $(RT_LIB_NAME).jar
 
 else
 
-java_symlinks:
+copy_java_runtime_files:
 
 install_mer_rt:
 
@@ -276,7 +276,7 @@ ifeq ($(MMAKE_USE_MMC_MAKE),yes)
 $(STD_LIB_NAME).jar: libmer_std
 endif
 
-$(RT_LIB_NAME).jar: java_symlinks
+$(RT_LIB_NAME).jar: copy_java_runtime_files
 	$(JAVAC) $(ALL_JAVACFLAGS) jmercury/runtime/*.java
 	$(JAR) $(JAR_CREATE_FLAGS) $(RT_LIB_NAME).jar jmercury/runtime/*.class
 	$(JAR) i $(RT_LIB_NAME).jar

====

Branches: main

Fix two problems using the Java grade on Cygwin.

compiler/compile_target_code.m:
        We were creating a temporary file in /tmp, whose path would be passed
        to `jar', which might not be a Cygwin program.  It would interpret
        that path differently and be unable to open the file.  The fix is to
        create the temporary file in the current directory.

        Use ";" as the classpath separator if `io.have_cygwin' succeeds.


diff --git a/compiler/compile_target_code.m b/compiler/compile_target_code.m
index 22d2bfb..720b83c 100644
--- a/compiler/compile_target_code.m
+++ b/compiler/compile_target_code.m
@@ -915,7 +915,11 @@ compile_java_files(ErrorStream, JavaFiles, Globals, Succeeded, !IO) :-
 
     globals.lookup_accumulating_option(Globals, java_classpath,
         Java_Incl_Dirs),
-    ( dir.use_windows_paths ->
+    (
+        ( dir.use_windows_paths
+        ; io.have_cygwin
+        )
+    ->
         PathSeparator = ";"
     ;
         PathSeparator = ":"
@@ -2393,8 +2397,10 @@ create_java_archive(Globals, ErrorStream, JarFileName, ObjectList, Succeeded,
 
     % Write the list of class files to a temporary file and pass the name of
     % the temporary file to jar using @syntax.  The list of class files can be
-    % extremely long.
-    io.make_temp(TempFileName, !IO),
+    % extremely long.  We create the temporary file in the current directory to
+    % avoid problems under Cygwin, where absolute paths will be interpreted
+    % incorrectly when passed to a non-Cygwin jar program.
+    io.make_temp(".", "mtmp", TempFileName, !IO),
     io.open_output(TempFileName, OpenResult, !IO),
     (
         OpenResult = ok(Stream),
--------------------------------------------------------------------------
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