summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2019-08-27 12:12:30 +0200
committerRémi Verschelde <rverschelde@gmail.com>2019-08-29 13:22:17 +0200
commitb948b3884033dc8c0bfbd5fbe40751f8b9892e45 (patch)
tree5437c05ae55d558f7ab79291bf910c9f6d62a271 /platform/android
parent9762372329253a5d89feac7705770eb2f8e0cc04 (diff)
SCons: Generate android_source.zip during build
This is now needed after #27781, as this android_source.zip template is used for custom Android builds from the editor.
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/SCsub22
1 files changed, 22 insertions, 0 deletions
diff --git a/platform/android/SCsub b/platform/android/SCsub
index d2f27817c6..1bd8161fa7 100644
--- a/platform/android/SCsub
+++ b/platform/android/SCsub
@@ -55,3 +55,25 @@ if lib_arch_dir != '':
stl_lib_path = str(env['ANDROID_NDK_ROOT']) + '/sources/cxx-stl/llvm-libc++/libs/' + lib_arch_dir + '/libc++_shared.so'
env_android.Command(out_dir + '/libc++_shared.so', stl_lib_path, Copy("$TARGET", "$SOURCE"))
+
+# Zip android/java folder for the source export template.
+print("Archiving platform/android/java as bin/android_source.zip...")
+import os
+import zipfile
+# Change dir to avoid have zipped paths start from the android/java folder.
+olddir = os.getcwd()
+os.chdir(Dir('#platform/android/java').abspath)
+bindir = Dir('#bin').abspath
+# Make 'bin' dir if missing, can happen on fresh clone.
+if not os.path.exists(bindir):
+ os.makedirs(bindir)
+zipf = zipfile.ZipFile(os.path.join(bindir, 'android_source.zip'), 'w', zipfile.ZIP_DEFLATED)
+exclude_dirs = ['.gradle', 'build', 'libs', 'patches']
+for root, dirs, files in os.walk('.', topdown=True):
+ # Change 'dirs' in place to exclude folders we don't want.
+ # https://stackoverflow.com/a/19859907
+ dirs[:] = [d for d in dirs if d not in exclude_dirs]
+ for f in files:
+ zipf.write(os.path.join(root, f))
+zipf.close()
+os.chdir(olddir)