@@ -147,324 +147,6 @@ def split_argument_list(l):
147147 return re .split (r'[ ,]+' , l )
148148
149149
150- # class NewToolchainCL(object):
151- # def __init__(self):
152- # parser = argparse.ArgumentParser(
153- # description=('A packaging tool for turning Python scripts and apps '
154- # 'into Android APKs'))
155-
156- # parser.add_argument(
157- # '--debug', dest='debug', action='store_true',
158- # help='Display debug output and all build info')
159- # parser.add_argument(
160- # '--color', dest='color', choices=['always', 'never', 'auto'],
161- # help='Enable or disable color output (default enabled on tty)')
162- # parser.add_argument(
163- # '--sdk-dir', '--sdk_dir', dest='sdk_dir', default='',
164- # help='The filepath where the Android SDK is installed')
165- # parser.add_argument(
166- # '--ndk-dir', '--ndk_dir', dest='ndk_dir', default='',
167- # help='The filepath where the Android NDK is installed')
168- # parser.add_argument(
169- # '--android-api', '--android_api', dest='android_api', default=0, type=int,
170- # help='The Android API level to build against.')
171- # parser.add_argument(
172- # '--ndk-version', '--ndk_version', dest='ndk_version', default='',
173- # help=('The version of the Android NDK. This is optional, '
174- # 'we try to work it out automatically from the ndk_dir.'))
175-
176- # default_storage_dir = user_data_dir('python-for-android')
177- # if ' ' in default_storage_dir:
178- # default_storage_dir = '~/.python-for-android'
179- # parser.add_argument(
180- # '--storage-dir', dest='storage_dir',
181- # default=default_storage_dir,
182- # help=('Primary storage directory for downloads and builds '
183- # '(default: {})'.format(default_storage_dir)))
184-
185- # # AND: This option doesn't really fit in the other categories, the
186- # # arg structure needs a rethink
187- # parser.add_argument(
188- # '--arch',
189- # help='The archs to build for, separated by commas.',
190- # default='armeabi')
191-
192- # # Options for specifying the Distribution
193- # parser.add_argument(
194- # '--dist-name', '--dist_name',
195- # help='The name of the distribution to use or create',
196- # default='')
197-
198- # parser.add_argument(
199- # '--requirements',
200- # help=('Dependencies of your app, should be recipe names or '
201- # 'Python modules'),
202- # default='')
203-
204- # parser.add_argument(
205- # '--bootstrap',
206- # help='The bootstrap to build with. Leave unset to choose automatically.',
207- # default=None)
208-
209- # add_boolean_option(
210- # parser, ["allow-download"],
211- # default=False,
212- # description='Whether to allow binary dist download:')
213-
214- # add_boolean_option(
215- # parser, ["allow-build"],
216- # default=True,
217- # description='Whether to allow compilation of a new distribution:')
218-
219- # add_boolean_option(
220- # parser, ["force-build"],
221- # default=False,
222- # description='Whether to force compilation of a new distribution:')
223-
224- # parser.add_argument(
225- # '--extra-dist-dirs', '--extra_dist_dirs',
226- # dest='extra_dist_dirs', default='',
227- # help='Directories in which to look for distributions')
228-
229- # add_boolean_option(
230- # parser, ["require-perfect-match"],
231- # default=False,
232- # description=('Whether the dist recipes must perfectly match '
233- # 'those requested'))
234-
235- # parser.add_argument(
236- # '--local-recipes', '--local_recipes',
237- # dest='local_recipes', default='./p4a-recipes',
238- # help='Directory to look for local recipes')
239-
240- # add_boolean_option(
241- # parser, ['copy-libs'],
242- # default=False,
243- # description='Copy libraries instead of using biglink (Android 4.3+)')
244-
245-
246- # subparsers = parser.add_subparsers(dest='subparser_name',
247- # help='The command to run')
248-
249- # parser_recipes = subparsers.add_parser(
250- # 'recipes', help='List the available recipes')
251- # parser_recipes.add_argument(
252- # "--compact", action="store_true", default=False,
253- # help="Produce a compact list suitable for scripting")
254-
255- # parser_bootstraps = subparsers.add_parser(
256- # 'bootstraps', help='List the available bootstraps')
257- # parser_clean_all = subparsers.add_parser(
258- # 'clean_all', aliases=['clean-all'],
259- # help='Delete all builds, dists and caches')
260- # parser_clean_dists = subparsers.add_parser(
261- # 'clean_dists', aliases=['clean-dists'],
262- # help='Delete all dists')
263- # parser_clean_bootstrap_builds = subparsers.add_parser(
264- # 'clean_bootstrap_builds', aliases=['clean-bootstrap-builds'],
265- # help='Delete all bootstrap builds')
266- # parser_clean_builds = subparsers.add_parser(
267- # 'clean_builds', aliases=['clean-builds'],
268- # help='Delete all builds')
269-
270- # parser_clean_recipe_build = subparsers.add_parser(
271- # 'clean_recipe_build', aliases=['clean-recipe-build'],
272- # help='Delete the build info for the given recipe')
273- # parser_clean_recipe_build.add_argument('recipe', help='The recipe name')
274-
275- # parser_clear_download_cache= subparsers.add_parser(
276- # 'clear_download_cache', aliases=['clear-download-cache'],
277- # help='Delete any cached recipe downloads')
278- # parser_export_dist = subparsers.add_parser(
279- # 'export_dist', aliases=['export-dist'],
280- # help='Copy the named dist to the given path')
281- # parser_symlink_dist = subparsers.add_parser(
282- # 'symlink_dist', aliases=['symlink-dist'],
283- # help='Symlink the named dist at the given path')
284- # # todo: make symlink an option of export
285- # parser_apk = subparsers.add_parser(
286- # 'apk', help='Build an APK')
287- # parser_create = subparsers.add_parser(
288- # 'create', help='Compile a set of requirements into a dist')
289- # parser_context_info = subparsers.add_parser(
290- # 'context_info', aliases=['context-info'],
291- # help='Print some debug information about the build context')
292- # parser_archs = subparsers.add_parser(
293- # 'archs', help='List the available target architectures')
294- # parser_distributions = subparsers.add_parser(
295- # 'distributions', aliases=['dists'],
296- # help='List the currently available (compiled) dists')
297- # parser_delete_dist = subparsers.add_parser(
298- # 'delete_dist', aliases=['delete-dist'], help='Delete a compiled dist')
299-
300- # parser_sdk_tools = subparsers.add_parser(
301- # 'sdk_tools', aliases=['sdk-tools'],
302- # help='Run the given binary from the SDK tools dis')
303- # parser_sdk_tools.add_argument('tool', help=('The tool binary name to run'))
304-
305- # parser_adb = subparsers.add_parser(
306- # 'adb', help='Run adb from the given SDK')
307- # parser_logcat = subparsers.add_parser(
308- # 'logcat', help='Run logcat from the given SDK')
309- # parser_build_status = subparsers.add_parser(
310- # 'build_status', aliases=['build-status'],
311- # help='Print some debug information about current built components')
312-
313- # parser_distributions.set_defaults(func=self.distributions)
314-
315- # print('ready to parse')
316- # args = parser.parse_args(sys.argv[1:])
317- # print('parsed')
318-
319- # setup_color(args.color)
320-
321- # # strip version from requirements, and put them in environ
322- # requirements = []
323- # for requirement in split_argument_list(args.requirements):
324- # if "==" in requirement:
325- # requirement, version = requirement.split(u"==", 1)
326- # os.environ["VERSION_{}".format(requirement)] = version
327- # info('Recipe {}: version "{}" requested'.format(
328- # requirement, version))
329- # requirements.append(requirement)
330- # args.requirements = u",".join(requirements)
331-
332- # self.ctx = Context()
333- # self.storage_dir = args.storage_dir
334- # self.ctx.setup_dirs(self.storage_dir)
335- # self.sdk_dir = args.sdk_dir
336- # self.ndk_dir = args.ndk_dir
337- # self.android_api = args.android_api
338- # self.ndk_version = args.ndk_version
339-
340- # self._archs = split_argument_list(args.arch)
341-
342- # # AND: Fail nicely if the args aren't handled yet
343- # if args.extra_dist_dirs:
344- # warning('Received --extra_dist_dirs but this arg currently is not '
345- # 'handled, exiting.')
346- # exit(1)
347-
348- # self.ctx.local_recipes = args.local_recipes
349- # self.ctx.copy_libs = args.copy_libs
350-
351- # # Each subparser corresponds to a method
352- # getattr(self, args.subparser_name.replace('-', '_'))(args)
353-
354- # def dists(self, args):
355- # print('args', args)
356- # self.distributions(args)
357-
358- # def distributions(self, args):
359- # '''Lists all distributions currently available (i.e. that have already
360- # been built).'''
361- # ctx = self.ctx
362- # dists = Distribution.get_distributions(ctx)
363-
364- # if dists:
365- # print('{Style.BRIGHT}Distributions currently installed are:'
366- # '{Style.RESET_ALL}'.format(Style=Out_Style, Fore=Out_Fore))
367- # pretty_log_dists(dists, print)
368- # else:
369- # print('{Style.BRIGHT}There are no dists currently built.'
370- # '{Style.RESET_ALL}'.format(Style=Out_Style))
371-
372- # def context_info(self, args):
373- # '''Prints some debug information about which system paths
374- # python-for-android will internally use for package building, along
375- # with information about where the Android SDK and NDK will be called
376- # from.'''
377- # ctx = self.ctx
378- # for attribute in ('root_dir', 'build_dir', 'dist_dir', 'libs_dir',
379- # 'eccache', 'cython', 'sdk_dir', 'ndk_dir',
380- # 'ndk_platform', 'ndk_ver', 'android_api'):
381- # print('{} is {}'.format(attribute, getattr(ctx, attribute)))
382-
383- # def archs(self, args):
384- # '''List the target architectures available to be built for.'''
385- # print('{Style.BRIGHT}Available target architectures are:'
386- # '{Style.RESET_ALL}'.format(Style=Out_Style))
387- # for arch in self.ctx.archs:
388- # print(' {}'.format(arch.arch))
389-
390- # def delete_dist(self, args):
391- # dist = self._dist
392- # if dist.needs_build:
393- # info('No dist exists that matches your specifications, '
394- # 'exiting without deleting.')
395- # shutil.rmtree(dist.dist_dir)
396-
397- # def sdk_tools(self, args):
398- # '''Runs the android binary from the detected SDK directory, passing
399- # all arguments straight to it. This binary is used to install
400- # e.g. platform-tools for different API level targets. This is
401- # intended as a convenience function if android is not in your
402- # $PATH.
403- # '''
404- # ctx = self.ctx
405- # ctx.prepare_build_environment(user_sdk_dir=self.sdk_dir,
406- # user_ndk_dir=self.ndk_dir,
407- # user_android_api=self.android_api,
408- # user_ndk_ver=self.ndk_version)
409- # android = sh.Command(join(ctx.sdk_dir, 'tools', args.tool))
410- # output = android(
411- # *unknown, _iter=True, _out_bufsize=1, _err_to_out=True)
412- # for line in output:
413- # sys.stdout.write(line)
414- # sys.stdout.flush()
415-
416- # def adb(self, args):
417- # '''Runs the adb binary from the detected SDK directory, passing all
418- # arguments straight to it. This is intended as a convenience
419- # function if adb is not in your $PATH.
420- # '''
421- # ctx = self.ctx
422- # ctx.prepare_build_environment(user_sdk_dir=self.sdk_dir,
423- # user_ndk_dir=self.ndk_dir,
424- # user_android_api=self.android_api,
425- # user_ndk_ver=self.ndk_version)
426- # if platform in ('win32', 'cygwin'):
427- # adb = sh.Command(join(ctx.sdk_dir, 'platform-tools', 'adb.exe'))
428- # else:
429- # adb = sh.Command(join(ctx.sdk_dir, 'platform-tools', 'adb'))
430- # info_notify('Starting adb...')
431- # output = adb(args, _iter=True, _out_bufsize=1, _err_to_out=True)
432- # for line in output:
433- # sys.stdout.write(line)
434- # sys.stdout.flush()
435-
436- # def logcat(self, args):
437- # '''Runs ``adb logcat`` using the adb binary from the detected SDK
438- # directory. All extra args are passed as arguments to logcat.'''
439- # self.adb(['logcat'] + args)
440-
441-
442- # def build_status(self, args):
443-
444- # print('{Style.BRIGHT}Bootstraps whose core components are probably '
445- # 'already built:{Style.RESET_ALL}'.format(Style=Out_Style))
446- # for filen in os.listdir(join(self.ctx.build_dir, 'bootstrap_builds')):
447- # print(' {Fore.GREEN}{Style.BRIGHT}{filen}{Style.RESET_ALL}'
448- # .format(filen=filen, Fore=Out_Fore, Style=Out_Style))
449-
450- # print('{Style.BRIGHT}Recipes that are probably already built:'
451- # '{Style.RESET_ALL}'.format(Style=Out_Style))
452- # if exists(join(self.ctx.build_dir, 'other_builds')):
453- # for filen in sorted(
454- # os.listdir(join(self.ctx.build_dir, 'other_builds'))):
455- # name = filen.split('-')[0]
456- # dependencies = filen.split('-')[1:]
457- # recipe_str = (' {Style.BRIGHT}{Fore.GREEN}{name}'
458- # '{Style.RESET_ALL}'.format(
459- # Style=Out_Style, name=name, Fore=Out_Fore))
460- # if dependencies:
461- # recipe_str += (
462- # ' ({Fore.BLUE}with ' + ', '.join(dependencies) +
463- # '{Fore.RESET})').format(Fore=Out_Fore)
464- # recipe_str += '{Style.RESET_ALL}'.format(Style=Out_Style)
465- # print(recipe_str)
466-
467-
468150class ToolchainCL (object ):
469151
470152 def __init__ (self ):
0 commit comments