Skip to content

Instantly share code, notes, and snippets.

@pmuellr
Created October 5, 2012 01:15
Show Gist options
  • Save pmuellr/3837499 to your computer and use it in GitHub Desktop.
Save pmuellr/3837499 to your computer and use it in GitHub Desktop.
Makefile for Cordova devs for iOS
#-------------------------------------------------------------------------------
# Makefile for Cordova devs for iOS
#-------------------------------------------------------------------------------
# Use `make help` for more information.
#-------------------------------------------------------------------------------
# This Makefile assumes you have the following subdirectories in the same
# directory as this makefile, presumably git clones of the apache git repos:
# - incubator-cordova-ios
# - incubator-cordova-js
# - incubator-cordova-mobile-spec
#-------------------------------------------------------------------------------
CORDOVA_VERSION = $(shell cat incubator-cordova-js/VERSION)
PROJECT_SAMP = CordovaSamp
PROJECT_SPEC = MobileSpec
SOURCES = \
incubator-cordova-ios/bin \
incubator-cordova-ios/CordovaLib \
incubator-cordova-js/lib \
incubator-cordova-mobile-spec
#-------------------------------------------------------------------------------
all: help
#-------------------------------------------------------------------------------
clean:
rm -rf ~/tmp/$(PROJECT_SAMP)
rm -rf ~/tmp/$(PROJECT_SPEC)
#-------------------------------------------------------------------------------
samp-create: pre-reqs
./incubator-cordova-ios/bin/create ~/tmp/$(PROJECT_SAMP) org.example.$(PROJECT_SAMP) $(PROJECT_SAMP)
#-------------------------------------------------------------------------------
spec-create: pre-reqs
./incubator-cordova-ios/bin/create ~/tmp/$(PROJECT_SPEC) org.example.$(PROJECT_SPEC) $(PROJECT_SPEC)
cp -R incubator-cordova-mobile-spec/* ~/tmp/$(PROJECT_SPEC)/www
cp incubator-cordova-js/pkg/cordova.ios.js ~/tmp/$(PROJECT_SPEC)/www/cordova.js
#-------------------------------------------------------------------------------
samp-update: pre-reqs
cd incubator-cordova-js; jake
cp incubator-cordova-js/pkg/cordova.ios.js ~/tmp/$(PROJECT_SAMP)/www/cordova-$(CORDOVA_VERSION).js
cp -R incubator-cordova-ios/CordovaLib/* ~/tmp/$(PROJECT_SAMP)/CordovaLib
#-------------------------------------------------------------------------------
spec-update: pre-reqs
cd incubator-cordova-js; jake
cp -R incubator-cordova-mobile-spec/* ~/tmp/$(PROJECT_SPEC)/www
cp incubator-cordova-js/pkg/cordova.ios.js ~/tmp/$(PROJECT_SPEC)/www/cordova.js
cp -R incubator-cordova-ios/CordovaLib/* ~/tmp/$(PROJECT_SPEC)/CordovaLib
#-------------------------------------------------------------------------------
samp-open: pre-reqs
open ~/tmp/$(PROJECT_SAMP)/$(PROJECT_SAMP).xcodeproj
#-------------------------------------------------------------------------------
spec-open: pre-reqs
open ~/tmp/$(PROJECT_SPEC)/$(PROJECT_SPEC).xcodeproj
#-------------------------------------------------------------------------------
samp-watch:
wr "make samp-update" $(SOURCES)
#-------------------------------------------------------------------------------
spec-watch:
wr "make spec-update" $(SOURCES)
#-------------------------------------------------------------------------------
pre-reqs: existing-dirs mkdir-tmp
#-------------------------------------------------------------------------------
mkdir-tmp:
@mkdir -p ~/tmp
#-------------------------------------------------------------------------------
existing-dirs: incubator-cordova-js incubator-cordova-ios incubator-cordova-mobile-spec
incubator-cordova-js:
$(error Expecting directory incubator-cordova-js to exist)
incubator-cordova-ios:
$(error Expecting directory incubator-cordova-ios to exist)
incubator-cordova-mobile-spec:
$(error Expecting directory incubator-cordova-mobile-spec to exist)
#-------------------------------------------------------------------------------
help:
@echo "The following targets are available:"
@echo " samp-create - creates Xcode project ~/tmp/CordovaSamp"
@echo " samp-update - updates Xcode project ~/tmp/CordovaSamp"
@echo " samp-watch - watch for updates for CordovaSamp"
@echo " samp-open - open the CordovaSamp project in Xcode"
@echo
@echo " spec-create - creates Xcode project ~/tmp/MobileSpec"
@echo " spec-update - updates Xcode project ~/tmp/MobileSpec"
@echo " spec-watch - watch for updates for MobileSpec"
@echo " spec-open - open the MobileSpec project in Xcode"
@echo
@echo " clean - delete ~/tmp/MobileSpec and ~/tmp/CordovaSamp"
@echo " help - print this help"
@echo
@echo "CordovaSamp is the out-of-the-box default project created"
@echo "by Cordova's 'create' command."
@echo
@echo "MobileSpec is the mobile-spec tester"
@echo
@echo "samp-watch and spec-watch require that the npm package 'wr'"
@echo "is globally installed"
@echo
@echo "Typically, you will use XXX-create target to create a project,"
@echo "and then subsequently use the XXX-update target to update"
@echo "from your incubator-cordova-YYY working directories."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment