Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for resource value files #19

Merged
merged 2 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions doc/source/buildoptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ options (this list may not be exhaustive):
- ``--enable-crashlytics-native-symbol-upload``: Enable processing and uploading
of native symbols to Firebase servers. This flag must be enabled to see
properly-symbolicated native stack traces in the Crashlytics dashboard.
- ``--res-values``: Resource value files to include in the app such as
``colors.xml`` and ``styles.xml``. This option can be specified multiple
times.


webview
Expand Down Expand Up @@ -190,6 +193,9 @@ ready.
- ``--enable-crashlytics-native-symbol-upload``: Enable processing and uploading
of native symbols to Firebase servers. This flag must be enabled to see
properly-symbolicated native stack traces in the Crashlytics dashboard.
- ``--res-values``: Resource value files to include in the app such as
``colors.xml`` and ``styles.xml``. This option can be specified multiple
times.


service_library
Expand Down Expand Up @@ -220,6 +226,9 @@ systems and frameworks.
project directory.
- ``--add-gradle-plugin``: Add a plugin for gradle. The format of the option
is ``<plugin-id>:<classpath>``. The option can be specified multiple times.
- ``--res-values``: Resource value files to include in the app such as
``colors.xml`` and ``styles.xml``. This option can be specified multiple
times.


Requirements blacklist (APK size optimization)
Expand Down
1 change: 0 additions & 1 deletion pythonforandroid/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class Bootstrap:
'''An Android project template, containing recipe stuff for
compilation and templated fields for APK info.
'''
name = ''
jni_subdir = '/jni'
ctx = None

Expand Down
9 changes: 9 additions & 0 deletions pythonforandroid/bootstraps/common/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,13 @@ def make_package(args):
xmlpath = join(args.private, xmlpath)
shutil.copy(xmlpath, res_xml_dir)

# Copy res_values files to src/main/res/values
res_values_dir = join(res_dir, 'values')
if args.res_values:
ensure_dir(res_values_dir)
for xmlpath in args.res_values:
shutil.copy(xmlpath, res_values_dir)

# Render out android manifest:
manifest_path = "src/main/AndroidManifest.xml"
render_args = {
Expand Down Expand Up @@ -832,6 +839,8 @@ def parse_args_and_make_package(args=None):
'directory'))
ap.add_argument('--res_xml', dest='res_xmls', action='append', default=[],
help='Add files to res/xml directory (for example device-filters)', nargs='+')
ap.add_argument('--res-values', dest='res_values', action='append', default=[],
help='Add files to res/values directory (for example styles.xml)')
ap.add_argument('--with-billing', dest='billing_pubkey',
help='If set, the billing service will be added (not implemented)')
ap.add_argument('--add-source', dest='extra_source_dirs', action='append',
Expand Down
9 changes: 4 additions & 5 deletions pythonforandroid/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ class Context:
# the Android project folder where everything ends up
dist_dir = None

# where Android libs are cached after build
# but before being placed in dists
libs_dir = None
aars_dir = None

# Whether setup.py or similar should be used if present:
use_setup_py = False

Expand Down Expand Up @@ -109,6 +104,10 @@ def templates_dir(self):

@property
def libs_dir(self):
"""
where Android libs are cached after build
but before being placed in dists
"""
# Was previously hardcoded as self.build_dir/libs
directory = join(self.build_dir, 'libs_collections',
self.bootstrap.distribution.name)
Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_dependency_tuple_list_for_recipe(recipe, blacklist=None):
"""
if blacklist is None:
blacklist = set()
assert type(blacklist) == set
assert type(blacklist) is set
if recipe.depends is None:
dependencies = []
else:
Expand Down Expand Up @@ -160,7 +160,7 @@ def obvious_conflict_checker(ctx, name_tuples, blacklist=None):
current_to_be_added = list(to_be_added)
to_be_added = []
for (added_tuple, adding_recipe) in current_to_be_added:
assert type(added_tuple) == tuple
assert type(added_tuple) is tuple
if len(added_tuple) > 1:
# No obvious commitment in what to add, don't check it itself
# but throw it into deps for later comparing against
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ def _fix_args(args):
fix_args = ('--dir', '--private', '--add-jar', '--add-source',
'--whitelist', '--blacklist', '--presplash', '--icon',
'--icon-bg', '--icon-fg', '--fileprovider-paths',
'--google-services-json')
'--google-services-json', '--res-values')
unknown_args = args.unknown_args

for asset in args.assets:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def test_strip_if_with_debug_symbols(self):
modules = ["mymodule"]
project_dir = None
with mock.patch('pythonforandroid.build.info'), \
mock.patch('sh.Command'),\
mock.patch('pythonforandroid.build.open'),\
mock.patch('pythonforandroid.build.shprint'),\
mock.patch('pythonforandroid.build.current_directory'),\
mock.patch('sh.Command'), \
mock.patch('pythonforandroid.build.open'), \
mock.patch('pythonforandroid.build.shprint'), \
mock.patch('pythonforandroid.build.current_directory'), \
mock.patch('pythonforandroid.build.CythonRecipe') as m_CythonRecipe, \
mock.patch('pythonforandroid.build.project_has_setup_py') as m_project_has_setup_py, \
mock.patch('pythonforandroid.build.run_setuppy_install'):
Expand Down