From 91a8dfd48e659da33e16ab9521d95a9f5219479e Mon Sep 17 00:00:00 2001 From: Ryan Pessa Date: Mon, 25 Jan 2016 13:01:35 -0600 Subject: [PATCH] implement --add-source argument --- .../bootstraps/sdl2/build/ant.properties | 1 + .../bootstraps/sdl2/build/build.py | 20 +++++++++++++++++++ .../build/templates/custom_rules.tmpl.xml | 14 +++++++++++++ pythonforandroid/toolchain.py | 10 ++++++++-- 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 pythonforandroid/bootstraps/sdl2/build/templates/custom_rules.tmpl.xml diff --git a/pythonforandroid/bootstraps/sdl2/build/ant.properties b/pythonforandroid/bootstraps/sdl2/build/ant.properties index b0971e891e..f74e644b8a 100644 --- a/pythonforandroid/bootstraps/sdl2/build/ant.properties +++ b/pythonforandroid/bootstraps/sdl2/build/ant.properties @@ -15,3 +15,4 @@ # 'key.alias' for the name of the key to use. # The password will be asked during the build when you use the 'release' target. +source.absolute.dir = tmp-src diff --git a/pythonforandroid/bootstraps/sdl2/build/build.py b/pythonforandroid/bootstraps/sdl2/build/build.py index 3a6ff45199..22ba94966a 100755 --- a/pythonforandroid/bootstraps/sdl2/build/build.py +++ b/pythonforandroid/bootstraps/sdl2/build/build.py @@ -286,6 +286,19 @@ def make_package(args): with open(args.intent_filters) as fd: args.intent_filters = fd.read() + if args.extra_source_dirs: + esd = [] + for spec in args.extra_source_dirs: + if ':' in spec: + specdir, specincludes = spec.split(':') + else: + specdir = spec + specincludes = '**' + esd.append((realpath(specdir), specincludes)) + args.extra_source_dirs = esd + else: + args.extra_source_dirs = [] + service = False service_main = join(realpath(args.private), 'service', 'main.py') if exists(service_main) or exists(service_main + 'o'): @@ -322,6 +335,11 @@ def make_package(args): 'res/values/strings.xml', args=args) + render( + 'custom_rules.tmpl.xml', + 'custom_rules.xml', + args=args) + with open(join(dirname(__file__), 'res', 'values', 'strings.xml')) as fileh: lines = fileh.read() @@ -410,6 +428,8 @@ def parse_args(args=None): help='If set, the billing service will be added (not implemented)') ap.add_argument('--service', dest='services', action='append', help='Declare a new service entrypoint: NAME:PATH_TO_PY') + ap.add_argument('--add-source', dest='extra_source_dirs', action='append', + help='Include additional source dirs in Java build') if args is None: args = sys.argv[1:] diff --git a/pythonforandroid/bootstraps/sdl2/build/templates/custom_rules.tmpl.xml b/pythonforandroid/bootstraps/sdl2/build/templates/custom_rules.tmpl.xml new file mode 100644 index 0000000000..8b2f60c7e1 --- /dev/null +++ b/pythonforandroid/bootstraps/sdl2/build/templates/custom_rules.tmpl.xml @@ -0,0 +1,14 @@ + + + + + + {% for dir, includes in args.extra_source_dirs %} + + {% endfor %} + + + + + + diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index da5ac2303d..adb6e3b9ff 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -539,9 +539,15 @@ def apk(self, args): # unsatisfactory and should probably be changed somehow, but # we can't leave it until later as the build.py scripts assume # they are in the current directory. + fix_args = ('--dir', '--private', '--add-jar', '--add-source') for i, arg in enumerate(args[:-1]): - if arg in ('--dir', '--private'): - args[i+1] = realpath(expanduser(args[i+1])) + argx = arg.split('=') + if argx[0] in fix_args: + if len(argx) > 1: + args[i] = '='.join((argx[0], + realpath(expanduser(argx[1])))) + else: + args[i+1] = realpath(expanduser(args[i+1])) build = imp.load_source('build', join(dist.dist_dir, 'build.py')) with current_directory(dist.dist_dir):