gradle: start supporting gradle-based build (sdl2_gradle)

This commit is contained in:
Mathieu Virbel 2017-05-06 18:02:19 +02:00
parent 7b2a2712db
commit bb643ce15b
2 changed files with 27 additions and 12 deletions

View file

@ -763,23 +763,36 @@ class TargetAndroid(Target):
pass pass
# XXX found how the apk name is really built from the title # XXX found how the apk name is really built from the title
bl = u'\'" ,' if exists(join(dist_dir, "build.gradle")):
apptitle = config.get('app', 'title') # on gradle build, the apk use the package name, and have no version
if hasattr(apptitle, 'decode'): packagename = config.get('app', 'package.name')
apptitle = apptitle.decode('utf-8') apk = u'{packagename}-{mode}.apk'.format(
apktitle = ''.join([x for x in apptitle if x not in bl]) packagename=packagename, mode=mode)
apk = u'{title}-{version}-{mode}.apk'.format( apk_dir = join(dist_dir, "build", "outputs", "apk")
title=apktitle, apk_dest = u'{packagename}-{version}-{mode}.apk'.format(
version=version, packagename=packagename, mode=mode, version=version)
mode=mode)
else:
# on ant, the apk use the title, and have version
bl = u'\'" ,'
apptitle = config.get('app', 'title')
if hasattr(apptitle, 'decode'):
apptitle = apptitle.decode('utf-8')
apktitle = ''.join([x for x in apptitle if x not in bl])
apk = u'{title}-{version}-{mode}.apk'.format(
title=apktitle,
version=version,
mode=mode)
apk_dir = join(dist_dir, "bin")
apk_dest = apk
# copy to our place # copy to our place
copyfile(join(dist_dir, 'bin', apk), join(self.buildozer.bin_dir, apk)) copyfile(join(apk_dir, apk), join(self.buildozer.bin_dir, apk_dest))
self.buildozer.info('Android packaging done!') self.buildozer.info('Android packaging done!')
self.buildozer.info( self.buildozer.info(
u'APK {0} available in the bin directory'.format(apk)) u'APK {0} available in the bin directory'.format(apk_dest))
self.buildozer.state['android:latestapk'] = apk self.buildozer.state['android:latestapk'] = apk_dest
self.buildozer.state['android:latestmode'] = self.build_mode self.buildozer.state['android:latestmode'] = self.build_mode
def _update_libraries_references(self, dist_dir): def _update_libraries_references(self, dist_dir):

View file

@ -98,6 +98,8 @@ class TargetAndroidNew(TargetAndroid):
elif option == "--sdk": elif option == "--sdk":
cmd.append("--android_api") cmd.append("--android_api")
cmd.extend(values) cmd.extend(values)
cmd.append("--sdk")
cmd.extend(values)
else: else:
cmd.extend(args) cmd.extend(args)