Skip to content
This repository has been archived by the owner on Oct 29, 2022. It is now read-only.

Commit

Permalink
improved build process; added iOS simulator compilation and launch
Browse files Browse the repository at this point in the history
  • Loading branch information
alebianco committed Aug 17, 2012
1 parent 2cdbc60 commit 55fa9cd
Show file tree
Hide file tree
Showing 2 changed files with 206 additions and 77 deletions.
256 changes: 186 additions & 70 deletions build/build.ant
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
<?xml version="1.0" ?>
<project name="Air Native Extension Build Scripts" default="all" basedir="../">

<project name="Air Native Extension Build Scripts" default="build" basedir="../">

<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="./build/ant/lib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>

<property file="build/build.properties" />

<target name="all" depends="init,and,ios,default,agnostic,package,clean,deploy" description="Full build of the extension"/>
<target name="build" depends="ext_init,ext_and,ext_ios-device,ext_ios-simulator,
ext_as3-default,ext_as3-android,ext_as3-iosdevice,ext_as3-iossimulator,
ext_package,ext_clean,ext_deploy"
description="Build the extension"/>

<target name="deploy">
<copy file="${BIN_DIR}/${LIB_NAME}.ane" todir="demo/ane/" overwrite="true"/>
</target>
<target name="init">
<target name="simulate" depends="demo_compile,demo_package,demo_uninstall,demo_install,demo_launch"
description="Run demo project on the iOS simulator"/>

<target name="ext_init">
<!-- create necessary folders to compile the extension -->
<mkdir dir="${BIN_DEF_DIR}"/>
<mkdir dir="${BIN_AND_DIR}"/>
<mkdir dir="${BIN_IOS_DIR}"/>
<mkdir dir="${BIN_IOS_DIR}"/>
<mkdir dir="${BIN_SIM_DIR}"/>
</target>

<target name="and" description="Build Android native library">

<target name="ext_and">
<!-- Build Android native library -->
<mkdir dir="${TMP_DIR}"/>
<ant antfile="build.xml" target="-compile" dir="${SRC_AND_DIR}" inheritall="false">
<property name="build.target" value="-compile"/>
Expand All @@ -37,68 +49,101 @@
<copy file="${TMP_DIR}/lib${LIB_NAME}.jar" todir="${BIN_AND_DIR}" overwrite="true"/>
<delete dir="${TMP_DIR}"/>
</target>

<target name="ios" description="Build iOS native library">

<target name="ext_ios-device">
<antcall target="ext_ios">
<param name="arch" value="armv7"/>
<param name="sdk" value="iphoneos"/>
<param name="dir" value="${BIN_IOS_DIR}"/>
</antcall>
</target>

<target name="ext_ios-simulator">
<antcall target="ext_ios">
<param name="arch" value="i386"/>
<param name="sdk" value="iphonesimulator"/>
<param name="dir" value="${BIN_SIM_DIR}"/>
</antcall>
</target>

<target name="ext_ios">
<!-- Build iOS native library -->
<mkdir dir="${TMP_DIR}"/>
<exec executable="xcodebuild" failonerror="true" dir="${SRC_IOS_DIR}">
<arg line="-project ${LIB_NAME}.xcodeproj"/>
<arg line="-target ${LIB_NAME}"/>
<arg line="-configuration Release"/>
<arg line="-configuration Release"/>
<arg line="-arch ${arch}"/>
<arg line="-sdk ${sdk}"/>
<arg line="SYMROOT=../../${TMP_DIR}"/>
</exec>
<copy file="${TMP_DIR}/Release-iphoneos/lib${LIB_NAME}.a" todir="${BIN_IOS_DIR}" overwrite="true"/>
<copy file="${TMP_DIR}/Release-${sdk}/lib${LIB_NAME}.a" todir="${dir}" overwrite="true"/>
<delete dir="${TMP_DIR}"/>
</target>

<target name="default" description="Build default extension implementation">
<mkdir dir="${TMP_DIR}"/>
<fileset dir="${SRC_DEF_DIR}/src" casesensitive="yes" id="default_files">
<include name="**/*.as"/>
</fileset>
<pathconvert property="default_classes" refid="default_files" pathsep=" " dirsep=".">
<regexpmapper from=".*src.(.*)\.as" to="\1"/>
</pathconvert>
<exec executable="${COMPC}" failonerror="true">
<arg line="-source-path ${SRC_DEF_DIR}/src"/>
<arg line="-output ${TMP_DIR}/default.swc"/>
<arg line="-swf-version=14"/>
<arg line="-external-library-path+='${FLEX_HOME}/frameworks/libs/air/airglobal.swc'"/>
<!--
<arg line="-library-path+='${SRC_DEF_DIR}/libs/'"/>
-->
<arg line="-include-classes ${default_classes}"/>
</exec>
<mkdir dir="${TMP_DIR}/content"/>
<copy file="${TMP_DIR}/default.swc" tofile="${BIN_DIR}/${LIB_NAME}.swc"/>
<unzip src="${TMP_DIR}/default.swc" dest="${TMP_DIR}/content" overwrite="true"/>
<copy file="${TMP_DIR}/content/library.swf" todir="${BIN_DEF_DIR}"/>
<delete dir="${TMP_DIR}"/>
</target>

<target name="agnostic" description="Build generic extension implementation for all platforms">
<mkdir dir="${TMP_DIR}"/>
<fileset dir="${SRC_AS3_DIR}/src" casesensitive="yes" id="agnostic_files">
<include name="**/*.as"/>
</fileset>
<pathconvert property="agnostic_classes" refid="agnostic_files" pathsep=" " dirsep=".">
<regexpmapper from=".*src.(.*)\.as" to="\1"/>
</pathconvert>
<exec executable="${COMPC}" failonerror="true">
<arg line="-source-path ${SRC_AS3_DIR}/src"/>
<arg line="-output ${TMP_DIR}/agnostic.swc"/>
<arg line="-swf-version=14"/>
<arg line="-external-library-path+='${FLEX_HOME}/frameworks/libs/air/airglobal.swc'"/>
<arg line="-library-path+='${SRC_AS3_DIR}/libs/'"/>
<arg line="-include-classes ${agnostic_classes}"/>
</exec>
<mkdir dir="${TMP_DIR}/content"/>
<unzip src="${TMP_DIR}/agnostic.swc" dest="${TMP_DIR}/content" overwrite="true"/>
<copy file="${TMP_DIR}/content/library.swf" todir="${BIN_AND_DIR}"/>
<copy file="${TMP_DIR}/content/library.swf" todir="${BIN_IOS_DIR}"/>
<delete dir="${TMP_DIR}"/>
</target>

<target name="package" description="Package the final extension">

<target name="ext_as3-default">
<antcall target="ext_as3">
<param name="source" value="${SRC_DEF_DIR}"/>
<param name="destination" value="${BIN_DEF_DIR}"/>
<param name="default" value="true"/>
</antcall>
</target>
<target name="ext_as3-android">
<antcall target="ext_as3">
<param name="source" value="${SRC_AS3_DIR}"/>
<param name="destination" value="${BIN_AND_DIR}"/>
</antcall>
</target>

<target name="ext_as3-iosdevice">
<antcall target="ext_as3">
<param name="source" value="${SRC_AS3_DIR}"/>
<param name="destination" value="${BIN_IOS_DIR}"/>
</antcall>
</target>

<target name="ext_as3-iossimulator">
<antcall target="ext_as3">
<param name="source" value="${SRC_AS3_DIR}"/>
<param name="destination" value="${BIN_SIM_DIR}"/>
</antcall>
</target>


<target name="ext_as3">
<!-- Build Actionscript extension bridge -->
<mkdir dir="${TMP_DIR}"/>
<fileset dir="${source}/src" casesensitive="yes" id="files">
<include name="**/*.as"/>
</fileset>
<pathconvert property="classes" refid="files" pathsep=" " dirsep=".">
<regexpmapper from=".*src.(.*)\.as" to="\1"/>
</pathconvert>
<exec executable="${COMPC}" failonerror="true">
<arg line="-source-path ${source}/src"/>
<arg line="-output ${TMP_DIR}/library.swc"/>
<arg line="-swf-version 14"/>
<arg line="-external-library-path+='${FLEX_HOME}/frameworks/libs/air/airglobal.swc'"/>
<arg line="-library-path+='${source}/libs/'"/>
<arg line="-include-classes ${classes}"/>
</exec>
<mkdir dir="${TMP_DIR}/content"/>
<if>
<and>
<isset property="default" />
<equals arg1="${default}" arg2="true"/>
</and>
<then>
<copy file="${TMP_DIR}/library.swc" tofile="${BIN_DIR}/${LIB_NAME}.swc"/>
</then>
</if>
<unzip src="${TMP_DIR}/library.swc" dest="${TMP_DIR}/content" overwrite="true"/>
<copy file="${TMP_DIR}/content/library.swf" todir="${destination}"/>
<delete dir="${TMP_DIR}"/>
</target>

<target name="ext_package">
<!-- Package the final extension -->
<java jar="${ADT}" fork="true" failonerror="true">
<arg line="-package"/>
<arg line="-storetype pkcs12"/>
Expand All @@ -108,18 +153,89 @@
<arg line="-target ane ${BIN_DIR}/${LIB_NAME}.ane ${ANE_DESCRIPTOR}"/>
<arg line="-swc bin/${LIB_NAME}.swc"/>
<arg line="-platform Android-ARM -C ${BIN_AND_DIR} ."/>
<arg line="-platform iPhone-ARM -platformoptions ${IOS_PLATFORM_OPTIONS} -C ${BIN_IOS_DIR} ."/>
<!--
<arg line="-platform QNX-x86 -C bin/native/qnx-x86 ."/>
<arg line="-platform QNX-ARM -C bin/native/qnx-arm ."/>
-->
<arg line="-platform iPhone-ARM -platformoptions ${IOS_PLATFORM_OPTIONS} -C ${BIN_IOS_DIR} ."/>
<arg line="-platform iPhone-x86 -C ${BIN_SIM_DIR} ."/>

<!--
<arg line="-platform QNX-x86 -C bin/native/qnx-x86 ."/>
<arg line="-platform QNX-ARM -C bin/native/qnx-arm ."/>
-->
<arg line="-platform default -C ${BIN_DEF_DIR} ."/>
</java>
</target>

<target name="clean">
<target name="ext_clean">
<!-- remove temporary folders needed to build the extension -->
<delete dir="${BIN_NATIVE}"/>
<delete dir="${TMP_DIR}"/>
</target>

<target name="ext_deploy">
<!-- deploys the compiled extension to the demo project -->
<copy file="${BIN_DIR}/${LIB_NAME}.ane" todir="${DEMO_DIR}/ane/" overwrite="true"/>
</target>

<target name="demo_compile">
<exec executable="${MXMLC}" failonerror="true">
<arg line="-swf-version=14"/>
<arg line="-debug=true"/>
<arg line="-source-path=${DEMO_DIR}/src"/>
<arg line="-library-path+=${DEMO_DIR}/libs"/>
<arg line="-external-library-path+='${FLEX_HOME}/frameworks/libs/air/airglobal.swc'"/>
<arg line="-external-library-path+=${DEMO_DIR}/ane/${LIB_NAME}.ane"/>
<arg line="-static-link-runtime-shared-libraries=true"/>
<arg line="-o=${BIN_DEMO_DIR}/${DEMO_SWF}"/>
<arg line="${DEMO_DIR}/src/Demo.as"/>
</exec>
</target>

<target name="demo_package">
<!-- compile the demo project to be run on the iOS simulator -->
<java jar="${ADT}" fork="true" failonerror="true">
<arg line="-package"/>
<arg line="-target ipa-debug-interpreter-simulator"/>
<arg line="-storetype pkcs12"/>
<arg line="-keystore ${KEYSTORE}"/>
<arg line="-storepass ${STOREPASS}"/>
<arg line="${DEMO_IPA} ${DEMO_DESCRIPTOR}"/>
<arg line="-extdir ${DEMO_DIR}/ane/"/>
<arg line="-platformsdk ${IOS_SIM_SDK}"/>
<arg line="-C ${BIN_DEMO_DIR} ${DEMO_SWF}"/>
<arg line="-C ${DEMO_EMBEDS_DIR} ."/>
</java>
</target>

<target name="demo_uninstall">
<!-- uninstall previous version of the demo from the simulator -->
<java jar="${ADT}" fork="true" failonerror="false">
<arg line="-uninstallApp"/>
<arg line="-platform ios"/>
<arg line="-platformsdk ${IOS_SIM_SDK}"/>
<arg line="-device ios-simulator"/>
<arg line="-appid ${DEMO_APP_ID}"/>
</java>
</target>

<target name="demo_install">
<!-- install current version of the demo in the simulator -->
<java jar="${ADT}" fork="true" failonerror="true">
<arg line="-installApp"/>
<arg line="-platform ios"/>
<arg line="-platformsdk ${IOS_SIM_SDK}"/>
<arg line="-device ios-simulator"/>
<arg line="-package ${DEMO_IPA}"/>
</java>
</target>

<target name="demo_launch">
<!-- launch demo on the iOS simulator -->
<java jar="${ADT}" fork="true" failonerror="true">
<arg line="-launchApp"/>
<arg line="-platform ios"/>
<arg line="-platformsdk ${IOS_SIM_SDK}"/>
<arg line="-device ios-simulator"/>
<arg line="-appid ${DEMO_APP_ID}"/>
</java>
</target>

</project>
27 changes: 20 additions & 7 deletions build/build.properties
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
<!-- SDKs properties -->
FLEX_HOME=/Applications/Adobe Flash Builder 4.6/sdks/latest
ANDROID_SDK=/Users/alessandro/android-sdks
# SDKs properties
FLEX_HOME = /Users/cyberpunk/SDKs/flex-sdk/4.6.0
ANDROID_SDK = /Users/cyberpunk/SDKs/android-sdks
IOS_SIM_SDK = /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk

<!-- Tools paths -->
# Tools paths
COMPC = ${FLEX_HOME}/bin/compc
MXMLC = ${FLEX_HOME}/bin/mxmlc
ADT = ${FLEX_HOME}/lib/adt.jar

<!-- Project properties -->
# Project properties
LIB_NAME = NativeGATracker
ANE_DESCRIPTOR = build/extension.xml
IOS_PLATFORM_OPTIONS = build/platform-iphone.xml

KEYSTORE = build/certificate.p12
STOREPASS = password

<!-- Folder paths -->
# Folder paths
TMP_DIR = bin-temp
BIN_DIR = bin
SRC_DIR = source
DEMO_DIR = demo

BIN_NATIVE = ${BIN_DIR}/native
BIN_DEF_DIR = ${BIN_NATIVE}/default
BIN_AND_DIR = ${BIN_NATIVE}/android
BIN_IOS_DIR = ${BIN_NATIVE}/ios
BIN_SIM_DIR = ${BIN_NATIVE}/sim

BIN_DEMO_DIR = ${DEMO_DIR}/bin-debug

SRC_DEF_DIR = ${SRC_DIR}/actionscript/default
SRC_AS3_DIR = ${SRC_DIR}/actionscript/agnostic
SRC_AND_DIR = ${SRC_DIR}/android
SRC_IOS_DIR = ${SRC_DIR}/ios
SRC_IOS_DIR = ${SRC_DIR}/ios

# Demo properties
DEMO_APP_ID = eu.alebianco.GATrackerDemo.debug
DEMO_DESCRIPTOR = build/Demo-app.xml
DEMO_EMBEDS_DIR = ${DEMO_DIR}/embeds
DEMO_IPA = ${BIN_DEMO_DIR}/Demo.ipa
DEMO_SWF = Demo.swf

0 comments on commit 55fa9cd

Please sign in to comment.