Skip to content

Commit 1106705

Browse files
Add --ouya-category argument which causes the appropriate OUYA-specific intent-filter to be added to AndroidManifest.xml
1 parent 92594e0 commit 1106705

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/build.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,13 @@ def make_package(args):
239239
if os.path.exists(service_main):
240240
service = True
241241

242+
# Check if OUYA support is enabled
243+
if args.ouya_category:
244+
args.ouya_category = args.ouya_category.upper()
245+
if args.ouya_category not in ('GAME', 'APP'):
246+
print 'Invalid --ouya-category argument. should be one of GAME or APP'
247+
sys.exit(-1)
248+
242249
# Render the various templates into control files.
243250
render(
244251
'AndroidManifest.tmpl.xml',
@@ -296,9 +303,12 @@ def make_package(args):
296303
# Copy over the icon and presplash files.
297304
shutil.copy(args.icon or default_icon, 'res/drawable/icon.png')
298305
shutil.copy(args.presplash or default_presplash, 'res/drawable/presplash.jpg')
299-
if not os.path.isdir('res/drawable-xhdpi'):
300-
os.mkdir('res/drawable-xhdpi')
301-
shutil.copy(args.ouya_icon or default_ouya_icon, 'res/drawable-xhdpi/ouya_icon.png')
306+
307+
# If OUYA support was requested, copy over the OUYA icon
308+
if args.ouya_category:
309+
if not os.path.isdir('res/drawable-xhdpi'):
310+
os.mkdir('res/drawable-xhdpi')
311+
shutil.copy(args.ouya_icon or default_ouya_icon, 'res/drawable-xhdpi/ouya_icon.png')
302312

303313
# Build.
304314
try:
@@ -333,6 +343,7 @@ def make_package(args):
333343
ap.add_argument('--ignore-path', dest='ignore_path', action='append', help='Ignore path when building the app')
334344
ap.add_argument('--icon', dest='icon', help='A png file to use as the icon for the application.')
335345
ap.add_argument('--presplash', dest='presplash', help='A jpeg file to use as a screen while the application is loading.')
346+
ap.add_argument('--ouya-category', dest='ouya_category', help='Valid values are GAME and APP. This must be specified to enable OUYA console support.')
336347
ap.add_argument('--ouya-icon', dest='ouya_icon', help='A png file to use as the icon for the application if it is installed on an OUYA console.')
337348
ap.add_argument('--install-location', dest='install_location', default='auto', help='The default install location. Should be "auto", "preferExternal" or "internalOnly".')
338349
ap.add_argument('--compile-pyo', dest='compile_pyo', action='store_true', help='Compile all .py files to .pyo, and only distribute the compiled bytecode.')

src/templates/AndroidManifest.tmpl.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@
3535
</intent-filter>
3636
{% endif %}
3737

38+
{%if args.ouya_category %}
39+
<intent-filter>
40+
<action android:name="android.intent.action.MAIN"/>
41+
<category android:name="android.intent.category.LAUNCHER"/>
42+
<category android:name="tv.ouya.intent.category.{{ args.ouya_category }}"/>
43+
</intent-filter>
44+
45+
{% endif %}
46+
3847
{%if args.intent_filters %}
3948
{{ intent_filters }}
4049
{% endif %}

0 commit comments

Comments
 (0)