Introjucer's build.xml "clean" target doesn't clean all the way


#1

Using the version of Introjucer that comes with JUCE 3.0.4 (just updated today), calling "ant clean" fails to remove the intermediate build files located in the obj and libs directories. Furthermore, since obj and libs aren't removed, then if you call "ant clean" and then call "ant debug" or "ant release" again, it doesn't rebuild any C++. This is how it works on my setup on Mac OS X, anyway.

Jules actually mentions in the context of a tangentially-related thread here (http://www.juce.com/comment/276949#comment-276949) that ant clean doesn't seem to work, and that he's using a shell script to clean intermediate files. I don't know if the reasons for both of these problems are the same, but at least on my machine it still doesn't seem to actually clean.

Luckily it's possible to tweak Introjucer's build.xml output to make it all work. Right now, the auto-generated build.xml contains the following XML for the "clean" target:

  <target name="clean">
    <exec executable="${ndk.dir}/ndk-build" dir="${basedir}" failonerror="true">
      <arg value="clean"/>
    </exec>
  </target>

Just make it say this instead and you're clear:

  <target name="clean" depends="android_rules.clean">
    <delete dir="obj" />
    <delete dir="libs" />
    <exec executable="${ndk.dir}/ndk-build" dir="${basedir}" failonerror="true">
      <arg value="clean"/>
    </exec>
  </target>

I'm not sure if there's some even neater way of doing things, but it does ensure that "ant clean" actually cleans.


#2

Hmm, I could add that, but are you using r9? There seems to have been a bug in the build tools which was fixed: https://code.google.com/p/android/issues/detail?id=59228


#3

I am using r9 - if I go to ${NDK_DIR}/build/core/build-binary.mk, the patch for the missing $ is already there. However, "ant clean" still doesn't get rid of obj and libs.

Does it on your end?

BTW, I think that adding depends="android_rules.clean" may be a good idea no matter what - I see that attribute in most references for how to set up an "ant clean" for NDK when Googling, and it might be useful in dealing with weird errors like "[aapt] invalid resource directory name: ..../Builds/Android/bin/res/crunch" and so on. (speculative)


#4

Ok, ta - this all seems sensible, I'll add it!