Closed jskuse closed 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 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.
— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/haxenme/nme/issues/315
Hi Hugh, thanks for the response. I've just returned to this to have a look if I could make it work as per your suggestion and am happy to report that all is well.
It definitely seems that the most robust approach in general (across targets) would be to copy any user defined template files after the base template. For what it's worth, every bit of easily google-able advice on this (admittedly generally OpenFL focussed) suggests the first approach I tried, so it might also aid in helping people migrating to NME.
My original concept was the "templatePath" stuff, where you would copy & modify the template files locally. Joshua added the "rename" stuff various places later - I guess he really likes a flat directory structure. As you say, most of the web stuff brings up the "openfl way" so the solution is really to support this too..
On Mon, May 16, 2016 at 10:43 PM, jskuse notifications@github.com wrote:
Closed #315 https://github.com/haxenme/nme/issues/315.
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/haxenme/nme/issues/315#event-661698833
I can absolutely see what you were going for now - it makes a lot of sense to copy the whole template rather than a partial one for all manner of reasons.
I think the rename attribute thing does feel a touch clunky too, certainly not ideal. I think the confusion on my part came because the "rename" approach mostly worked rather than not at all. But, yeah, it might be worth making work none the less simply in the name of compatibility.
Thanks again for your help!
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: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 viaplatform.updateExtra()
which is called last.It doesn't look like
FileHelper.copyFile()
does aisNewer()
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.