PROJECT=NLua.iOS.sln
MDTOOL=/Applications/MonoDevelop.app/Contents/MacOS/mdtool
MTOUCH=/Developer/MonoTouch/usr/bin/mtouch
TOUCH_SERVER=./Touch.Server/bin/Debug/Touch.Server.exe

all: build-simulator build-device

run run-test: run-device

touch-server:
	cd Touch.Server && xbuild

build-simulator:
	$(MDTOOL) -v build -t:Build "-c:Release|iPhoneSimulator" $(PROJECT)

run-simulator: build-simulator touch-server
	rm -f sim-results.log
	mono --debug $(TOUCH_SERVER) --launchsim ios/NLuaTestsiOS/bin/iPhoneSimulator/Release/NLuaTest.app -autoexit -logfile=sim-results.log
	cat sim-results.log

build-device:
	$(MDTOOL) -v build -t:Build "-c:Release|iPhone" $(PROJECT)

run-device: build-device touch-server
	$(MTOUCH) --installdev ios/NLuaTestsiOS/bin/iPhone/Release/NLuaTest.app
	# kill an existing instance (based on the bundle id)
	$(MTOUCH) --killdev org.nlua.nluatest
	rm -f dev-results.log
	mono --debug $(TOUCH_SERVER) --launchdev org.nlua.nluatest -autoexit -logfile=dev-results.log
	cat dev-results.log
