haxenme / nme

A cross-platform native backend for Haxe projects
MIT License
480 stars 123 forks source link

Custom AndroidManifest.xml gets overwritten #315

Closed jskuse closed 8 years ago

jskuse commented 8 years ago

We're just tidying up the loose ends on our game ready for launch and found ourselves needing to use a custom AndroidManifest.xml (to specify supported screen sizes) via a <template> tag in our project file, but it appears the order in which files are copied is scuppering us.

If I run nme update android -verbose, the relevant part of the output is as follows:

Running command: UPDATE
 - Copying file: templates/android/AndroidManifest.xml -> bin/android/tmapp/AndroidManifest.xml
 - Copying library file: /usr/lib/haxe/lib/nme/5,5,20//ndll/Android/libnme.so -> bin/android/tmapp/libs/armeabi/libnme.so
 - Copying library file: /usr/lib/haxe/lib/hxcpp/3,2,205//bin/Android/libstd.so -> bin/android/tmapp/libs/armeabi/libstd.so
 - Copying library file: /usr/lib/haxe/lib/hxcpp/3,2,205//bin/Android/libzlib.so -> bin/android/tmapp/libs/armeabi/libzlib.so
 - Copying library file: /usr/lib/haxe/lib/hxcpp/3,2,205//bin/Android/libregexp.so -> bin//android/tmapp/libs/armeabi/libregexp.so
 - Copying template file: /usr/lib/haxe/lib/nme/5,5,20/templates/android/PROJ/AndroidManifest.xml -> bin/android/tmapp/AndroidManifest.xml

So, it looks like nme's version of template is copied after the custom one and overwriting it.

Poking through the source reinforces this idea since it appears that templates are copied as part of platform.updateBuildDir() which is called at the start of update, whereas the Android project is copied via platform.updateExtra() which is called last.

It doesn't look like FileHelper.copyFile() does a isNewer() check for template files when it needs to do processing, so my naive quick fix solution was to add that and it seems to address the issue. However modifying a utility function so fundamental could have repercussions, so I figured it more sensible to flag up here rather than just blundering in with an undercooked pull request.

hughsando commented 8 years ago

Hi what if you put your override templates in the same directory structure, like "templates/android/PROJ/AndroidManifest.xml", with your templatePath name just pointing to your 'templates' directory (no 'rename') ? Then I think the template system should find yours preferentially, since it uses a simple search algorithm. But I could also do the explicit template copies at then end.

On Sat, May 7, 2016 at 7:12 PM, jskuse notifications@github.com wrote:

We're just tidying up the loose ends on our game ready for launch and found ourselves needing to use a custom AndroidManifest.xml (to specify supported screen sizes) via a