New build ()

* fix build for openssl 1.1.1b required for sdk
(cherry picked from commit aa49e3b2755b97b6331cdbbb89efc954de8d5977)

* use js code from master

* fix openssl recipe and tweak build
(cherry picked from commit 6e94c27021c7bd7b1e880c2fc314850e36a5a38e)

* remove unused build recipes
(cherry picked from commit f5c0577bdb175bfc0990602936bbc9e2052e1f25)
This commit is contained in:
Akinwale Ariwodola 2019-03-30 21:58:45 +01:00 committed by GitHub
parent f853132e9b
commit 8b2694efb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
340 changed files with 12797 additions and 5034 deletions
p4a/pythonforandroid

View file

@ -1,32 +1,37 @@
import contextlib
from os.path import exists
from os import getcwd, chdir, makedirs
from os.path import exists, join
from os import getcwd, chdir, makedirs, walk, uname
import io
import json
import sh
import shutil
import sys
from fnmatch import fnmatch
from tempfile import mkdtemp
try:
from urllib.request import FancyURLopener
except ImportError:
from urllib import FancyURLopener
from pythonforandroid.logger import (logger, Err_Fore)
from pythonforandroid.logger import (logger, Err_Fore, error, info)
IS_PY3 = sys.version_info[0] >= 3
if IS_PY3:
unistr = str
else:
unistr = unicode
class WgetDownloader(FancyURLopener):
version = ('Wget/1.17.1')
urlretrieve = WgetDownloader().retrieve
build_platform = '{system}-{machine}'.format(
system=uname()[0], machine=uname()[-1]).lower()
"""the build platform in the format `system-machine`. We use
this string to define the right build system when compiling some recipes or
to get the right path for clang compiler"""
@contextlib.contextmanager
def current_directory(new_dir):
cur_dir = getcwd()
@ -106,7 +111,7 @@ class JsonStore(object):
json.dump(self.data, fd, ensure_ascii=False)
else:
with io.open(self.filename, 'w', encoding='utf-8') as fd:
fd.write(unicode(json.dumps(self.data, ensure_ascii=False)))
fd.write(unicode(json.dumps(self.data, ensure_ascii=False))) # noqa F821
def which(program, path_env):
@ -130,18 +135,60 @@ def which(program, path_env):
return None
def get_directory(filename):
'''If the filename ends with a recognised file extension, return the
filename without this extension.'''
if filename.endswith('.tar.gz'):
return basename(filename[:-7])
elif filename.endswith('.tgz'):
return basename(filename[:-4])
elif filename.endswith('.tar.bz2'):
return basename(filename[:-8])
elif filename.endswith('.tbz2'):
return basename(filename[:-5])
elif filename.endswith('.zip'):
return basename(filename[:-4])
info('Unknown file extension for {}'.format(filename))
def get_virtualenv_executable():
virtualenv = None
if virtualenv is None:
virtualenv = sh.which('virtualenv2')
if virtualenv is None:
virtualenv = sh.which('virtualenv-2.7')
if virtualenv is None:
virtualenv = sh.which('virtualenv')
return virtualenv
def walk_valid_filens(base_dir, invalid_dir_names, invalid_file_patterns):
"""Recursively walks all the files and directories in ``dirn``,
ignoring directories that match any pattern in ``invalid_dirns``
and files that patch any pattern in ``invalid_filens``.
``invalid_dirns`` and ``invalid_filens`` should both be lists of
strings to match. ``invalid_dir_patterns`` expects a list of
invalid directory names, while ``invalid_file_patterns`` expects a
list of glob patterns compared against the full filepath.
File and directory paths are evaluated as full paths relative to ``dirn``.
"""
for dirn, subdirs, filens in walk(base_dir):
# Remove invalid subdirs so that they will not be walked
for i in reversed(range(len(subdirs))):
subdir = subdirs[i]
if subdir in invalid_dir_names:
subdirs.pop(i)
for filen in filens:
for pattern in invalid_file_patterns:
if fnmatch(filen, pattern):
break
else:
yield join(dirn, filen)
class BuildInterruptingException(Exception):
def __init__(self, message, instructions=None):
super(BuildInterruptingException, self).__init__(message, instructions)
self.message = message
self.instructions = instructions
def handle_build_exception(exception):
"""
Handles a raised BuildInterruptingException by printing its error
message and associated instructions, if any, then exiting.
"""
error('Build failed: {}'.format(exception.message))
if exception.instructions is not None:
info('Instructions: {}'.format(exception.instructions))
exit(1)