def _make_partial_archive(zip_base, subdirs, root_dir): zip = zipfile.ZipFile(zip_base + ".zip", "w") with cd(root_dir): for subdir in subdirs: if not os.path.exists(subdir): continue for root, dirs, files in os.walk(subdir): for file in files: zip.write(os.path.join(root, file)) zip.close() return zip_base + ".zip"
def post_build_actions_android(self, binDir): android_platform = os.environ['ANDROID_PLATFORM'] print "Detected Android Platform as " + android_platform apkDir = "apk" if os.path.exists(apkDir): shutil.rmtree(apkDir) os.makedirs(apkDir+"/lib/armeabi") # Shared library directory os.makedirs(apkDir+"/assets") # Binary asset files (.ak) if not self.create_assets(apkDir+"/assets"): return False with build.cd(apkDir): # Copy everything we need into the apk directory #shutil.copy2("../classes.dex", "./") build.copy_files("../projects/ogltest/*.so", "lib/armeabi/") #shutil.copy2("../projects/ogltest/libpng/libpng16d.so", "lib/armeabi/libpng16.so") shutil.copy2("../../../../../src/projects/ogltest/AndroidManifest.xml", "./") shutil.copytree("../../../../../src/projects/ogltest/res", "res") # Create the APK buildCmd = "aapt package -f -M ./AndroidManifest.xml -S res/ -A assets/ -I " + android_platform + "/android.jar -F OGLtest.apk.unaligned" if call(buildCmd, shell=True) != 0: return False #buildCmd = "aapt add -f OGLtest.apk.unaligned classes.dex lib/armeabi/*" buildCmd = "aapt add -f OGLtest.apk.unaligned lib/armeabi/*" if call(buildCmd, shell=True) != 0: return False # Sign the package buildCmd = "jarsigner -sigalg MD5withRSA -digestalg SHA1 -storepass test1234 -keypass test1234 -keystore ~/akkeystore OGLtest.apk.unaligned ogltestkey" if call(buildCmd, shell=True) != 0: return False # Run zipalign buildCmd = "zipalign 4 OGLtest.apk.unaligned OGLtest.apk" if call(buildCmd, shell=True) != 0: return False shutil.copy2("apk/OGLtest.apk", binDir) if self.install: call("adb install -rdg " + binDir + "/OGLtest.apk", shell=True) return True
def create_assets(self, binDir): # create one .ak file for each subdirectory in projects/ogltest/data with build.cd("../../../../src/projects/ogltest/data"): for file in glob.glob("*.ak"): os.remove(file) for folder in os.listdir("."): if os.path.isdir(folder): print "Creating asset file " + folder + ".ak from folder " + folder + " ..." if self.system == "android": sys = "linux" elif self.system == "ios": sys = "osx" else: sys = self.system exe = os.path.join("..", "..", "..", "..", "gen", "akcab", sys, "debug", "AKCab") cmd = exe + " " + folder + ".ak -add -recursive " + folder if call(cmd, shell=True) != 0: return False build.copy_files("../../../../src/projects/ogltest/data/*.ak", binDir) print "Copying ../../../../src/projects/ogltest/data/*.ak to " + binDir return True