Skip to content

Instantly share code, notes, and snippets.

@ricardoalcocer
Created December 6, 2013 17:49
Show Gist options
  • Save ricardoalcocer/7829130 to your computer and use it in GitHub Desktop.
Save ricardoalcocer/7829130 to your computer and use it in GitHub Desktop.
Makefile to build and test native Android modules for Titanium
#
# make file for building, packaging and testing native android modules for titanium
# originally written by Tomas Hau (@mudderman) and modified by Ricardo Alcocer (@ricardoalcocer)
#
# 1. create a folder to hold your module and your test Ti app. this file lives here
# 2. create two sub-folders: 'mod' and 'testapp'
# 3. set the MODULE_NAME, MODULE_VERSION and APP_NAME variables to match your app ids
#
# to build simply run 'make full', 'make app' or 'make module'
#
GREEN = \033[32m
YELLOW = \033[38;5;226m
NOCOLOR = \033[39;0m
# env
TI_LIB_DIR := ~/Library/Application\ Support/Titanium/modules/android
BUILD_FILE := mod/build.xml
# app
MODULE_NAME := com.openwintent
MODULE_VERSION := 1.0
APP_NAME := com.openwintent.test
.PHONY: default
default: full
.PHONY: module
module:
@echo "$(YELLOW) Building module... $(NOCOLOR)"
@ant -f $(BUILD_FILE) clean dist #>/dev/null
@echo "$(YELLOW) Extracting files $(NOCOLOR)"
@unzip -o mod/dist/$(MODULE_NAME)-android-$(MODULE_VERSION).zip -d /tmp >/dev/null
@echo "$(YELLOW) Removing old module files $(NOCOLOR)"
@rm -rf $(TI_LIB_DIR)/$(MODULE_NAME) >/dev/null
@echo "$(YELLOW) Copying files $(NOCOLOR)"
@cp -R /tmp/modules/android/$(MODULE_NAME) $(TI_LIB_DIR)/
@echo "$(GREEN) Done building and installing module! $(NOCOLOR)"
.PHONY: app
app:
@titanium clean -q --project-dir testapp
@echo "$(YELLOW) Uninstalling application $(NOCOLOR)"
@adb uninstall $(APP_NAME) >/dev/null
@echo "$(YELLOW) Building application... $(NOCOLOR)"
@titanium build -q --platform android --android-sdk $(ANDROID_SDK) --target device --project-dir testapp #>/dev/null
@echo "$(GREEN) Done building and installing application! $(NOCOLOR)"
.PHONY: full
full: module app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment