Skip to content

Commit 715ee8a

Browse files
authored
Merge pull request #2330 from advian-oss/res_xml
Add option for adding files to res/xml without touching manifest
2 parents fd98534 + 214047f commit 715ee8a

File tree

1 file changed

+14
-1
lines changed
  • pythonforandroid/bootstraps/common/build

1 file changed

+14
-1
lines changed

pythonforandroid/bootstraps/common/build/build.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,12 +508,20 @@ def make_package(args):
508508
url_scheme = 'kivy'
509509

510510
# Copy backup rules file if specified and update the argument
511+
res_xml_dir = join(res_dir, 'xml')
511512
if args.backup_rules:
512-
res_xml_dir = join(res_dir, 'xml')
513513
ensure_dir(res_xml_dir)
514514
shutil.copy(join(args.private, args.backup_rules), res_xml_dir)
515515
args.backup_rules = split(args.backup_rules)[1][:-4]
516516

517+
# Copy res_xml files to src/main/res/xml
518+
if args.res_xmls:
519+
ensure_dir(res_xml_dir)
520+
for xmlpath in args.res_xmls:
521+
if not os.path.exists(xmlpath):
522+
xmlpath = join(args.private, xmlpath)
523+
shutil.copy(xmlpath, res_xml_dir)
524+
517525
# Render out android manifest:
518526
manifest_path = "src/main/AndroidManifest.xml"
519527
render_args = {
@@ -803,6 +811,8 @@ def parse_args_and_make_package(args=None):
803811
'filename containing xml. The filename should be '
804812
'located relative to the python-for-android '
805813
'directory'))
814+
ap.add_argument('--res_xml', dest='res_xmls', action='append', default=[],
815+
help='Add files to res/xml directory (for example device-filters)', nargs='+')
806816
ap.add_argument('--with-billing', dest='billing_pubkey',
807817
help='If set, the billing service will be added (not implemented)')
808818
ap.add_argument('--add-source', dest='extra_source_dirs', action='append',
@@ -901,6 +911,9 @@ def _read_configuration():
901911
if args.permissions and isinstance(args.permissions[0], list):
902912
args.permissions = [p for perm in args.permissions for p in perm]
903913

914+
if args.res_xmls and isinstance(args.res_xmls[0], list):
915+
args.res_xmls = [x for res in args.res_xmls for x in res]
916+
904917
if args.try_system_python_compile:
905918
# Hardcoding python2.7 is okay for now, as python3 skips the
906919
# compilation anyway

0 commit comments

Comments
 (0)