8000 Merge pull request #18 from endlessm/more-manifest-gradle-templating · endlessm/python-for-android@304bf5c · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 304bf5c

Browse files
authored
Merge pull request #18 from endlessm/more-manifest-gradle-templating
More manifest and gradle templating
2 parents a4de463 + 1762981 commit 304bf5c

File tree

8 files changed

+68
-13
lines changed

8 files changed

+68
-13
lines changed

doc/source/buildoptions.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ options (this list may not be exhaustive):
9191
- ``--add-source``: Add a source directory to the app's Java code.
9292
- ``--no-compile-pyo``: Do not optimise .py files to .pyo.
9393
- ``--enable-androidx``: Enable AndroidX support library.
94+
- ``--extra-manifest-xml``: Extra xml to write directly inside the
95+
``<manifest>`` element of AndroidManifest.xml.
96+
- ``--extra-manifest-application-arguments``: Extra arguments to be
97+
added to the ``<manifest><application>`` tag of AndroidManifest.xml.
98+
- ``--manifest-placeholders``: Inject build variables into the manifest
99+
via the ``manifestPlaceholders`` property.
100+
- ``--debug-manifest-placeholders``: Inject build variables into the
101+
manifest via the manifestPlaceholders property in the debug buildType.
102+
- ``--release-manifest-placeholders``: Inject build variables into the
103+
manifest via the manifestPlaceholders property in the release
104+
buildType.
94105
- ``--enable-google-services``: Enable the Google Services Gradle plugin.
95106
This option requires a ``google-services.json`` file in root of the
96107
project directory.
@@ -160,6 +171,17 @@ ready.
160171
- ``add-source``: Add a source directory to the app's Java code.
161172
- ``--port``: The port on localhost that the WebView will
162173
access. Defaults to 5000.
174+
- ``--extra-manifest-xml``: Extra xml to write directly inside the
175+
``<manifest>`` element of AndroidManifest.xml.
176+
- ``--extra-manifest-application-arguments``: Extra arguments to be
177+
added to the ``<manifest><application>`` tag of AndroidManifest.xml.
178+
- ``--manifest-placeholders``: Inject build variables into the manifest
179+
via the ``manifestPlaceholders`` property.
180+
- ``--debug-manifest-placeholders``: Inject build variables into the
181+
manifest via the manifestPlaceholders property in the debug buildType.
182+
- ``--release-manifest-placeholders``: Inject build variables into the
183+
manifest via the manifestPlaceholders property in the release
184+
buildType.
163185
- ``--enable-google-services``: Enable the Google Services Gradle plugin.
164186
This option requires a ``google-services.json`` file in root of the
165187
project directory.

pythonforandroid/bootstraps/common/build/build.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,18 @@ def parse_args_and_make_package(args=None):
876876
ap.add_argument('--manifest-placeholders', dest='manifest_placeholders',
877877
default='[:]', help=('Inject build variables into the manifest '
878878
'via the manifestPlaceholders property'))
879+
ap.add_argument('--debug-manifest-placeholders',
880+
dest='debug_manifest_placeholders',
881+
default='[:]',
882+
help=('Inject build variables into the manifest '
883+
'via the manifestPlaceholders property '
884+
'in the debug buildType'))
885+
ap.add_argument('--release-manifest-placeholders',
886+
dest='release_manifest_placeholders',
887+
default='[:]',
888+
help=('Inject build variables into the manifest '
889+
'via the manifestPlaceholders property '
890+
8000 'in the release buildType'))
879891
ap.add_argument('--service-class-name', dest='service_class_name', default=DEFAULT_PYTHON_SERVICE_JAVA_CLASS,
880892
help='Use that parameter if you need to implement your own PythonServive Java class')
881893
ap.add_argument('--activity-class-name', dest='activity_class_name', default=DEFAULT_PYTHON_ACTIVITY_JAVA_CLASS,

pythonforandroid/bootstraps/common/build/templates/build.tmpl.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ android {
9494

9595
buildTypes {
9696
debug {
97+
manifestPlaceholders = {{ args.debug_manifest_placeholders }}
9798
{% if args.enable_crashlytics_native_symbol_upload -%}
9899
firebaseCrashlytics {
99100
nativeSymbolUploadEnabled true
@@ -105,6 +106,7 @@ android {
105106
{% if args.sign -%}
106107
signingConfig signingConfigs.release
107108
{%- endif %}
109+
manifestPlaceholders = {{ args.release_manifest_placeholders }}
108110
{% if args.enable_crashlytics_native_symbol_upload -%}
109111
firebaseCrashlytics {
110112
nativeSymbolUploadEnabled true

pythonforandroid/bootstraps/service_only/build/templates/AndroidManifest.tmpl.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
<uses-permission android:name="com.android.vending.BILLING" />
3636
{% endif %}
3737

38+
{{ args.extra_manifest_xml }}
39+
3840
<!-- Create a Java class extending SDLActivity and place it in a
3941
directory under src matching the package, e.g.
4042
src/com/gamemaker/game/MyGame.java
@@ -51,7 +53,9 @@
5153
{% if args.backup_rules %}android:fullBackupContent="@xml/{{ args.backup_rules }}"{% endif %}
5254
android:theme="{{args.android_apptheme}}{% if not args.window %}.Fullscreen{% endif %}"
5355
android:hardwareAccelerated="true"
54-
android:extractNativeLibs="true" >
56+
android:extractNativeLibs="true"
57+
{{ args.extra_manifest_application_arguments }}
58+
>
5559
{% for l in args.android_used_libs %}
5660
<uses-library android:name="{{ l }}" />
5761
{% endfor %}

pythonforandroid/bootstraps/webview/build/templates/AndroidManifest.tmpl.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
<uses-permission android:name="com.android.vending.BILLING" />
3737
{% endif %}
3838

39+
{{ args.extra_manifest_xml }}
40+
3941
<!-- Create a Java class extending SDLActivity and place it in a
4042
directory under src matching the package, e.g.
4143
src/com/gamemaker/game/MyGame.java
@@ -54,6 +56,7 @@
5456
android:usesCleartextTraffic="true"
5557
android:extractNativeLibs="true"
5658
{% if debug %}android:debuggable="true"{% endif %}
59+
{{ args.extra_manifest_application_arguments }}
5760
>
5861
{% for l in args.android_used_libs %}
5962
<uses-library android:name="{{ l F438 }}" />

pythonforandroid/recipe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ def install_libs(self, arch, *libs):
629629
shprint(sh.cp, *args)
630630

631631
def has_libs(self, arch, *libs):
632-
return all(map(lambda l: self.ctx.has_lib(arch.arch, l), libs))
632+
return all(map(lambda lib: self.ctx.has_lib(arch.arch, lib), libs))
633633

634634
def get_libraries(self, arch_name, in_context=False):
635635
"""Return the full path of the library depending on the architecture.

tests/test_pythonpackage_basic.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,15 @@ def test_systemwide_python(self):
269269
p2 = os.path.normpath(pybin)
270270
assert p1 == p2
271271
except RuntimeError as e:
272+
# (remember this is not in a virtualenv)
273+
# Some deps may not be installed, so we just avoid to raise
274+
# an exception here, as a missing dep should not make the test
275+
# fail.
272276
if "pep517" in str(e.args):
273277
# System python probably doesn't have pep517 available!
274-
# (remember this is not in a virtualenv)
275-
# Not much we can do in that case since pythonpackage needs it,
276-
# so we'll skip this particular check.
278+
pass
279+
elif "toml" in str(e.args):
280+
# System python probably doesn't have toml available!
277281
pass
278282
else:
279283
raise

tox.ini

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,19 @@ commands = flake8 pythonforandroid/ tests/ ci/ setup.py
2727

2828
[flake8]
2929
ignore =
30-
E123, # Closing bracket does not match indentation of opening bracket's line
31-
E124, # Closing bracket does not match visual indentation
32-
E126, # Continuation line over-indented for hanging indent
33-
E226, # Missing whitespace around arithmetic operator
34-
E402, # Module level import not at top of file
35-
E501, # Line too long (82 > 79 characters)
36-
W503, # Line break occurred before a binary operator
37-
W504 # Line break occurred after a binary operator
30+
# Closing bracket does not match indentation of opening bracket's line
31+
E123,
32+
# Closing bracket does not match visual indentation
33+
E124,
34+
# Continuation line over-indented for hanging indent
35+
E126,
36+
# Missing whitespace around arithmetic operator
37+
E226,
38+
# Module level import not at top of file
39+
E402,
40+
# Line too long (82 > 79 characters)
41+
E501,
42+
# Line break occurred before a binary operator
43+
W503,
44+
# Line break occurred after a binary operator
45+
W504

0 commit comments

Comments
 (0)
0