Skip to content

sdl2/bootstrap: add --add-jar and --intent-filters support #571

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

Merged
merged 1 commit into from
Jan 10, 2016
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
27 changes: 22 additions & 5 deletions pythonforandroid/bootstraps/sdl2/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,6 @@ def compile_dir(dfn):


def make_package(args):
url_scheme = 'kivy'

# Figure out versions of the private and public data.
private_version = str(time.time())

# # Update the project to a recent version.
# try:
# subprocess.call([ANDROID, 'update', 'project', '-p', '.', '-t',
Expand Down Expand Up @@ -253,6 +248,14 @@ def make_package(args):
shutil.copy(args.presplash or default_presplash,
'res/drawable/presplash.jpg')

# If extra Java jars were requested, copy them into the libs directory
if args.add_jar:
for jarname in args.add_jar:
if not os.path.exists(jarname):
print('Requested jar does not exist: {}'.format(jarname))
sys.exit(-1)
shutil.copy(jarname, 'libs')

versioned_name = (args.name.replace(' ', '').replace('\'', '') +
'-' + args.version)

Expand All @@ -263,6 +266,10 @@ def make_package(args):
version_code += int(i)
args.numeric_version = str(version_code)

if args.intent_filters:
with open(args.intent_filters) as fd:
args.intent_filters = fd.read()

render(
'AndroidManifest.tmpl.xml',
'AndroidManifest.xml',
Expand Down Expand Up @@ -345,6 +352,16 @@ def parse_args(args=None):
default=join(curdir, 'whitelist.txt'),
help=('Use a whitelist file to prevent blacklisting of '
'file in the final APK'))
ap.add_argument('--add-jar', dest='add_jar', action='append',
help=('Add a Java .jar to the libs, so you can access its '
'classes with pyjnius. You can specify this '
'argument more than once to include multiple jars'))
ap.add_argument('--intent-filters', dest='intent_filters',
help=('Add intent-filters xml rules to the '
'AndroidManifest.xml file. The argument is a '
'filename containing xml. The filename should be '
'located relative to the python-for-android '
'directory'))

if args is None:
args = sys.argv[1:]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
{%- if args.intent_filters -%}
{{- args.intent_filters -}}
{%- endif -%}
</activity>
</application>

</manifest>
</manifest>