############################################################################### # Global configurations. Protip: set your own overrides in a local.mk file. # # # # GAIA_DOMAIN : change that if you plan to use a different domain to update # # your applications or want to use a local domain # # # # HOMESCREEN : url of the homescreen to start on # # # # ADB : if you use a device and plan to send update it with your work # # you need to have adb in your path or you can edit this line to# # specify its location. # # # # DEBUG : debug mode enables mode output on the console and disable the # # the offline cache. This is mostly for desktop debugging. # # # # REPORTER : Mocha reporter to use for test output. # # # # GAIA_APP_SRCDIRS : list of directories to search for web apps # # # ############################################################################### -include local.mk # Headless bot does not need the full output of wget # and it can cause crashes in bot.io option is here so # -nv can be passed and turn off verbose output. WGET_OPTS?=-c GAIA_DOMAIN?=gaiamobile.org DEBUG?=0 PRODUCTION?=0 DOGFOOD?=0 LOCAL_DOMAINS?=1 ADB?=adb ifeq ($(DEBUG),1) SCHEME=http:// else SCHEME=app:// endif HOMESCREEN?=$(SCHEME)system.$(GAIA_DOMAIN) BUILD_APP_NAME?=* ifneq ($(APP),) BUILD_APP_NAME=$(APP) endif REPORTER?=Spec GAIA_APP_SRCDIRS?=apps GAIA_INSTALL_PARENT?=/data/local ADB_REMOUNT?=0 GAIA_ALL_APP_SRCDIRS=$(GAIA_APP_SRCDIRS) GAIA_LOCALES_PATH?=locales LOCALES_FILE?=shared/resources/languages.json GAIA_LOCALE_SRCDIRS=shared $(GAIA_APP_SRCDIRS) GAIA_DEFAULT_LOCALE?=en-US GAIA_INLINE_LOCALES?=1 ############################################################################### # The above rules generate the profile/ folder and all its content. # # The profile folder content depends on different rules: # # 1. webapp manifest # # A directory structure representing the applications installed using the # # Apps API. In Gaia all applications use this method. # # See https://developer.mozilla.org/en/Apps/Apps_JavaScript_API # # # # 2. offline # # An Application Cache database containing Gaia apps, so the phone can be # # used offline and application can be updated easily. For details about it# # see: https://developer.mozilla.org/en/Using_Application_Cache # # # # 3. preferences # # A preference file used by the platform to configure permissions # # # ############################################################################### # In debug mode the offline cache is not used (even if it is generated) and # Gaia is loaded by a built-in web server via port GAIA_PORT. # # XXX For now the name of the domain should be mapped to localhost manually # by editing /etc/hosts on linux/mac. This steps would not be required # anymore once https://bugzilla.mozilla.org/show_bug.cgi?id=722197 will land. ifeq ($(DEBUG),1) GAIA_PORT?=:8080 else GAIA_PORT?= endif # Force bash for all shell commands since we depend on bash-specific syntax SHELL := /bin/bash # what OS are we on? SYS=$(shell uname -s) ARCH?=$(shell uname -m) MSYS_FIX= ifeq (${SYS}/${ARCH},Darwin/i386) ARCH=x86_64 endif SEP=/ ifneq (,$(findstring MINGW32_,$(SYS))) CURDIR:=$(shell pwd -W | sed -e 's|/|\\\\|g') SEP=\\ # Mingw mangle path and append c:\mozilla-build\msys\data in front of paths MSYS_FIX=/ endif ifeq ($(SYS),Darwin) MD5SUM = md5 -r SED_INPLACE_NO_SUFFIX = /usr/bin/sed -i '' DOWNLOAD_CMD = /usr/bin/curl -O else MD5SUM = md5sum -b SED_INPLACE_NO_SUFFIX = sed -i DOWNLOAD_CMD = wget $(WGET_OPTS) endif # Test agent setup TEST_COMMON=test_apps/test-agent/common TEST_AGENT_DIR=tools/test-agent/ ifeq ($(strip $(NODEJS)),) NODEJS := `which node` endif ifeq ($(strip $(NPM)),) NPM := `which npm` endif TEST_AGENT_CONFIG="./test_apps/test-agent/config.json" #Marionette testing variables #make sure we're python 2.7.x ifeq ($(strip $(PYTHON_27)),) PYTHON_27 := `which python` endif PYTHON_FULL := $(wordlist 2,4,$(subst ., ,$(shell $(PYTHON_27) --version 2>&1))) PYTHON_MAJOR := $(word 1,$(PYTHON_FULL)) PYTHON_MINOR := $(word 2,$(PYTHON_FULL)) MARIONETTE_HOST ?= localhost MARIONETTE_PORT ?= 2828 TEST_DIRS ?= $(CURDIR)/tests # Generate profile/ profile: multilocale applications-data preferences app-makefiles offline extensions profile/settings.json @echo "Profile Ready: please run [b2g|firefox] -profile $(CURDIR)$(SEP)profile" LANG=POSIX # Avoiding sort order differences between OSes .PHONY: multilocale multilocale: ifneq ($(LOCALE_BASEDIR),) $(MAKE) multilocale-clean @echo "Enable locales specified in $(LOCALES_FILE)..." @targets=""; \ for appdir in $(GAIA_LOCALE_SRCDIRS); do \ targets="$$targets --target $$appdir"; \ done; \ python $(CURDIR)/build/multilocale.py \ --config $(LOCALES_FILE) \ --source $(LOCALE_BASEDIR) \ $$targets; @echo "Done" ifneq ($(LOCALES_FILE),shared/resources/languages.json) cp $(LOCALES_FILE) shared/resources/languages.json endif endif .PHONY: multilocale-clean multilocale-clean: @echo "Cleaning l10n bits..." ifeq ($(wildcard .hg),.hg) @hg update --clean @hg status -n $(GAIA_LOCALE_SRCDIRS) | grep '\.properties' | xargs rm -rf else @git ls-files --other --exclude-standard $(GAIA_LOCALE_SRCDIRS) | grep '\.properties' | xargs rm -f @git ls-files --modified $(GAIA_LOCALE_SRCDIRS) | grep '\.properties' | xargs git checkout -- ifneq ($(DEBUG),1) @# Leave these files modified in DEBUG profiles @git ls-files --modified $(GAIA_LOCALE_SRCDIRS) | grep 'manifest.webapp' | xargs git checkout -- @git ls-files --modified $(GAIA_LOCALE_SRCDIRS) | grep '\.ini' | xargs git checkout -- @git checkout -- shared/resources/languages.json @echo "Done" endif endif app-makefiles: @for d in ${GAIA_APP_SRCDIRS}; \ do \ for mfile in `find $$d -mindepth 2 -maxdepth 2 -name "Makefile"` ;\ do \ make -C `dirname $$mfile`; \ done; \ done; # Generate profile/webapps/ # We duplicate manifest.webapp to manifest.webapp and manifest.json # to accommodate Gecko builds without bug 757613. Should be removed someday. webapp-manifests: @mkdir -p profile/webapps @$(call run-js-command, webapp-manifests) @#cat profile/webapps/webapps.json # Generate profile/webapps/APP/application.zip webapp-zip: ifneq ($(DEBUG),1) @mkdir -p profile/webapps @$(call run-js-command, webapp-zip) endif # Web app optimization steps (like precompling l10n, concatenating js files, etc..). webapp-optimize: @$(call run-js-command, webapp-optimize) # Remove temporary l10n files optimize-clean: @$(call run-js-command, optimize-clean) # Populate appcache offline-cache: webapp-manifests @echo "Populate external apps appcache" @$(call run-js-command, offline-cache) @echo "Done" # Create webapps offline: webapp-manifests webapp-optimize webapp-zip optimize-clean define run-js-command echo "run-js-command $1"; \ JS_CONSTS=' \ const GAIA_DIR = "$(CURDIR)"; const PROFILE_DIR = "$(CURDIR)$(SEP)profile"; \ const GAIA_SCHEME = "$(SCHEME)"; const GAIA_DOMAIN = "$(GAIA_DOMAIN)"; \ const DEBUG = $(DEBUG); const LOCAL_DOMAINS = $(LOCAL_DOMAINS); \ const HOMESCREEN = "$(HOMESCREEN)"; const GAIA_PORT = "$(GAIA_PORT)"; \ const GAIA_APP_SRCDIRS = "$(GAIA_APP_SRCDIRS)"; \ const GAIA_LOCALES_PATH = "$(GAIA_LOCALES_PATH)"; \ const LOCALES_FILE = "$(LOCALES_FILE)"; \ const BUILD_APP_NAME = "$(BUILD_APP_NAME)"; \ const PRODUCTION = "$(PRODUCTION)"; \ const DOGFOOD = "$(DOGFOOD)"; \ const OFFICIAL = "$(MOZILLA_OFFICIAL)"; \ const GAIA_DEFAULT_LOCALE = "$(GAIA_DEFAULT_LOCALE)"; \ const GAIA_INLINE_LOCALES = "$(GAIA_INLINE_LOCALES)"; \ const GAIA_ENGINE = "xpcshell"; \ '; \ $(B2G_PATH)/run-mozilla.sh $(B2G_PATH)/xpcshell -e "$$JS_CONSTS" -f build/utils.js "build/$(strip $1).js" endef # Optional files that may be provided to extend the set of default # preferences installed for gaia. If the preferences in these files # conflict, the result is undefined. EXTENDED_PREF_FILES = \ custom-prefs.js \ payment-prefs.js \ ua-override-prefs.js \ # Generate profile/prefs.js preferences: @test -d profile || mkdir -p profile @$(call run-js-command, preferences) @$(foreach prefs_file,$(addprefix build/,$(EXTENDED_PREF_FILES)),\ if [ -f $(prefs_file) ]; then \ cat $(prefs_file) >> profile/user.js; \ fi; \ ) # Generate profile/ applications-data: test -d profile || mkdir -p profile @$(call run-js-command, applications-data) # Generate profile/extensions EXT_DIR=profile/extensions extensions: @mkdir -p profile @rm -rf $(EXT_DIR) ifeq ($(DEBUG),1) cp -r tools/extensions $(EXT_DIR) endif @echo "Finished: Generating extensions" ############################################################################### # Tests # ############################################################################### MOZ_TESTS = "$(MOZ_OBJDIR)/_tests/testing/mochitest" INJECTED_GAIA = "$(MOZ_TESTS)/browser/gaia" TEST_PATH=gaia/tests/${TEST_FILE} ifeq ($(TESTS),) ifneq ($(APP),) TESTS=$(shell find apps/$(APP)/test/integration/ -name "*_test.js" -type f ) else TESTS=$(shell find apps -name "*_test.js" -type f | grep integration) endif endif .PHONY: test-integration test-integration: @./tests/js/bin/runner $(TESTS) .PHONY: tests tests: webapp-manifests offline echo "Checking if the mozilla build has tests enabled..." test -d $(MOZ_TESTS) || (echo "Please ensure you don't have |ac_add_options --disable-tests| in your mozconfig." && exit 1) echo "Checking the injected Gaia..." test -L $(INJECTED_GAIA) || ln -s $(CURDIR) $(INJECTED_GAIA) TEST_PATH=$(TEST_PATH) make -C $(MOZ_OBJDIR) mochitest-browser-chrome EXTRA_TEST_ARGS="--browser-arg=\"\" --extra-profile-file=$(CURDIR)/profile/webapps --extra-profile-file=$(CURDIR)/profile/user.js" .PHONY: common-install common-install: @test -x $(NODEJS) || (echo "Please Install NodeJS -- (use aptitude on linux or homebrew on osx)" && exit 1 ) @test -x $(NPM) || (echo "Please install NPM (node package manager) -- http://npmjs.org/" && exit 1 ) cd $(TEST_AGENT_DIR) && npm install . ############################################################################### # Utils # ############################################################################### # Lint apps lint: @# ignore lint on: @# cubevid @# crystalskull @# towerjelly @gjslint --nojsdoc -r apps -e 'homescreen/everything.me,sms/js/ext,pdfjs/content,pdfjs/test,email/js/ext,music/js/ext,calendar/js/ext' @gjslint --nojsdoc -r shared/js # Erase all the indexedDB databases on the phone, so apps have to rebuild them. delete-databases: @echo 'Stopping b2g' $(ADB) shell stop b2g $(ADB) shell rm -r $(MSYS_FIX)/data/local/indexedDB/* @echo 'Starting b2g' $(ADB) shell start b2g # Take a screenshot of the device and put it in screenshot.png screenshot: mkdir -p screenshotdata $(ADB) pull $(MSYS_FIX)/dev/graphics/fb0 screenshotdata/fb0 dd bs=1920 count=800 if=screenshotdata/fb0 of=screenshotdata/fb0b ffmpeg -vframes 1 -vcodec rawvideo -f rawvideo -pix_fmt rgb32 -s 480x800 -i screenshotdata/fb0b -f image2 -vcodec png screenshot.png rm -rf screenshotdata # Forward port to use the RIL daemon from the device forward: $(ADB) shell touch $(MSYS_FIX)/data/local/rilproxyd $(ADB) shell killall rilproxy $(ADB) forward tcp:6200 localreserved:rilproxyd # update the manifest.appcache files to match what's actually there update-offline-manifests: for d in `find -L ${GAIA_APP_SRCDIRS} -mindepth 1 -maxdepth 1 -type d` ;\ do \ rm -rf $$d/manifest.appcache ;\ if [ -f $$d/manifest.webapp ] ;\ then \ echo \\t$$d ; \ ( cd $$d ; \ echo "CACHE MANIFEST" > manifest.appcache ;\ cat `find * -type f | sort -nfs` | $(MD5SUM) | cut -f 1 -d ' ' | sed 's/^/\#\ Version\ /' >> manifest.appcache ;\ find * -type f | grep -v tools | sort >> manifest.appcache ;\ $(SED_INPLACE_NO_SUFFIX) -e 's|manifest.appcache||g' manifest.appcache ;\ echo "http://$(GAIA_DOMAIN)$(GAIA_PORT)/webapi.js" >> manifest.appcache ;\ echo "NETWORK:" >> manifest.appcache ;\ echo "http://*" >> manifest.appcache ;\ echo "https://*" >> manifest.appcache ;\ ) ;\ fi \ done # If your gaia/ directory is a sub-directory of the B2G directory, then # you should use the install-gaia target of the B2G Makefile. But if you're # working on just gaia itself, and you already have B2G firmware on your # phone, and you have adb in your path, then you can use the install-gaia # target to update the gaia files and reboot b2g TARGET_FOLDER = webapps/$(BUILD_APP_NAME).$(GAIA_DOMAIN) APP_NAME = $(shell cat apps/${BUILD_APP_NAME}/manifest.webapp | grep name | head -1 | cut -d '"' -f 4) APP_PID = $(shell adb shell b2g-ps | grep '${APP_NAME}' | tr -s '${APP_NAME}' ' ' | tr -s ' ' ' ' | cut -f 3 -d' ') install-gaia: profile $(ADB) start-server @echo 'Stopping b2g' ifeq ($(BUILD_APP_NAME),*) $(ADB) shell stop b2g else ifeq ($(BUILD_APP_NAME), system) $(ADB) shell stop b2g else ifneq (${APP_PID},) $(ADB) shell kill ${APP_PID} endif $(ADB) shell rm -r $(MSYS_FIX)/cache/* ifeq ($(ADB_REMOUNT),1) $(ADB) remount endif ifeq ($(BUILD_APP_NAME),*) python build/install-gaia.py "$(ADB)" "$(MSYS_FIX)$(GAIA_INSTALL_PARENT)" else $(ADB) push profile/$(TARGET_FOLDER)/manifest.webapp $(MSYS_FIX)$(GAIA_INSTALL_PARENT)/$(TARGET_FOLDER)/manifest.webapp $(ADB) push profile/$(TARGET_FOLDER)/application.zip $(MSYS_FIX)$(GAIA_INSTALL_PARENT)/$(TARGET_FOLDER)/application.zip endif @echo "Installed gaia into profile/." @echo 'Starting b2g' $(ADB) shell start b2g # Copy demo media to the sdcard. # If we've got old style directories on the phone, rename them first. install-media-samples: $(ADB) shell 'if test -d /sdcard/Pictures; then mv /sdcard/Pictures /sdcard/DCIM; fi' $(ADB) shell 'if test -d /sdcard/music; then mv /sdcard/music /sdcard/music.temp; mv /sdcard/music.temp /sdcard/Music; fi' $(ADB) shell 'if test -d /sdcard/videos; then mv /sdcard/videos /sdcard/Movies; fi' $(ADB) push media-samples/DCIM $(MSYS_FIX)/sdcard/DCIM $(ADB) push media-samples/Movies $(MSYS_FIX)/sdcard/Movies $(ADB) push media-samples/Music $(MSYS_FIX)/sdcard/Music install-test-media: $(ADB) push test_media/DCIM $(MSYS_FIX)/sdcard/DCIM $(ADB) push test_media/Movies $(MSYS_FIX)/sdcard/Movies $(ADB) push test_media/Music $(MSYS_FIX)/sdcard/Music dialer-demo: @cp -R apps/contacts apps/dialer @rm apps/dialer/contacts/manifest* @mv apps/dialer/contacts/index.html apps/dialer/contacts/contacts.html @sed -i.bak 's/manifest.appcache/..\/manifest.appcache/g' apps/dialer/contacts/contacts.html @find apps/dialer/ -name '*.bak' -exec rm {} \; demo: install-media-samples install-gaia production: reset-gaia dogfood: reset-gaia # Remove everything and install a clean profile reset-gaia: purge install-gaia install-settings-defaults # remove the memories and apps on the phone purge: $(ADB) shell stop b2g @(for FILE in `$(ADB) shell ls $(MSYS_FIX)/data/local | tr -d '\r'`; \ do \ [ $$FILE != 'tmp' ] && $(ADB) shell rm -r $(MSYS_FIX)/data/local/$$FILE; \ done); $(ADB) shell rm -r $(MSYS_FIX)/cache/* $(ADB) shell rm -r $(MSYS_FIX)/data/b2g/* $(ADB) shell rm -r $(MSYS_FIX)$(GAIA_INSTALL_PARENT)/webapps # Build the settings.json file from settings.py ifeq ($(NOFTU), 1) SETTINGS_ARG=--noftu endif # We want the console to be disabled for device builds using the user variant. ifneq ($(TARGET_BUILD_VARIANT),user) SETTINGS_ARG += --console endif profile/settings.json: build/settings.py build/wallpaper.jpg python build/settings.py $(SETTINGS_ARG) --locale $(GAIA_DEFAULT_LOCALE) --homescreen $(SCHEME)homescreen.$(GAIA_DOMAIN)$(GAIA_PORT)/manifest.webapp --ftu $(SCHEME)communications.$(GAIA_DOMAIN)$(GAIA_PORT)/manifest.webapp --wallpaper build/wallpaper.jpg --override build/custom-settings.json --output $@ # push profile/settings.json to the phone install-settings-defaults: profile/settings.json $(ADB) shell stop b2g $(ADB) remount $(ADB) push profile/settings.json /system/b2g/defaults/settings.json $(ADB) shell start b2g # clean out build products clean: install: