|
8 | 8 | import shlex |
9 | 9 | import shutil |
10 | 10 |
|
11 | | -from pythonforandroid.logger import (shprint, info, logger, debug) |
| 11 | +from pythonforandroid.logger import (shprint, info, info_main, logger, debug) |
12 | 12 | from pythonforandroid.util import ( |
13 | 13 | current_directory, ensure_dir, temp_directory, BuildInterruptingException, |
14 | 14 | rmdir, move) |
@@ -184,11 +184,52 @@ def prepare_build_dir(self): |
184 | 184 | def prepare_dist_dir(self): |
185 | 185 | ensure_dir(self.dist_dir) |
186 | 186 |
|
| 187 | + def _assemble_distribution_for_arch(self, arch): |
| 188 | + """Per-architecture distribution assembly. |
| 189 | +
|
| 190 | + Override this method to customize per-arch behavior. |
| 191 | + Called once for each architecture in self.ctx.archs. |
| 192 | + """ |
| 193 | + self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)]) |
| 194 | + self.distribute_aars(arch) |
| 195 | + |
| 196 | + python_bundle_dir = join(f'_python_bundle__{arch.arch}', '_python_bundle') |
| 197 | + ensure_dir(python_bundle_dir) |
| 198 | + site_packages_dir = self.ctx.python_recipe.create_python_bundle( |
| 199 | + join(self.dist_dir, python_bundle_dir), arch) |
| 200 | + if not self.ctx.with_debug_symbols: |
| 201 | + self.strip_libraries(arch) |
| 202 | + self.fry_eggs(site_packages_dir) |
| 203 | + |
187 | 204 | def assemble_distribution(self): |
188 | | - ''' Copies all the files into the distribution (this function is |
189 | | - overridden by the specific bootstrap classes to do this) |
190 | | - and add in the distribution info. |
191 | | - ''' |
| 205 | + """Assemble the distribution by copying files and creating Python bundle. |
| 206 | +
|
| 207 | + This default implementation works for most bootstraps. Override |
| 208 | + _assemble_distribution_for_arch() for per-arch customization, or |
| 209 | + override this entire method for fundamentally different behavior. |
| 210 | + """ |
| 211 | + info_main(f'# Creating Android project ({self.name})') |
| 212 | + |
| 213 | + rmdir(self.dist_dir) |
| 214 | + shprint(sh.cp, '-r', self.build_dir, self.dist_dir) |
| 215 | + |
| 216 | + with current_directory(self.dist_dir): |
| 217 | + with open('local.properties', 'w') as fileh: |
| 218 | + fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir)) |
| 219 | + |
| 220 | + with current_directory(self.dist_dir): |
| 221 | + info('Copying Python distribution') |
| 222 | + |
| 223 | + self.distribute_javaclasses(self.ctx.javaclass_dir, |
| 224 | + dest_dir=join("src", "main", "java")) |
| 225 | + |
| 226 | + for arch in self.ctx.archs: |
| 227 | + self._assemble_distribution_for_arch(arch) |
| 228 | + |
| 229 | + if 'sqlite3' not in self.ctx.recipe_build_order: |
| 230 | + with open('blacklist.txt', 'a') as fileh: |
| 231 | + fileh.write('\nsqlite3/*\nlib-dynload/_sqlite3.so\n') |
| 232 | + |
192 | 233 | self._copy_in_final_files() |
193 | 234 | self.distribution.save_info(self.dist_dir) |
194 | 235 |
|
|
0 commit comments