Skip to content

Commit 9af971f

Browse files
committed
Added Arch specification support (hackily)
1 parent 88bcb5f commit 9af971f

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

pythonforandroid/toolchain.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ def wrapper_func(self, args):
290290
user_ndk_dir=self.ndk_dir,
291291
user_android_api=self.android_api,
292292
user_ndk_ver=self.ndk_version)
293+
ctx.set_archs(self.archs)
293294
dist = self._dist
294295
if dist.needs_build:
295296
info_notify('No dist exists that meets your requirements, '
@@ -1087,9 +1088,11 @@ def __init__(self):
10871088
# root of the toolchain
10881089
self.setup_dirs()
10891090

1090-
# AND: Currently only the Android architecture is supported
1091+
# this list should contain all Archs, it is pruned later
10911092
self.archs = (
10921093
ArchARM(self),
1094+
ArchARMv7_a(self),
1095+
Archx86(self)
10931096
)
10941097

10951098
ensure_dir(join(self.build_dir, 'bootstrap_builds'))
@@ -1104,6 +1107,22 @@ def __init__(self):
11041107
# set the state
11051108
self.state = JsonStore(join(self.dist_dir, "state.db"))
11061109

1110+
def set_archs(self, arch_names):
1111+
all_archs = self.archs
1112+
new_archs = set()
1113+
for name in arch_names:
1114+
matching = [arch for arch in all_archs if arch.arch == name]
1115+
for match in matching:
1116+
new_archs.add(match)
1117+
self.archs = list(new_archs)
1118+
if not self.archs:
1119+
warning('Asked to compile for no Archs, so failing.')
1120+
exit(1)
1121+
info('Will compile for the following archs: {}'.format(
1122+
', '.join([arch.arch for arch in self.archs])))
1123+
exit(1)
1124+
1125+
11071126
def prepare_bootstrap(self, bs):
11081127
bs.ctx = self
11091128
self.bootstrap = bs
@@ -2771,6 +2790,14 @@ def __init__(self):
27712790
help=('The version of the Android NDK. This is optional, '
27722791
'we try to work it out automatically from the ndk_dir.'))
27732792

2793+
2794+
# AND: This option doesn't really fit in the other categories, the
2795+
# arg structure needs a rethink
2796+
parser.add_argument(
2797+
'--arch',
2798+
help='The archs to build for, separated by commas.',
2799+
default='armeabi')
2800+
27742801
# Options for specifying the Distribution
27752802
parser.add_argument(
27762803
'--dist_name',
@@ -2808,6 +2835,7 @@ def __init__(self):
28082835
description=('Whether the dist recipes must perfectly match '
28092836
'those requested'))
28102837

2838+
28112839
self._read_configuration()
28122840

28132841
args, unknown = parser.parse_known_args(sys.argv[1:])
@@ -2820,8 +2848,8 @@ def __init__(self):
28202848
self.android_api = args.android_api
28212849
self.ndk_version = args.ndk_version
28222850

2823-
# import ipdb
2824-
# ipdb.set_trace()
2851+
self.archs = split_argument_list(args.arch)
2852+
28252853
# AND: Fail nicely if the args aren't handled yet
28262854
if args.extra_dist_dirs:
28272855
warning('Received --extra_dist_dirs but this arg currently is not '

0 commit comments

Comments
 (0)