From 557088512229f7dede07b6bbb25729641f335224 Mon Sep 17 00:00:00 2001
From: Dexer <73297572+DexerBR@users.noreply.github.com>
Date: Sun, 17 Apr 2022 21:14:07 -0300
Subject: [PATCH 1/3] Adds an option to allow add extra resources
---
.../bootstraps/common/build/build.py | 31 ++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/pythonforandroid/bootstraps/common/build/build.py b/pythonforandroid/bootstraps/common/build/build.py
index dcb6d2ac3b..bb03f7fc39 100644
--- a/pythonforandroid/bootstraps/common/build/build.py
+++ b/pythonforandroid/bootstraps/common/build/build.py
@@ -4,7 +4,7 @@
import hashlib
import json
from os.path import (
- dirname, join, isfile, realpath,
+ dirname, join, isfile, isdir, realpath,
relpath, split, exists, basename
)
from os import environ, listdir, makedirs, remove
@@ -342,10 +342,37 @@ def make_package(args):
res_dir = "src/main/res"
default_icon = 'templates/kivy-icon.png'
default_presplash = 'templates/kivy-presplash.jpg'
+
+ if args.res:
+ target_res_dirs = [
+ filename for filename in listdir(res_dir)
+ if isdir(join(res_dir, filename))
+ ]
+ source_res_dirs = [
+ filename for filename in listdir(args.res)
+ if isdir(join(args.res, filename))
+ ]
+ for directory in source_res_dirs:
+ if directory not in target_res_dirs:
+ ensure_dir(join(res_dir, directory))
+ source_dir = join(args.res, directory)
+ target_dir = join(res_dir, directory)
+
+ source_dir_files = [
+ filename for filename in listdir(source_dir)
+ if isfile(join(source_dir, filename))
+ ]
+ for filename in source_dir_files:
+ shutil.copy(
+ join(source_dir, filename),
+ join(target_dir, filename)
+ )
+
shutil.copy(
args.icon or default_icon,
join(res_dir, 'mipmap/icon.png')
)
+
if args.icon_fg and args.icon_bg:
shutil.copy(args.icon_fg, join(res_dir, 'mipmap/icon_foreground.png'))
shutil.copy(args.icon_bg, join(res_dir, 'mipmap/icon_background.png'))
@@ -690,6 +717,8 @@ 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('--add-res', dest='res',
+ help=('Copy/overwrite directories and its files in the android res directory'))
ap.add_argument('--icon', dest='icon',
help=('A png file to use as the icon for '
'the application.'))
From e92fdf3d093fc8c95839189beb43f52daeca5f59 Mon Sep 17 00:00:00 2001
From: Dexer <73297572+DexerBR@users.noreply.github.com>
Date: Fri, 29 Jul 2022 22:50:52 -0300
Subject: [PATCH 2/3] Update templating process, Fix WSL related issue
---
.../bootstraps/common/build/build.py | 30 +++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/pythonforandroid/bootstraps/common/build/build.py b/pythonforandroid/bootstraps/common/build/build.py
index bb03f7fc39..156de5eae2 100644
--- a/pythonforandroid/bootstraps/common/build/build.py
+++ b/pythonforandroid/bootstraps/common/build/build.py
@@ -343,6 +343,30 @@ def make_package(args):
default_icon = 'templates/kivy-icon.png'
default_presplash = 'templates/kivy-presplash.jpg'
+ # Clean res directory
+ shutil.rmtree(res_dir)
+
+ # Create default p4a res dirs
+ default_res_dirs = [
+ "drawable", "drawable-mdpi", "drawable-hdpi", "drawable-xhdpi",
+ "drawable-xxhdpi", "layout", "mipmap", "mipmap-anydpi-v26", "values",
+ "xml"
+ ]
+ for dir in default_res_dirs:
+ ensure_dir(join(res_dir, dir))
+
+ # Copy default xml layout files
+ if get_bootstrap_name() == "sdl2":
+ default_layout_xmls = [
+ "chooser_item.xml", "main.xml", "project_chooser.xml",
+ "project_empty.xml"
+ ]
+ for xml in default_layout_xmls:
+ shutil.copy(
+ join("templates", xml),
+ join(res_dir, "layout", xml)
+ )
+
if args.res:
target_res_dirs = [
filename for filename in listdir(res_dir)
@@ -368,6 +392,12 @@ def make_package(args):
join(target_dir, filename)
)
+ # Removes :Zone.Identifier files, for WSL users.
+ # Issue: https://github.com/microsoft/WSL/issues/7456
+ for file in listdir(join(res_dir, directory)):
+ if file.endswith(':Zone.Identifier'):
+ remove(join(res_dir, directory, file))
+
shutil.copy(
args.icon or default_icon,
join(res_dir, 'mipmap/icon.png')
From 5a7002da1db5b433ac4dc3c1c116c7925f173539 Mon Sep 17 00:00:00 2001
From: Dexer <73297572+DexerBR@users.noreply.github.com>
Date: Fri, 29 Jul 2022 23:02:18 -0300
Subject: [PATCH 3/3] Add sdl2 layout xmls to templates dir
---
.../common/build/templates/chooser_item.xml | 39 +++++++++++++++++++
.../common/build/templates/main.xml | 13 +++++++
.../build/templates/project_chooser.xml | 22 +++++++++++
.../common/build/templates/project_empty.xml | 15 +++++++
4 files changed, 89 insertions(+)
create mode 100644 pythonforandroid/bootstraps/common/build/templates/chooser_item.xml
create mode 100644 pythonforandroid/bootstraps/common/build/templates/main.xml
create mode 100644 pythonforandroid/bootstraps/common/build/templates/project_chooser.xml
create mode 100644 pythonforandroid/bootstraps/common/build/templates/project_empty.xml
diff --git a/pythonforandroid/bootstraps/common/build/templates/chooser_item.xml b/pythonforandroid/bootstraps/common/build/templates/chooser_item.xml
new file mode 100644
index 0000000000..1823b13223
--- /dev/null
+++ b/pythonforandroid/bootstraps/common/build/templates/chooser_item.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pythonforandroid/bootstraps/common/build/templates/main.xml b/pythonforandroid/bootstraps/common/build/templates/main.xml
new file mode 100644
index 0000000000..123c4b6eac
--- /dev/null
+++ b/pythonforandroid/bootstraps/common/build/templates/main.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
diff --git a/pythonforandroid/bootstraps/common/build/templates/project_chooser.xml b/pythonforandroid/bootstraps/common/build/templates/project_chooser.xml
new file mode 100644
index 0000000000..23828e644b
--- /dev/null
+++ b/pythonforandroid/bootstraps/common/build/templates/project_chooser.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/pythonforandroid/bootstraps/common/build/templates/project_empty.xml b/pythonforandroid/bootstraps/common/build/templates/project_empty.xml
new file mode 100644
index 0000000000..ee5481421d
--- /dev/null
+++ b/pythonforandroid/bootstraps/common/build/templates/project_empty.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+