New build (#508)
* fix build for openssl 1.1.1b required for sdk (cherry picked from commitaa49e3b275
) * use js code from master * fix openssl recipe and tweak build (cherry picked from commit6e94c27021
) * remove unused build recipes (cherry picked from commitf5c0577bdb
)
This commit is contained in:
parent
f853132e9b
commit
8b2694efb7
340 changed files with 12797 additions and 5034 deletions
p4a/pythonforandroid
|
@ -1,17 +1,39 @@
|
|||
from os.path import (join, dirname, isdir, splitext, basename)
|
||||
from os import listdir
|
||||
from os.path import (join, dirname, isdir, normpath, splitext, basename)
|
||||
from os import listdir, walk, sep
|
||||
import sh
|
||||
import shlex
|
||||
import glob
|
||||
import json
|
||||
import importlib
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from pythonforandroid.logger import (warning, shprint, info, logger,
|
||||
debug)
|
||||
from pythonforandroid.util import (current_directory, ensure_dir,
|
||||
temp_directory, which)
|
||||
temp_directory)
|
||||
from pythonforandroid.recipe import Recipe
|
||||
|
||||
|
||||
def copy_files(src_root, dest_root, override=True):
|
||||
for root, dirnames, filenames in walk(src_root):
|
||||
for filename in filenames:
|
||||
subdir = normpath(root.replace(src_root, ""))
|
||||
if subdir.startswith(sep): # ensure it is relative
|
||||
subdir = subdir[1:]
|
||||
dest_dir = join(dest_root, subdir)
|
||||
if not os.path.exists(dest_dir):
|
||||
os.makedirs(dest_dir)
|
||||
src_file = join(root, filename)
|
||||
dest_file = join(dest_dir, filename)
|
||||
if os.path.isfile(src_file):
|
||||
if override and os.path.exists(dest_file):
|
||||
os.unlink(dest_file)
|
||||
if not os.path.exists(dest_file):
|
||||
shutil.copy(src_file, dest_file)
|
||||
else:
|
||||
os.makedirs(dest_file)
|
||||
|
||||
|
||||
class Bootstrap(object):
|
||||
'''An Android project template, containing recipe stuff for
|
||||
compilation and templated fields for APK info.
|
||||
|
@ -27,7 +49,11 @@ class Bootstrap(object):
|
|||
dist_name = None
|
||||
distribution = None
|
||||
|
||||
recipe_depends = ['sdl2']
|
||||
# All bootstraps should include Python in some way:
|
||||
recipe_depends = [
|
||||
("python2", "python2legacy", "python3", "python3crystax"),
|
||||
'android',
|
||||
]
|
||||
|
||||
can_be_chosen_automatically = True
|
||||
'''Determines whether the bootstrap can be chosen as one that
|
||||
|
@ -78,6 +104,9 @@ class Bootstrap(object):
|
|||
def get_dist_dir(self, name):
|
||||
return join(self.ctx.dist_dir, name)
|
||||
|
||||
def get_common_dir(self):
|
||||
return os.path.abspath(join(self.bootstrap_dir, "..", 'common'))
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
modname = self.__class__.__module__
|
||||
|
@ -87,9 +116,10 @@ class Bootstrap(object):
|
|||
'''Ensure that a build dir exists for the recipe. This same single
|
||||
dir will be used for building all different archs.'''
|
||||
self.build_dir = self.get_build_dir()
|
||||
shprint(sh.cp, '-r',
|
||||
join(self.bootstrap_dir, 'build'),
|
||||
self.build_dir)
|
||||
self.common_dir = self.get_common_dir()
|
||||
copy_files(join(self.bootstrap_dir, 'build'), self.build_dir)
|
||||
copy_files(join(self.common_dir, 'build'), self.build_dir,
|
||||
override=False)
|
||||
if self.ctx.symlink_java_src:
|
||||
info('Symlinking java src instead of copying')
|
||||
shprint(sh.rm, '-r', join(self.build_dir, 'src'))
|
||||
|
@ -102,26 +132,15 @@ class Bootstrap(object):
|
|||
fileh.write('target=android-{}'.format(self.ctx.android_api))
|
||||
|
||||
def prepare_dist_dir(self, name):
|
||||
# self.dist_dir = self.get_dist_dir(name)
|
||||
ensure_dir(self.dist_dir)
|
||||
|
||||
def run_distribute(self):
|
||||
# print('Default bootstrap being used doesn\'t know how '
|
||||
# 'to distribute...failing.')
|
||||
# exit(1)
|
||||
with current_directory(self.dist_dir):
|
||||
info('Saving distribution info')
|
||||
with open('dist_info.json', 'w') as fileh:
|
||||
json.dump({'dist_name': self.ctx.dist_name,
|
||||
'bootstrap': self.ctx.bootstrap.name,
|
||||
'archs': [arch.arch for arch in self.ctx.archs],
|
||||
'recipes': self.ctx.recipe_build_order + self.ctx.python_modules},
|
||||
fileh)
|
||||
self.distribution.save_info(self.dist_dir)
|
||||
|
||||
@classmethod
|
||||
def list_bootstraps(cls):
|
||||
'''Find all the available bootstraps and return them.'''
|
||||
forbidden_dirs = ('__pycache__', )
|
||||
forbidden_dirs = ('__pycache__', 'common')
|
||||
bootstraps_dir = join(dirname(__file__), 'bootstraps')
|
||||
for name in listdir(bootstraps_dir):
|
||||
if name in forbidden_dirs:
|
||||
|
@ -152,7 +171,7 @@ class Bootstrap(object):
|
|||
for recipe in recipes:
|
||||
try:
|
||||
recipe = Recipe.get_recipe(recipe, ctx)
|
||||
except IOError:
|
||||
except ValueError:
|
||||
conflicts = []
|
||||
else:
|
||||
conflicts = recipe.conflicts
|
||||
|
@ -160,7 +179,7 @@ class Bootstrap(object):
|
|||
for conflict in conflicts]):
|
||||
ok = False
|
||||
break
|
||||
if ok:
|
||||
if ok and bs not in acceptable_bootstraps:
|
||||
acceptable_bootstraps.append(bs)
|
||||
info('Found {} acceptable bootstraps: {}'.format(
|
||||
len(acceptable_bootstraps),
|
||||
|
@ -249,16 +268,22 @@ class Bootstrap(object):
|
|||
info('Python was loaded from CrystaX, skipping strip')
|
||||
return
|
||||
env = arch.get_env()
|
||||
strip = which('arm-linux-androideabi-strip', env['PATH'])
|
||||
if strip is None:
|
||||
warning('Can\'t find strip in PATH...')
|
||||
return
|
||||
strip = sh.Command(strip)
|
||||
filens = shprint(sh.find, join(self.dist_dir, 'private'),
|
||||
join(self.dist_dir, 'libs'),
|
||||
tokens = shlex.split(env['STRIP'])
|
||||
strip = sh.Command(tokens[0])
|
||||
if len(tokens) > 1:
|
||||
strip = strip.bake(tokens[1:])
|
||||
|
||||
libs_dir = join(self.dist_dir, '_python_bundle',
|
||||
'_python_bundle', 'modules')
|
||||
if self.ctx.python_recipe.name == 'python2legacy':
|
||||
libs_dir = join(self.dist_dir, 'private')
|
||||
filens = shprint(sh.find, libs_dir, join(self.dist_dir, 'libs'),
|
||||
'-iname', '*.so', _env=env).stdout.decode('utf-8')
|
||||
|
||||
logger.info('Stripping libraries in private dir')
|
||||
for filen in filens.split('\n'):
|
||||
if not filen:
|
||||
continue # skip the last ''
|
||||
try:
|
||||
strip(filen, _env=env)
|
||||
except sh.ErrorReturnCode_1:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue