Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pythonforandroid/bootstraps/common/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,15 @@ def make_package(args):

# Prepare some variables for templating process
res_dir = "src/main/res"
# Add user resouces
for resource in args.resources:
resource_src, resource_dest = resource.split(":")
if isfile(realpath(resource_src)):
ensure_dir(dirname(join(res_dir, resource_dest)))
shutil.copy(realpath(resource_src), join(res_dir, resource_dest))
else:
shutil.copytree(realpath(resource_src), join(res_dir, resource_dest))

default_icon = 'templates/kivy-icon.png'
default_presplash = 'templates/kivy-presplash.jpg'
shutil.copy(
Expand Down Expand Up @@ -698,6 +707,10 @@ def parse_args_and_make_package(args=None):
action="append", default=[],
metavar="/path/to/source:dest",
help='Put this in the assets folder at assets/dest')
ap.add_argument('--resource', dest='resources',
action="append", default=[],
metavar="/path/to/source:kind/asset",
help='Put this in the res folder at res/kind')
ap.add_argument('--icon', dest='icon',
help=('A png file to use as the icon for '
'the application.'))
Expand Down
11 changes: 11 additions & 0 deletions pythonforandroid/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,10 @@ def add_parser(subparsers, *args, **kwargs):
'--add-asset', dest='assets',
action="append", default=[],
help='Put this in the assets folder in the apk.')
parser_packaging.add_argument(
'--add-resource', dest='resources',
action="append", default=[],
help='Put this in the res folder in the apk.')
parser_packaging.add_argument(
'--private', dest='private',
help='the directory with the app source code files' +
Expand Down Expand Up @@ -1000,6 +1004,13 @@ def _fix_args(args):
asset_src = asset_dest = asset
# take abspath now, because build.py will be run in bootstrap dir
unknown_args += ["--asset", os.path.abspath(asset_src)+":"+asset_dest]
for resource in args.resources:
if ":" in resource:
resource_src, resource_dest = resource.split(":")
else:
resource_src = resource_dest = resource
# take abspath now, because build.py will be run in bootstrap dir
unknown_args += ["--resource", os.path.abspath(resource_src)+":"+resource_dest]
for i, arg in enumerate(unknown_args):
argx = arg.split('=')
if argx[0] in fix_args:
Expand Down