Skip to content

Evil DOS characters breaks Java builder! #2610

Open

Description

@bdbaddog

This issue was originally created at: 2010-04-08 13:53:16.
This issue was reported by: weegreenblobbie.
weegreenblobbie said at 2010-04-08 13:53:16

I'm using swig and javac to eventually build a jar file. When trying to use the Java builder to build all the .java files in a sub directory, I discovered extraneous '\r\n' (evil dos) characters in the produced compiler command. This causes the build to fail.

I'm running in cygwin, here is my Sconscript file:

import sys
 
JDK = "/cygdrive/c/Program Files/Java/jdk1.6.0_18"
JAVAC = "/cygdrive/c/Program\ Files/Java/jdk1.6.0_18/bin/javac.exe"
 
JAVA_SOURCE = [
    "ArStatus.java",
    "Array.java",
    "Attrib.java",
    "COMPLEX.java",
    "DType.java",
    "SWIGTYPE_p_void.java",
    "VECTOR2.java",
    "VECTOR3.java",
    "VECTOR4.java",
    "VECTOR5.java",
    "VECTOR6.java",
    "libarray.java",
    "libarrayConstants.java",
    "libarrayJNI.java"]
 
# Import previous Exports
Import("*")
 
swig_env = env.Clone()
swig_env.Append(SWIGFLAGS = ["-java", "-package", "libaoa"])
swig_env.Append(SWIGPATH = ["../../include"])
swig_env.Append(CPPPATH = ["../../include"])
swig_env.Append(CPPPATH = ["%s/include" % JDK])
swig_env.Append(CPPPATH = ["%s/include/win32" % JDK])
swig_env.Append(LIBS = [libarray])
swig_env.Append(SHLINKFLAGS = '-Wl,--add-stdcall-alias')
swig_env.Append(JAVACLASSDIR = "java/swig")
swig_env["JAVAC"] = JAVAC
#~swig_env["JAVASOURCEPATH"] = "java/swig"
 
wrapper_obj = swig_env.SharedObject(["Array_wrap.c", "Array.i"])
jar_dll = swig_env.SharedLibrary("libaoa", wrapper_obj[0])
 
###############################################################################
# Compile java classes
jclasses = swig_env.Java(
    target = "./",
    source = "./")
 
###############################################################################
# Explicit dependancies
 
env.Depends(jar_dll, libarray)
env.Depends(JAVA_SOURCE, jar_dll)
env.Depends(jclasses, jar_dll)
 
###############################################################################
# Explicit Clean up
 
clean_targets = []
clean_targets.append("Array_wrap.c")
clean_targets.append(JAVA_SOURCE)
clean_targets.append(wrapper_obj[0])
clean_targets.append(jar_dll)
clean_targets.append(jclasses)
 
env.Clean(libarray, clean_targets)
 
env.Alias("jar_dll", jar_dll)
env.Alias("jar", jclasses)
env.Alias("jar", jar_dll)
 
# :mode=python:

Here is the command output:

$ scons  jar
scons: Reading SConscript files ...
Hello Cygwin!
 
CXXFLAGS =
LDFLAGS  =
 
checking compiler flags ... (cached) good
checking endianess ... (cached) little
checking if math.h defines M_PI ... (cached) yes
Checking char is 1 bytes... (cached) yes
Checking short is 2 bytes... (cached) yes
Checking int is 4 bytes... (cached) yes
Checking long long is 8 bytes... (cached) yes
Checking float is 4 bytes... (cached) yes
Checking double is 8 bytes... (cached) yes
scons: done reading SConscript files.
scons: Building targets ...
swig -o java/swig/Array_wrap.c -Iinclude -java -package libaoa java/swig/Array.i
 
/cygdrive/c/Program\ Files/Java/jdk1.6.0_18/bin/javac.exe -d java/swig -sourcepath java/swig java/swig/ArStatus.java java/swig/Array.java java/swig/Attrib.java java/swig/COMPLEX.java java/swig/DType.java java/swig/SWIGTYPE_p_void.java java/ swig/VECTOR2.java java/swig/VECTOR3.java java/swig/VECTOR4.java java/swig/VECTOR 5.java java/swig/VECTOR6.java java/swig/libarray.java java/swig/libarrayConstant JNI.javava/swig/libarrayyJNI.java java/swig/libarray
.java: file not found: java\swig\libarray
Usage: javac <options> <source files>
use -help for a list of possible options
scons: *** [java/swig/libaoa/ArStatus.class] Error 2
scons: building terminated because of errors.

Notice the last .java file on the compile command is truncated! I have discovered extraneous evil dos characters (^M below) in the compile command when I piped the output to less:

$ scons  jar 2>&1 | less
scons: Reading SConscript files ...
Hello Cygwin!
 
CXXFLAGS =
LDFLAGS  =
 
checking compiler flags ... (cached) good
checking endianess ... (cached) little
checking if math.h defines M_PI ... (cached) yes
Checking char is 1 bytes... (cached) yes
Checking short is 2 bytes... (cached) yes
Checking int is 4 bytes... (cached) yes
Checking long long is 8 bytes... (cached) yes
Checking float is 4 bytes... (cached) yes
Checking double is 8 bytes... (cached) yes
scons: done reading SConscript files.
scons: Building targets ...
swig -o java/swig/Array_wrap.c -Iinclude -java -package libaoa java/swig/Array.i/cygdrive/c/Program\ Files/Java/jdk1.6.0_18/bin/javac.exe -d java/swig -sourcepath java/swig java/swig/ArStatus.java java/swig/Array.java java/swig/Attrib.javajava/swig/COMPLEX.java java/swig/DType.java java/swig/SWIGTYPE_p_void.java java/swig/VECTOR2.java java/swig/VECTOR3.java java/swig/VECTOR4.java java/swig/VECTOR5.java java/swig/VECTOR6.java java/swig/libarray.java java/swig/libarrayConstants.java java/swig/libarrayJNI.java java/swig/libarray^M.java java/swig/libarray^M
^MJNI.java
javac: file not found: java\swig\libarray^M.java
Usage: javac <options> <source files>
use -help for a list of possible options
scons: *** [java/swig/libaoa/ArStatus.class] Error 2
scons: building terminated because of errors.

Any workarounds would be helpful!

Thanks,
Nick

weegreenblobbie said at 2010-04-08 14:31:05

Adding java to keywords

weegreenblobbie said at 2010-04-08 15:55:17

I've made a work around hack for this. Not ideal but gets the job done until
this bug is fixed.

#############################################################################
# Compile java classes
 
bld = Builder(action = '%s -d java/swig -sourcepath java/swig $SOURCES' % JAVAC,
              suffix = ".class",
              emitter = '$MY_EMITTER')
 
def modify1(target, source, env):
    jsrc = glob.glob("*.java")
 
    for i in range(0, len(jsrc)):
        target.append(jsrc[i].replace(".java", "class"))
 
    return target, jsrc
 
swig_env.Append(
    BUILDERS = {'MyJava' : bld},
    MY_EMITTER = modify1)
 
jclasses = swig_env.MyJava()

gregnoel said at 2010-04-30 16:30:25

Bug party triage. This looks like a good issue for Mike Fowler to get his feet wet. Steven to research and identify exactly where Mike should be looking, then pass it to him (2.1 p3) for action.

gregnoel said at 2010-07-21 17:00:31

Bug party triage. Bump the priority of this issue.

Votes for this issue: 1.

Activity

  1. added this to the milestone on Jan 2, 2018
  2. added
    Java
    on May 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions