8000 implement --add-source argument · mixedCase/python-for-android@91a8dfd · GitHub
[go: up one dir, main page]

Skip to content

Commit 91a8dfd

Browse files
committed
implement --add-source argument
1 parent 1d030d4 commit 91a8dfd

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

pythonforandroid/bootstraps/sdl2/build/ant.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
# 'key.alias' for the name of the key to use.
1616
# The password will be asked during the build when you use the 'release' target.
1717

18+
source.absolute.dir = tmp-src

pythonforandroid/bootstraps/sdl2/build/build.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,19 @@ def make_package(args):
286286
with open(args.intent_filters) as fd:
287287
args.intent_filters = fd.read()
288288

289+
if args.extra_source_dirs:
290+
esd = []
291+
for spec in args.extra_source_dirs:
292+
if ':' in spec:
293+
specdir, specincludes = spec.split(':')
294+
else:
295+
specdir = spec
296+
specincludes = '**'
297+
esd.append((realpath(specdir), specincludes))
298+
args.extra_source_dirs = esd
299+
else:
300+
args.extra_source_dirs = []
301+
289302
service = False
290303
service_main = join(realpath(args.private), 'service', 'main.py')
291304
if exists(service_main) or exists(service_main + 'o'):
@@ -322,6 +335,11 @@ def make_package(args):
322335
'res/values/strings.xml',
323336
args=args)
324337

338+
render(
339+
'custom_rules.tmpl.xml',
340+
'custom_rules.xml',
341+
args=args)
342+
325343
with open(join(dirname(__file__), 'res',
326344
'values', 'strings.xml')) as fileh:
327345
lines = fileh.read()
@@ -410,6 +428,8 @@ def parse_args(args=None):
410428
help='If set, the billing service will be added (not implemented)')
411429
ap.add_argument('--service', dest='services', action='append',
412430
help='Declare a new service entrypoint: NAME:PATH_TO_PY')
431+
ap.add_argument('--add-source', dest='extra_source_dirs', action='append',
432+
help='Include additional source dirs in Java build')
413433

414434
if args is None:
415435
args = sys.argv[1:]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project name="CustomRules">
3+
<target name="-pre-build">
4+
<copy todir="tmp-src">
5+
<fileset dir="src" includes="**" />
6+
{% for dir, includes in args.extra_source_dirs %}
7+
<fileset dir="{{ dir }}" includes="{{ includes }}" />
8+
{% endfor %}
9+
</copy>
10+
</target>
11+
<target name="-post-build">
12+
<delete dir="tmp-src" />
13+
</target>
14+
</project>

pythonforandroid/toolchain.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,15 @@ def apk(self, args):
539539
# unsatisfactory and should probably be changed somehow, but
540540
# we can't leave it until later as the build.py scripts assume
541541
# they are in the current directory.
542+
fix_args = ('--dir', '--private', '--add-jar', '--add-source')
542543
for i, arg in enumerate(args[:-1]):
543-
if arg in ('--dir', '--private'):
544-
args[i+1] = realpath(expanduser(args[i+1]))
544+
argx = arg.split('=')
545+
if argx[0] in fix_args:
546+
if len(argx) > 1:
547+
args[i] = '='.join((argx[0],
548+
realpath(expanduser(argx[1]))))
549+
else:
550+
args[i+1] = realpath(expanduser(args[i+1]))
545551

546552
build = imp.load_source('build', join(dist.dist_dir, 'build.py'))
547553
with current_directory(dist.dist_dir):

0 commit comments

Comments
 (0)
0