56
56
environment = jinja2 .Environment (loader = jinja2 .FileSystemLoader (
57
57
join (curdir , 'templates' )))
58
58
59
+
59
60
def render (template , dest , ** kwargs ):
60
61
'''
61
62
Using jinja2, render `template` to the filename `dest`, supplying the keyword
@@ -69,13 +70,15 @@ def render(template, dest, **kwargs):
69
70
f .write (text .encode ('utf-8' ))
70
71
f .close ()
71
72
73
+
72
74
def compile_dir (dfn ):
73
75
'''
74
76
Compile *.py in directory `dfn` to *.pyo
75
77
'''
76
78
77
79
# -OO = strip docstrings
78
- subprocess .call ([PYTHON ,'-OO' ,'-m' ,'compileall' ,'-f' , dfn ])
80
+ subprocess .call ([PYTHON , '-OO' , '-m' , 'compileall' , '-f' , dfn ])
81
+
79
82
80
83
def is_blacklist (name ):
81
84
for pattern in BLACKLIST_PATTERNS :
@@ -86,6 +89,7 @@ def is_blacklist(name):
86
89
if fnmatch (name , pattern ):
87
90
return True
88
91
92
+
89
93
def listfiles (d ):
90
94
basedir = d
91
95
subdirlist = []
@@ -99,6 +103,7 @@ def listfiles(d):
99
103
for fn in listfiles (subdir ):
100
104
yield fn
101
105
106
+
102
107
def make_pythonzip ():
103
108
'''
104
109
Search for all the python related files, and construct the pythonXX.zip
@@ -184,6 +189,7 @@ def select(fn):
184
189
tf .add (fn , afn )
185
190
tf .close ()
186
191
192
+
187
193
def make_package (args ):
188
194
version_code = 0
189
<
10000
td data-grid-cell-id="diff-85f8ee033777a43aa48570f2f1e5cc83e8face442217eaa14823059312dfe915-189-195-1" data-selected="false" role="gridcell" style="background-color:var(--bgColor-default);text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative diff-line-number-neutral left-side">195
manifest_extra = '<uses-feature android:glEsVersion="0x00020000" />'
@@ -218,27 +224,33 @@ def make_package(args):
218
224
else :
219
225
public_version = None
220
226
227
+ if args .intent_filters :
228
+ intent_filters = open (args .intent_filters ).read ()
229
+ else :
230
+ intent_filters = ''
231
+
221
232
# Render the various templates into control files.
222
233
render (
223
234
'AndroidManifest.tmpl.xml' ,
224
235
'AndroidManifest.xml' ,
225
- args = args ,
226
- url_scheme = url_scheme ,
227
- manifest_extra = manifest_extra ,
236
+ args = args ,
237
+ url_scheme = url_scheme ,
238
+ intent_filters = intent_filters ,
239
+ manifest_extra = manifest_extra ,
228
240
)
229
241
230
242
render (
231
243
build_tpl ,
232
244
'build.xml' ,
233
- args = args ,
234
- versioned_name = versioned_name )
245
+ args = args ,
246
+ versioned_name = versioned_name )
235
247
236
248
render (
237
249
'strings.xml' ,
238
250
'res/values/strings.xml' ,
239
- public_version = public_version ,
240
- private_version = private_version ,
241
- url_scheme = url_scheme ,
251
+ public_version = public_version ,
252
+ private_version = private_version ,
253
+ url_scheme = url_scheme ,
242
254
args = args )
243
255
244
256
# Update the project to a recent version.
@@ -263,12 +275,12 @@ def make_package(args):
263
275
264
276
# Package up the private and public data.
265
277
if args .private :
266
- make_tar ('assets/private.mp3' , [ 'private' , args .private ])
278
+ make_tar ('assets/private.mp3' , ['private' , args .private ])
267
279
else :
268
- make_tar ('assets/private.mp3' , [ 'private' ])
280
+ make_tar ('assets/private.mp3' , ['private' ])
269
281
270
282
if args .dir :
271
- make_tar ('assets/public.mp3' , [ args .dir ], args .ignore_path )
283
+ make_tar ('assets/public.mp3' , [args .dir ], args .ignore_path )
272
284
273
285
# Copy over the icon and presplash files.
274
286
shutil .copy (args .icon or default_icon , 'res/drawable/icon.png' )
@@ -308,6 +320,7 @@ def make_package(args):
308
320
ap .add_argument ('--presplash' , dest = 'presplash' , help = 'A jpeg file to use as a screen while the application is loading.' )
309
321
ap .add_argument ('--install-location' , dest = 'install_location' , default = 'auto' , help = 'The default install location. Should be "auto", "preferExternal" or "internalOnly".' )
310
322
ap .add_argument ('--compile-pyo' , dest = 'compile_pyo' , action = 'store_true' , help = 'Compile all .py files to .pyo, and only distribute the compiled bytecode.' )
323
+ ap .add_argument ('--intent_filters' , dest = 'intent_filters' , help = 'Add intent-filters xml rules to AndroidManifest.xml' )
311
324
ap .add_argument ('--blacklist' , dest = 'blacklist' ,
312
325
default = join (curdir , 'blacklist.txt' ),
313
326
help = 'Use a blacklist file to match unwanted file in the final APK' )
@@ -319,10 +332,10 @@ def make_package(args):
319
332
ap .error ('One of --dir, --private, or --launcher must be supplied.' )
320
333
321
334
if args .permissions is None :
322
- args .permissions = [ ]
335
+ args .permissions = []
323
336
324
337
if args .ignore_path is None :
325
- args .ignore_path = [ ]
338
+ args .ignore_path = []
326
339
327
340
if args .compile_pyo :
328
341
if PYTHON is None :
@@ -336,4 +349,3 @@ def make_package(args):
336
349
BLACKLIST_PATTERNS += patterns
337
350
338
351
make_package (args )
339
-
0 commit comments