Skip to content

Commit

Permalink
Support for custom resources
Browse files Browse the repository at this point in the history
  • Loading branch information
lerela committed Aug 14, 2020
1 parent 524d621 commit bcce4ba
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pythonforandroid/bootstraps/common/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ def make_package(args):
sys.exit(1)

assets_dir = "src/main/assets"
res_dir = "src/main/res"

# Delete the old assets.
shutil.rmtree(assets_dir, ignore_errors=True)
Expand Down Expand Up @@ -307,6 +308,14 @@ def make_package(args):
else:
shutil.copytree(realpath(asset_src), join(assets_dir, asset_dest))

for res in args.resources:
res_src, res_dest = res.split(":")
if isfile(realpath(res_src)):
ensure_dir(dirname(join(res_dir, res_dest)))
shutil.copy(realpath(res_src), join(res_dir, res_dest))
else:
shutil.copytree(realpath(res_src), join(res_dir, res_dest))

if args.private or args.launcher:
make_tar(
join(assets_dir, 'private.mp3'), tar_dirs, args.ignore_path,
Expand All @@ -319,7 +328,6 @@ def make_package(args):
shutil.rmtree(env_vars_tarpath)

# Prepare some variables for templating process
res_dir = "src/main/res"
default_icon = 'templates/kivy-icon.png'
default_presplash = 'templates/kivy-presplash.jpg'
shutil.copy(
Expand Down Expand Up @@ -626,6 +634,10 @@ def parse_args_and_make_package(args=None):
help='Custom key=value to add in application metadata')
ap.add_argument('--uses-library', dest='android_used_libs', action='append', default=[],
help='Used shared libraries included using <uses-library> tag in AndroidManifest.xml')
ap.add_argument('--resource', dest='resources',
action="append", default=[],
metavar="/path/to/res/source:dest",
help='Put this in the resources folder at /dest')
ap.add_argument('--asset', dest='assets',
action="append", default=[],
metavar="/path/to/source:dest",
Expand Down

0 comments on commit bcce4ba

Please sign in to comment.