#244 cc Task Fails with Spaces in Source File Paths

open
Curt Arnold
cpptasks (103)
7
2011-07-07
2011-07-07
No

I had the following fairly simple task:

<cc name="g++" objdir="${rawsockets.dir.output.native}" outtype="static" rebuild="true" relentless="true"
warnings="diagnostic" optimize="full" failonerror="true">
<defineset define="_REENTRANT" />
<includepath path="${jdk.include.1.6}" />
<fileset dir="${rawsockets.dir.build.source.native}" includes="*.cpp" />
</cc>

That resulted in this error:

[cc] 3 total files to be compiled.
[cc] g++ -c -O2 -D_REENTRANT -W -Wall -I/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/include '"/Users/Nicholas/Documents/Nick Williams Technology Services/Java Projects/RawSockets/trunk/src/native/RawSocketImpl.cpp"' '"/Users/Nicholas/Documents/Nick Williams Technology Services/Java Projects/RawSockets/trunk/src/native/Constants.cpp"' '"/Users/Nicholas/Documents/Nick Williams Technology Services/Java Projects/RawSockets/trunk/src/native/SocketUtilities.cpp"'
[cc] i686-apple-darwin10-g++-4.2.1: "/Users/Nicholas/Documents/Nick Williams Technology Services/Java Projects/RawSockets/trunk/src/native/RawSocketImpl.cpp": No such file or directory
[cc] i686-apple-darwin10-g++-4.2.1: "/Users/Nicholas/Documents/Nick Williams Technology Services/Java Projects/RawSockets/trunk/src/native/Constants.cpp": No such file or directory
[cc] i686-apple-darwin10-g++-4.2.1: "/Users/Nicholas/Documents/Nick Williams Technology Services/Java Projects/RawSockets/trunk/src/native/SocketUtilities.cpp": No such file or directory
[cc] i686-apple-darwin10-g++-4.2.1: no input files

BUILD FAILED
/Users/Nicholas/Documents/Nick Williams Technology Services/Java Projects/RawSockets/trunk/ant-build.xml:184: g++ failed with return code 1
at net.sf.antcontrib.cpptasks.compiler.CommandLineCompiler.compile(CommandLineCompiler.java:215)
at net.sf.antcontrib.cpptasks.compiler.CommandLineCompilerConfiguration.compile(CommandLineCompilerConfiguration.java:133)
at net.sf.antcontrib.cpptasks.CCTask.execute(CCTask.java:732)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:809)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

I figured the spaces must be the culprit, so I created the spaceless /Users/Nicholas/RawSocketsNativeSrc symlink and changed the task:

<cc name="g++" objdir="${rawsockets.dir.output.native}" outtype="static" rebuild="true" relentless="true"
warnings="diagnostic" optimize="full" failonerror="true">
<defineset define="_REENTRANT" />
<includepath path="${jdk.include.1.6}" />
<fileset dir="/Users/Nicholas/RawSocketsNativeSrc" includes="*.cpp" />
</cc>

And now the compilation succeeds:

[cc] 3 total files to be compiled.
[cc] g++ -c -O2 -D_REENTRANT -W -Wall -I/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/include /Users/Nicholas/RawSocketsNativeSrc/RawSocketImpl.cpp /Users/Nicholas/RawSocketsNativeSrc/Constants.cpp /Users/Nicholas/RawSocketsNativeSrc/SocketUtilities.cpp

BUILD SUCCESSFUL

I looked at CommandLineCompiler.java#getInputFileArgument and figured lines 395-399 must be what's causing the issue, but I've never worked on this project and don't know enough about it to submit a patch.

If someone could come up with a patch pretty soon, at least I could start using that locally. This issue is making cpptasks rather unusable for me. :)

Suggestions?

Thanks!

Discussion

    • priority: 5 --> 7