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