mparticle-roku-sdk 2.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/.github/workflows/build.yml +26 -0
  2. package/.gitmodules +3 -0
  3. package/LICENSE +191 -0
  4. package/README.md +24 -0
  5. package/example-legacy-sdk/images/MainMenu_Icon_Center_HD.png +0 -0
  6. package/example-legacy-sdk/images/MainMenu_Icon_Center_SD43.png +0 -0
  7. package/example-legacy-sdk/images/MainMenu_Icon_Side_HD.png +0 -0
  8. package/example-legacy-sdk/images/MainMenu_Icon_Side_SD43.png +0 -0
  9. package/example-legacy-sdk/images/splash_fhd.jpg +0 -0
  10. package/example-legacy-sdk/images/splash_hd.jpg +0 -0
  11. package/example-legacy-sdk/images/splash_sd.jpg +0 -0
  12. package/example-legacy-sdk/manifest +26 -0
  13. package/example-legacy-sdk/source/main.brs +45 -0
  14. package/example-scenegraph-sdk/LICENSE +1 -0
  15. package/example-scenegraph-sdk/README.md +2 -0
  16. package/example-scenegraph-sdk/source/Makefile +6 -0
  17. package/example-scenegraph-sdk/source/app.mk +675 -0
  18. package/example-scenegraph-sdk/source/components/helloworld.brs +300 -0
  19. package/example-scenegraph-sdk/source/components/helloworld.xml +66 -0
  20. package/example-scenegraph-sdk/source/images/channel-poster_fhd.png +0 -0
  21. package/example-scenegraph-sdk/source/images/channel-poster_hd.png +0 -0
  22. package/example-scenegraph-sdk/source/images/channel-poster_sd.png +0 -0
  23. package/example-scenegraph-sdk/source/images/splash-screen_fhd.jpg +0 -0
  24. package/example-scenegraph-sdk/source/images/splash-screen_hd.jpg +0 -0
  25. package/example-scenegraph-sdk/source/images/splash-screen_sd.jpg +0 -0
  26. package/example-scenegraph-sdk/source/manifest +12 -0
  27. package/example-scenegraph-sdk/source/source/Main.brs +46 -0
  28. package/example-scenegraph-sdk/source/testFramework/UnitTestFramework.brs +2867 -0
  29. package/example-scenegraph-sdk/source/tests/TestBasics.brs +266 -0
  30. package/mParticleBundle.crt +68 -0
  31. package/mParticleCore.brs +2301 -0
  32. package/mParticleTask.brs +78 -0
  33. package/mParticleTask.xml +12 -0
  34. package/package.json +5 -0
  35. package/testing/tests/Test__mParticle.brs +88 -0
@@ -0,0 +1,675 @@
1
+ #########################################################################
2
+ # common include file for application Makefiles
3
+ #
4
+ # Makefile common usage:
5
+ # > make
6
+ # > make run
7
+ # > make install
8
+ # > make remove
9
+ #
10
+ # Makefile less common usage:
11
+ # > make art-opt
12
+ # > make pkg
13
+ # > make install_native
14
+ # > make remove_native
15
+ # > make tr
16
+ #
17
+ # By default, ZIP_EXCLUDE will exclude -x \*.pkg -x storeassets\* -x keys\* -x .\*
18
+ # If you define ZIP_EXCLUDE in your Makefile, it will override the default setting.
19
+ #
20
+ # To exclude different files from being added to the zipfile during packaging
21
+ # include a line like this:ZIP_EXCLUDE= -x keys\*
22
+ # that will exclude any file who's name begins with 'keys'
23
+ # to exclude using more than one pattern use additional '-x <pattern>' arguments
24
+ # ZIP_EXCLUDE= -x \*.pkg -x storeassets\*
25
+ #
26
+ # If you want to add additional files to the default ZIP_EXCLUDE use
27
+ # ZIP_EXCLUDE_LOCAL
28
+ #
29
+ # Important Notes:
30
+ # To use the "run", "install" and "remove" targets to install your
31
+ # application directly from the shell, you must do the following:
32
+ #
33
+ # 1) Make sure that you have the curl command line executable in your path
34
+ # 2) Set the variable ROKU_DEV_TARGET in your environment to the IP
35
+ # address of your Roku box. (e.g. export ROKU_DEV_TARGET=192.168.1.1.
36
+ ##########################################################################
37
+
38
+ # improve performance and simplify Makefile debugging by omitting
39
+ # default language rules that don't apply to this environment.
40
+ MAKEFLAGS += --no-builtin-rules
41
+ .SUFFIXES:
42
+
43
+ HOST_OS := unknown
44
+ UNAME_S := $(shell uname -s)
45
+ ifeq ($(UNAME_S),Darwin)
46
+ HOST_OS := macos
47
+ else ifeq ($(UNAME_S),Linux)
48
+ HOST_OS := linux
49
+ else ifneq (,$(findstring CYGWIN,$(UNAME_S)))
50
+ HOST_OS := cygwin
51
+ endif
52
+
53
+ IS_TEAMCITY_BUILD ?=
54
+ ifneq ($(TEAMCITY_BUILDCONF_NAME),)
55
+ IS_TEAMCITY_BUILD := true
56
+ endif
57
+
58
+ # get the root directory in absolute form, so that current directory
59
+ # can be changed during the make if needed.
60
+ APPS_ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
61
+
62
+ # the current directory is the app root directory
63
+ SOURCEDIR := .
64
+
65
+ DISTREL := $(APPS_ROOT_DIR)/dist
66
+ COMMONREL := $(APPS_ROOT_DIR)/common
67
+
68
+ ZIPREL := $(DISTREL)/apps
69
+ PKGREL := $(DISTREL)/packages
70
+ CHECK_TMP_DIR := $(DISTREL)/tmp-check
71
+
72
+ DATE_TIME := $(shell date +%F-%T)
73
+
74
+ APP_ZIP_FILE := $(ZIPREL)/$(APPNAME).zip
75
+ APP_PKG_FILE := $(PKGREL)/$(APPNAME)_$(DATE_TIME).pkg
76
+
77
+ # these variables are only used for the .pkg file version tagging.
78
+ APP_NAME := $(APPNAME)
79
+ APP_VERSION := $(VERSION)
80
+ ifeq ($(IS_TEAMCITY_BUILD),true)
81
+ APP_NAME := $(subst /,-,$(TEAMCITY_BUILDCONF_NAME))
82
+ APP_VERSION := $(BUILD_NUMBER)
83
+ endif
84
+
85
+ APPSOURCEDIR := $(SOURCEDIR)/source
86
+ IMPORTFILES := $(foreach f,$(IMPORTS),$(COMMONREL)/$f.brs)
87
+ IMPORTCLEANUP := $(foreach f,$(IMPORTS),$(APPSOURCEDIR)/$f.brs)
88
+
89
+ # ROKU_NATIVE_DEV must be set in the calling environment to
90
+ # the firmware native-build src directory
91
+ NATIVE_DIST_DIR := $(ROKU_NATIVE_DEV)/dist
92
+ #
93
+ NATIVE_DEV_REL := $(NATIVE_DIST_DIR)/rootfs/Linux86_dev.OBJ/root/nvram/incoming
94
+ NATIVE_DEV_PKG := $(NATIVE_DEV_REL)/dev.zip
95
+ NATIVE_PLETHORA := $(NATIVE_DIST_DIR)/application/Linux86_dev.OBJ/root/bin/plethora
96
+ NATIVE_TICKLER := $(NATIVE_PLETHORA) tickle-plugin-installer
97
+
98
+ # only Linux host is supported for these tools currently
99
+ APPS_TOOLS_DIR := $(APPS_ROOT_DIR)/tools/$(HOST_OS)/bin
100
+
101
+ APP_PACKAGE_TOOL := $(APPS_TOOLS_DIR)/app-package
102
+ MAKE_TR_TOOL := $(APPS_TOOLS_DIR)/maketr
103
+ BRIGHTSCRIPT_TOOL := $(APPS_TOOLS_DIR)/brightscript
104
+
105
+ # if building from a firmware tree, use the BrightScript libraries from there
106
+ ifneq (,$(wildcard $(APPS_ROOT_DIR)/../3rdParty/brightscript/Scripts/LibCore/.))
107
+ BRIGHTSCRIPT_LIBS_DIR ?= $(APPS_ROOT_DIR)/../3rdParty/brightscript/Scripts/LibCore
108
+ endif
109
+ # else use the reference libraries from the tools directory.
110
+ BRIGHTSCRIPT_LIBS_DIR ?= $(APPS_ROOT_DIR)/tools/brightscript/Scripts/LibCore
111
+
112
+ APP_KEY_PASS_TMP := /tmp/app_key_pass
113
+ DEV_SERVER_TMP_FILE := /tmp/dev_server_out
114
+
115
+ # The developer password that was set on the player is required for
116
+ # plugin_install operations on modern versions of firmware.
117
+ # It may be pre-specified in the DEVPASSWORD environment variable on entry,
118
+ # otherwise the make will stop and prompt the user to enter it when needed.
119
+ ifdef DEVPASSWORD
120
+ USERPASS := rokudev:$(DEVPASSWORD)
121
+ else
122
+ USERPASS := rokudev
123
+ endif
124
+
125
+ ifeq ($(HOST_OS),macos)
126
+ # Mac doesn't support these args
127
+ CP_ARGS =
128
+ else
129
+ CP_ARGS = --preserve=ownership,timestamps --no-preserve=mode
130
+ endif
131
+
132
+ # For a quick ping, we want the command to return success as soon as possible,
133
+ # and a timeout failure in no more than a second or two.
134
+ ifeq ($(HOST_OS),cygwin)
135
+ # This assumes that the Windows ping command is used, not cygwin's.
136
+ QUICK_PING_ARGS = -n 1 -w 1000
137
+ else # Linux
138
+ QUICK_PING_ARGS = -c 1
139
+ endif
140
+
141
+ ifndef ZIP_EXCLUDE
142
+ ZIP_EXCLUDE= -x \*.pkg -x storeassets\* -x keys\* -x \*/.\* $(ZIP_EXCLUDE_LOCAL)
143
+ endif
144
+
145
+ # -------------------------------------------------------------------------
146
+ # $(APPNAME): the default target is to create the zip file for the app.
147
+ # This contains the set of files that are to be deployed on a Roku.
148
+ # -------------------------------------------------------------------------
149
+ .PHONY: $(APPNAME)
150
+ $(APPNAME): manifest
151
+ @echo "*** Creating $(APPNAME).zip ***"
152
+
153
+ @echo " >> removing old application zip $(APP_ZIP_FILE)"
154
+ @if [ -e "$(APP_ZIP_FILE)" ]; then \
155
+ rm -f $(APP_ZIP_FILE); \
156
+ fi
157
+
158
+ @echo " >> creating destination directory $(ZIPREL)"
159
+ @if [ ! -d $(ZIPREL) ]; then \
160
+ mkdir -p $(ZIPREL); \
161
+ fi
162
+
163
+ @echo " >> setting directory permissions for $(ZIPREL)"
164
+ @if [ ! -w $(ZIPREL) ]; then \
165
+ chmod 755 $(ZIPREL); \
166
+ fi
167
+
168
+ @echo " >> copying imports"
169
+ @if [ "$(IMPORTFILES)" ]; then \
170
+ mkdir $(APPSOURCEDIR)/common; \
171
+ cp -f $(CP_ARGS) -v $(IMPORTFILES) $(APPSOURCEDIR)/common/; \
172
+ fi \
173
+
174
+ # zip .png files without compression
175
+ # do not zip up Makefiles, or any files ending with '~'
176
+ @echo " >> creating application zip $(APP_ZIP_FILE)"
177
+ @if [ -d $(SOURCEDIR) ]; then \
178
+ (zip -0 -r "$(APP_ZIP_FILE)" . -i \*.png $(ZIP_EXCLUDE)); \
179
+ (zip -9 -r "$(APP_ZIP_FILE)" . -x \*~ -x \*.png -x Makefile $(ZIP_EXCLUDE)); \
180
+ else \
181
+ echo "Source for $(APPNAME) not found at $(SOURCEDIR)"; \
182
+ fi
183
+
184
+ @if [ "$(IMPORTCLEANUP)" ]; then \
185
+ echo " >> deleting imports";\
186
+ rm -r -f $(APPSOURCEDIR)/common; \
187
+ fi \
188
+
189
+ @echo "*** packaging $(APPNAME) complete ***"
190
+
191
+ # If DISTDIR is not empty then copy the zip package to the DISTDIR.
192
+ # Note that this is used by the firmware build, to build applications that are
193
+ # embedded in the firmware software image, such as the built-in screensaver.
194
+ # For those cases, the Netflix/Makefile calls this makefile for each app
195
+ # with DISTDIR and DISTZIP set to the target directory and base filename
196
+ # respectively.
197
+ @if [ $(DISTDIR) ]; then \
198
+ rm -f $(DISTDIR)/$(DISTZIP).zip; \
199
+ mkdir -p $(DISTDIR); \
200
+ cp -f --preserve=ownership,timestamps --no-preserve=mode \
201
+ $(APP_ZIP_FILE) $(DISTDIR)/$(DISTZIP).zip; \
202
+ fi
203
+
204
+ # -------------------------------------------------------------------------
205
+ # clean: remove any build output for the app.
206
+ # -------------------------------------------------------------------------
207
+ .PHONY: clean
208
+ clean:
209
+ rm -f $(APP_ZIP_FILE)
210
+ # FIXME: we should use a canonical output file name, rather than having
211
+ # the date-time stamp in the output file name.
212
+ # rm -f $(APP_PKG_FILE)
213
+ rm -f $(PKGREL)/$(APPNAME)_*.pkg
214
+
215
+ # -------------------------------------------------------------------------
216
+ # clobber: remove any build output for the app.
217
+ # -------------------------------------------------------------------------
218
+ .PHONY: clobber
219
+ clobber: clean
220
+
221
+ # -------------------------------------------------------------------------
222
+ # dist-clean: remove the dist directory for the sandbox.
223
+ # -------------------------------------------------------------------------
224
+ .PHONY: dist-clean
225
+ dist-clean:
226
+ rm -rf $(DISTREL)/*
227
+
228
+ # -------------------------------------------------------------------------
229
+ # CHECK_OPTIONS: this is used to specify configurable options, such
230
+ # as which version of the BrightScript library sources should be used
231
+ # to compile the app.
232
+ # -------------------------------------------------------------------------
233
+ CHECK_OPTIONS =
234
+ ifneq (,$(wildcard $(BRIGHTSCRIPT_LIBS_DIR)/.))
235
+ CHECK_OPTIONS += -lib $(BRIGHTSCRIPT_LIBS_DIR)
236
+ endif
237
+
238
+ # -------------------------------------------------------------------------
239
+ # check: run the desktop BrightScript compiler/check tool on the
240
+ # application.
241
+ # You can bypass checking on the application by setting
242
+ # APP_CHECK_DISABLED=true in the app's Makefile or in the environment.
243
+ # -------------------------------------------------------------------------
244
+ .PHONY: check
245
+ check: $(APPNAME)
246
+ ifeq ($(APP_CHECK_DISABLED),true)
247
+ ifeq ($(IS_TEAMCITY_BUILD),true)
248
+ @echo "*** Warning: application check skipped ***"
249
+ endif
250
+ else
251
+ ifeq ($(wildcard $(BRIGHTSCRIPT_TOOL)),)
252
+ @echo "*** Note: application check not available ***"
253
+ else
254
+ @echo "*** Checking application ***"
255
+ rm -rf $(CHECK_TMP_DIR)
256
+ mkdir -p $(CHECK_TMP_DIR)
257
+ unzip -q $(APP_ZIP_FILE) -d $(CHECK_TMP_DIR)
258
+ $(BRIGHTSCRIPT_TOOL) check \
259
+ $(CHECK_OPTIONS) \
260
+ $(CHECK_TMP_DIR)
261
+ rm -rf $(CHECK_TMP_DIR)
262
+ endif
263
+ endif
264
+
265
+ # -------------------------------------------------------------------------
266
+ # check-strict: run the desktop BrightScript compiler/check tool on the
267
+ # application using strict mode.
268
+ # -------------------------------------------------------------------------
269
+ .PHONY: check-strict
270
+ check-strict: $(APPNAME)
271
+ @echo "*** Checking application (strict) ***"
272
+ rm -rf $(CHECK_TMP_DIR)
273
+ mkdir -p $(CHECK_TMP_DIR)
274
+ unzip -q $(APP_ZIP_FILE) -d $(CHECK_TMP_DIR)
275
+ $(BRIGHTSCRIPT_TOOL) check -strict \
276
+ $(CHECK_OPTIONS) \
277
+ $(CHECK_TMP_DIR)
278
+ rm -rf $(CHECK_TMP_DIR)
279
+
280
+ # -------------------------------------------------------------------------
281
+ # GET_FRIENDLY_NAME_FROM_DD is used to extract the Roku device ID
282
+ # from the ECP device description XML response.
283
+ # -------------------------------------------------------------------------
284
+ define GET_FRIENDLY_NAME_FROM_DD
285
+ cat $(DEV_SERVER_TMP_FILE) | \
286
+ grep -o "<friendlyName>.*</friendlyName>" | \
287
+ sed "s|<friendlyName>||" | \
288
+ sed "s|</friendlyName>||"
289
+ endef
290
+
291
+ # -------------------------------------------------------------------------
292
+ # CHECK_ROKU_DEV_TARGET is used to check if ROKU_DEV_TARGET refers a
293
+ # Roku device on the network that has an enabled developer web server.
294
+ # If the target doesn't exist or doesn't have an enabled web server
295
+ # the connection should fail.
296
+ # -------------------------------------------------------------------------
297
+ define CHECK_ROKU_DEV_TARGET
298
+ if [ -z "$(ROKU_DEV_TARGET)" ]; then \
299
+ echo "ERROR: ROKU_DEV_TARGET is not set."; \
300
+ exit 1; \
301
+ fi
302
+ echo "Checking dev server at $(ROKU_DEV_TARGET)..."
303
+
304
+ # first check if the device is on the network via a quick ping
305
+ ping $(QUICK_PING_ARGS) $(ROKU_DEV_TARGET) &> $(DEV_SERVER_TMP_FILE) || \
306
+ ( \
307
+ echo "ERROR: Device is not responding to ping."; \
308
+ exit 1 \
309
+ )
310
+
311
+ # second check ECP, to verify we are talking to a Roku
312
+ rm -f $(DEV_SERVER_TMP_FILE)
313
+ curl --connect-timeout 2 --silent --output $(DEV_SERVER_TMP_FILE) \
314
+ http://$(ROKU_DEV_TARGET):8060 || \
315
+ ( \
316
+ echo "ERROR: Device is not responding to ECP...is it a Roku?"; \
317
+ exit 1 \
318
+ )
319
+
320
+ # echo the device friendly name to let us know what we are talking to
321
+ ROKU_DEV_NAME=`$(GET_FRIENDLY_NAME_FROM_DD)`; \
322
+ echo "Device reports as \"$$ROKU_DEV_NAME\"."
323
+
324
+ # third check dev web server.
325
+ # Note, it should return 401 Unauthorized since we aren't passing the password.
326
+ rm -f $(DEV_SERVER_TMP_FILE)
327
+ HTTP_STATUS=`curl --connect-timeout 2 --silent --output $(DEV_SERVER_TMP_FILE) \
328
+ http://$(ROKU_DEV_TARGET)` || \
329
+ ( \
330
+ echo "ERROR: Device server is not responding...is the developer installer enabled?"; \
331
+ exit 1 \
332
+ )
333
+
334
+ echo "Dev server is ready."
335
+ endef
336
+
337
+ # -------------------------------------------------------------------------
338
+ # CHECK_DEVICE_HTTP_STATUS is used to that the last curl command
339
+ # to the dev web server returned HTTP 200 OK.
340
+ # -------------------------------------------------------------------------
341
+ define CHECK_DEVICE_HTTP_STATUS
342
+ if [ "$$HTTP_STATUS" != "200" ]; then \
343
+ echo "ERROR: Device returned HTTP $$HTTP_STATUS"; \
344
+ exit 1; \
345
+ fi
346
+ endef
347
+
348
+ # -------------------------------------------------------------------------
349
+ # GET_PLUGIN_PAGE_RESULT_STATUS is used to extract the status message
350
+ # (e.g. Success/Failed) from the dev server plugin_* web page response.
351
+ # (Note that the plugin_install web page has two fields, whereas the
352
+ # plugin_package web page just has one).
353
+ # -------------------------------------------------------------------------
354
+ define GET_PLUGIN_PAGE_RESULT_STATUS
355
+ cat $(DEV_SERVER_TMP_FILE) | \
356
+ grep -o "<font color=\"red\">.*" | \
357
+ sed "s|<font color=\"red\">||" | \
358
+ sed "s|</font>||"
359
+ endef
360
+
361
+ # -------------------------------------------------------------------------
362
+ # GET_PLUGIN_PAGE_PACKAGE_LINK is used to extract the installed package
363
+ # URL from the dev server plugin_package web page response.
364
+ # -------------------------------------------------------------------------
365
+ define GET_PLUGIN_PAGE_PACKAGE_LINK =
366
+ cat $(DEV_SERVER_TMP_FILE) | \
367
+ grep -o "<a href=\"pkgs//[^\"]*\"" | \
368
+ sed "s|<a href=\"pkgs//||" | \
369
+ sed "s|\"||"
370
+ endef
371
+
372
+ # -------------------------------------------------------------------------
373
+ # install: install the app as the dev channel on the Roku target device.
374
+ # -------------------------------------------------------------------------
375
+ .PHONY: install
376
+ install: $(APPNAME) check
377
+ @$(CHECK_ROKU_DEV_TARGET)
378
+
379
+ @echo "Installing $(APPNAME)..."
380
+ @rm -f $(DEV_SERVER_TMP_FILE)
381
+ @HTTP_STATUS=`curl --user $(USERPASS) --digest --silent --show-error \
382
+ -F "mysubmit=Install" -F "archive=@$(APP_ZIP_FILE)" \
383
+ --output $(DEV_SERVER_TMP_FILE) \
384
+ --write-out "%{http_code}" \
385
+ http://$(ROKU_DEV_TARGET)/plugin_install`; \
386
+ $(CHECK_DEVICE_HTTP_STATUS)
387
+
388
+ @MSG=`$(GET_PLUGIN_PAGE_RESULT_STATUS)`; \
389
+ echo "Result: $$MSG"
390
+
391
+ # -------------------------------------------------------------------------
392
+ # remove: uninstall the dev channel from the Roku target device.
393
+ # -------------------------------------------------------------------------
394
+ .PHONY: remove
395
+ remove:
396
+ @$(CHECK_ROKU_DEV_TARGET)
397
+
398
+ @echo "Removing dev app..."
399
+ @rm -f $(DEV_SERVER_TMP_FILE)
400
+ @HTTP_STATUS=`curl --user $(USERPASS) --digest --silent --show-error \
401
+ -F "mysubmit=Delete" -F "archive=" \
402
+ --output $(DEV_SERVER_TMP_FILE) \
403
+ --write-out "%{http_code}" \
404
+ http://$(ROKU_DEV_TARGET)/plugin_install`; \
405
+ $(CHECK_DEVICE_HTTP_STATUS)
406
+
407
+ @MSG=`$(GET_PLUGIN_PAGE_RESULT_STATUS)`; \
408
+ echo "Result: $$MSG"
409
+
410
+ # -------------------------------------------------------------------------
411
+ # check-roku-dev-target: check the status of the Roku target device.
412
+ # -------------------------------------------------------------------------
413
+ .PHONY: check-roku-dev-target
414
+ check-roku-dev-target:
415
+ @$(CHECK_ROKU_DEV_TARGET)
416
+
417
+ # -------------------------------------------------------------------------
418
+ # run: the install target is 'smart' and doesn't do anything if the package
419
+ # didn't change.
420
+ # But usually I want to run it even if it didn't change, so force a fresh
421
+ # install by doing a remove first.
422
+ # Some day we should look at doing the force run via a plugin_install flag,
423
+ # but for now just brute force it.
424
+ # -------------------------------------------------------------------------
425
+ .PHONY: run
426
+ run: remove install
427
+
428
+ # -------------------------------------------------------------------------
429
+ # pkg: use to create a pkg file from the application sources.
430
+ #
431
+ # Usage:
432
+ # The application name should be specified via $APPNAME.
433
+ # The application version should be specified via $VERSION.
434
+ # The developer's signing password (from genkey) should be passed via
435
+ # $APP_KEY_PASS, or via stdin, otherwise the script will prompt for it.
436
+ # -------------------------------------------------------------------------
437
+ .PHONY: pkg
438
+ pkg: install
439
+ @echo "*** Creating Package ***"
440
+
441
+ @echo " >> creating destination directory $(PKGREL)"
442
+ @if [ ! -d $(PKGREL) ]; then \
443
+ mkdir -p $(PKGREL); \
444
+ fi
445
+
446
+ @echo " >> setting directory permissions for $(PKGREL)"
447
+ @if [ ! -w $(PKGREL) ]; then \
448
+ chmod 755 $(PKGREL); \
449
+ fi
450
+
451
+ @$(CHECK_ROKU_DEV_TARGET)
452
+
453
+ @echo "Packaging $(APP_NAME)/$(APP_VERSION) to $(APP_PKG_FILE)"
454
+
455
+ @if [ -z "$(APP_KEY_PASS)" ]; then \
456
+ read -r -p "Password: " REPLY; \
457
+ echo "$$REPLY" > $(APP_KEY_PASS_TMP); \
458
+ else \
459
+ echo "$(APP_KEY_PASS)" > $(APP_KEY_PASS_TMP); \
460
+ fi
461
+
462
+ @rm -f $(DEV_SERVER_TMP_FILE)
463
+ @PASSWD=`cat $(APP_KEY_PASS_TMP)`; \
464
+ PKG_TIME=`expr \`date +%s\` \* 1000`; \
465
+ HTTP_STATUS=`curl --user $(USERPASS) --digest --silent --show-error \
466
+ -F "mysubmit=Package" -F "app_name=$(APP_NAME)/$(APP_VERSION)" \
467
+ -F "passwd=$$PASSWD" -F "pkg_time=$$PKG_TIME" \
468
+ --output $(DEV_SERVER_TMP_FILE) \
469
+ --write-out "%{http_code}" \
470
+ http://$(ROKU_DEV_TARGET)/plugin_package`; \
471
+ $(CHECK_DEVICE_HTTP_STATUS)
472
+
473
+ @MSG=`$(GET_PLUGIN_PAGE_RESULT_STATUS)`; \
474
+ case "$$MSG" in \
475
+ *Success*) \
476
+ ;; \
477
+ *) echo "Result: $$MSG"; \
478
+ exit 1 \
479
+ ;; \
480
+ esac
481
+
482
+ @PKG_LINK=`$(GET_PLUGIN_PAGE_PACKAGE_LINK)`; \
483
+ HTTP_STATUS=`curl --user $(USERPASS) --digest --silent --show-error \
484
+ --output $(APP_PKG_FILE) \
485
+ --write-out "%{http_code}" \
486
+ http://$(ROKU_DEV_TARGET)/pkgs/$$PKG_LINK`; \
487
+ $(CHECK_DEVICE_HTTP_STATUS)
488
+
489
+ @echo "*** Package $(APPNAME) complete ***"
490
+
491
+ # -------------------------------------------------------------------------
492
+ # app-pkg: use to create a pkg file from the application sources.
493
+ # Similar to the pkg target, but does not require a player to do the signing.
494
+ # Instead it requires the developer key file and signing password to be
495
+ # specified, which are then passed to the app-package desktop tool to create
496
+ # the package file.
497
+ #
498
+ # Usage:
499
+ # The application name should be specified via $APPNAME.
500
+ # The application version should be specified via $VERSION.
501
+ # The developer's key file (.pkg file) should be specified via $APP_KEY_FILE.
502
+ # The developer's signing password (from genkey) should be passed via
503
+ # $APP_KEY_PASS, or via stdin, otherwise the script will prompt for it.
504
+ # -------------------------------------------------------------------------
505
+ .PHONY: app-pkg
506
+ app-pkg: $(APPNAME) check
507
+ @echo "*** Creating package ***"
508
+
509
+ @echo " >> creating destination directory $(PKGREL)"
510
+ @mkdir -p $(PKGREL) && chmod 755 $(PKGREL)
511
+
512
+ @if [ -z "$(APP_KEY_FILE)" ]; then \
513
+ echo "ERROR: APP_KEY_FILE not defined"; \
514
+ exit 1; \
515
+ fi
516
+ @if [ ! -f "$(APP_KEY_FILE)" ]; then \
517
+ echo "ERROR: key file not found: $(APP_KEY_FILE)"; \
518
+ exit 1; \
519
+ fi
520
+
521
+ @if [ -z "$(APP_KEY_PASS)" ]; then \
522
+ read -r -p "Password: " REPLY; \
523
+ echo "$$REPLY" > $(APP_KEY_PASS_TMP); \
524
+ else \
525
+ echo "$(APP_KEY_PASS)" > $(APP_KEY_PASS_TMP); \
526
+ fi
527
+
528
+ @echo "Packaging $(APP_NAME)/$(APP_VERSION) to $(APP_PKG_FILE)"
529
+
530
+ @if [ -z "$(APP_VERSION)" ]; then \
531
+ echo "WARNING: VERSION is not set."; \
532
+ fi
533
+
534
+ @PASSWD=`cat $(APP_KEY_PASS_TMP)`; \
535
+ $(APP_PACKAGE_TOOL) package $(APP_ZIP_FILE) \
536
+ -n $(APP_NAME)/$(APP_VERSION) \
537
+ -k $(APP_KEY_FILE) \
538
+ -p "$$PASSWD" \
539
+ -o $(APP_PKG_FILE)
540
+
541
+ @rm $(APP_KEY_PASS_TMP)
542
+
543
+ @echo "*** Package $(APPNAME) complete ***"
544
+
545
+ # -------------------------------------------------------------------------
546
+ # teamcity: used to build .zip and .pkg file on TeamCity.
547
+ # See app-pkg target for info on options for specifying the signing password.
548
+ # -------------------------------------------------------------------------
549
+ .PHONY: teamcity
550
+ teamcity: app-pkg
551
+ ifeq ($(IS_TEAMCITY_BUILD),true)
552
+ @echo "Adding TeamCity artifacts..."
553
+
554
+ sudo rm -f /tmp/artifacts
555
+ sudo mkdir -p /tmp/artifacts
556
+
557
+ cp $(APP_ZIP_FILE) /tmp/artifacts/$(APP_NAME)-$(APP_VERSION).zip
558
+ @echo "##teamcity[publishArtifacts '/tmp/artifacts/$(APP_NAME)-$(APP_VERSION).zip']"
559
+
560
+ cp $(APP_PKG_FILE) /tmp/artifacts/$(APP_NAME)-$(APP_VERSION).pkg
561
+ @echo "##teamcity[publishArtifacts '/tmp/artifacts/$(APP_NAME)-$(APP_VERSION).pkg']"
562
+
563
+ @echo "TeamCity artifacts complete."
564
+ else
565
+ @echo "Not running on TeamCity, skipping artifacts."
566
+ endif
567
+
568
+ ##########################################################################
569
+
570
+ # -------------------------------------------------------------------------
571
+ # CHECK_NATIVE_TARGET is used to check if the Roku simulator is
572
+ # configured.
573
+ # -------------------------------------------------------------------------
574
+ define CHECK_NATIVE_TARGET
575
+ if [ -z "$(ROKU_NATIVE_DEV)" ]; then \
576
+ echo "ERROR: ROKU_NATIVE_DEV not defined"; \
577
+ exit 1; \
578
+ i
579
+ if [ ! -d "$(ROKU_NATIVE_DEV)" ]; then \
580
+ echo "ERROR: native dev dir not found: $(ROKU_NATIVE_DEV)"; \
581
+ exit 1; \
582
+ fi
583
+ if [ ! -d "$(NATIVE_DIST_DIR)" ]; then \
584
+ echo "ERROR: native build dir not found: $(NATIVE_DIST_DIR)"; \
585
+ exit 1; \
586
+ fi
587
+ endef
588
+
589
+ # -------------------------------------------------------------------------
590
+ # install-native: install the app as the dev channel on the Roku simulator.
591
+ # -------------------------------------------------------------------------
592
+ .PHONY: install-native
593
+ install-native: $(APPNAME) check
594
+ @$(CHECK_NATIVE_TARGET)
595
+ @echo "Installing $(APPNAME) to native."
596
+ @if [ ! -d "$(NATIVE_DEV_REL)" ]; then \
597
+ mkdir "$(NATIVE_DEV_REL)"; \
598
+ fi
599
+ @echo "Source is $(APP_ZIP_FILE)"
600
+ @echo "Target is $(NATIVE_DEV_PKG)"
601
+ @cp $(APP_ZIP_FILE) $(NATIVE_DEV_PKG)
602
+ @$(NATIVE_TICKLER)
603
+
604
+ # -------------------------------------------------------------------------
605
+ # remove-native: uninstall the dev channel from the Roku simulator.
606
+ # -------------------------------------------------------------------------
607
+ .PHONY: remove-native
608
+ remove-native:
609
+ @$(CHECK_NATIVE_TARGET)
610
+ @echo "Removing $(APPNAME) from native."
611
+ @rm $(NATIVE_DEV_PKG)
612
+ @$(NATIVE_TICKLER)
613
+
614
+ ##########################################################################
615
+
616
+ # -------------------------------------------------------------------------
617
+ # art-jpg-opt: compress any jpg files in the source tree.
618
+ # Used by the art-opt target.
619
+ # -------------------------------------------------------------------------
620
+ APPS_JPG_ART=`\find . -name "*.jpg"`
621
+
622
+ .PHONY: art-jpg-opt
623
+ art-jpg-opt:
624
+ p4 edit $(APPS_JPG_ART)
625
+ for i in $(APPS_JPG_ART); \
626
+ do \
627
+ TMPJ=`mktemp` || return 1; \
628
+ echo "optimizing $$i"; \
629
+ (jpegtran -copy none -optimize -outfile $$TMPJ $$i && mv -f $$TMPJ $$i &); \
630
+ done
631
+ wait
632
+ p4 revert -a $(APPS_JPG_ART)
633
+
634
+ # -------------------------------------------------------------------------
635
+ # art-png-opt: compress any png files in the source tree.
636
+ # Used by the art-opt target.
637
+ # -------------------------------------------------------------------------
638
+ APPS_PNG_ART=`\find . -name "*.png"`
639
+
640
+ .PHONY: art-png-opt
641
+ art-png-opt:
642
+ p4 edit $(APPS_PNG_ART)
643
+ for i in $(APPS_PNG_ART); \
644
+ do \
645
+ (optipng -o7 $$i &); \
646
+ done
647
+ wait
648
+ p4 revert -a $(APPS_PNG_ART)
649
+
650
+ # -------------------------------------------------------------------------
651
+ # art-opt: compress any png and jpg files in the source tree using
652
+ # lossless compression options.
653
+ # This assumes a Perforce client/workspace is configured.
654
+ # Modified files are opened for edit in the default changelist.
655
+ # -------------------------------------------------------------------------
656
+ .PHONY: art-opt
657
+ art-opt: art-png-opt art-jpg-opt
658
+
659
+ ##########################################################################
660
+
661
+ # -------------------------------------------------------------------------
662
+ # tr: this target is used to update translation files for an application
663
+ # MAKE_TR_OPTIONS may be set to [-t] [-d] etc. in the external environment,
664
+ # if needed.
665
+ # -------------------------------------------------------------------------
666
+ .PHONY: tr
667
+ tr:
668
+ p4 opened -c default
669
+ p4 edit locale/.../translations.xml
670
+ $(MAKE_TR_TOOL) $(MAKE_TR_OPTIONS)
671
+ rm locale/en_US/translations.xml
672
+ p4 revert -a locale/.../translations.xml
673
+ p4 opened -c default
674
+
675
+ ##########################################################################