# Edge IDE platform configuration file
# ------------------------------------

# General options
defname           = "Android"
defshortname      = "android"
androidndkpath    = "c:\program files\android\android-ndk-r6"
androidsdkpath    = "c:\program files\android\android-sdk"
javapath          = "c:\Program Files\Java\jdk"
antpath           = "c:\Program Files\android\apache-ant-1.8.2"

# Helper variables
edgelibpath       = "%edgepath%\lib\android"
toolcreatecopy    = ""%edgeidepath%\bin\createcopy.exe""
androidbuildpath  = "%prjpath%\release\Android\project"

# NDK programs and locations
ndktoolpath       = "%androidndkpath%\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows"
ndkplatformpath   = "%androidndkpath%\platforms\android-4"
toolcompiler      = ""%ndktoolpath%\bin\arm-linux-androideabi-g++""
toollinker        = ""%ndktoolpath%\bin\arm-linux-androideabi-g++""
toolarchiver      = ""%ndktoolpath%\bin\arm-linux-androideabi-ar""
# Java programs and locations
tooljar           = ""%javapath%\bin\jar""
toolant           = ""%antpath%\bin\ant.bat""

# Compile resources
#none

# Compile source code files
cxxarchflags      = "-fpic -ffunction-sections -funwind-tables -fstack-protector -march=armv5te -msoft-float -fno-exceptions -fno-rtti -mthumb -finline-limit=64 -fno-strict-aliasing -Wa,--noexecstack"
cxxoptimiseflags  = "-mtune=xscale -Os -fomit-frame-pointer"
cxxwarnings       = "-Wall -Wextra -Wno-long-long -Wno-unused -Wno-psabi"
commandcompile    = "%comspec% echo %srcfile%"
commandcompile    = "%toolcompiler% %cxxarchflags% %cxxoptimiseflags% %cxxwarnings% %l_incpath_l% %l_macrodef_l% -c "%srcfile%" -o "%bldpath%\%objfile%""

# Link target
clsysroot         = "--sysroot="%ndkplatformpath%\arch-arm""
clsdkinput        = ""%ndkplatformpath%\arch-arm\usr\lib\libc.so" "%ndkplatformpath%\arch-arm\usr\lib\libstdc++.so" "%ndkplatformpath%\arch-arm\usr\lib\libm.so""
clflags           = "-shared -Wl,--no-undefined -Wl,-z,noexecstack -L"%ndkplatformpath%\arch-arm\usr\lib" -Wl,-rpath-link="%ndkplatformpath%\arch-arm\usr\lib" "
commandlink       = "%toollinker% %clsysroot% -Wl,-soname,lib%binfile%%binextension% %clsdkinput% %clflags% %l_objfile_l% %l_dynamiclib_l% %l_staticlib_l% %l_libpath_l% -o "%binfile%%binextension%""

# Create static library
commandlib        = "%toolarchiver% cr "%binfile%.a" %l_objfile_l%"

# Resources

# Setup - generate java code
commandinstall    = "%comspec% if not exist "%prjpath%\release\Android\%binname%.java" "%edgeidepath%\bin\genresource.exe" "%edgeidepath%\templates\androidmain.ini" "%prjpath%\release\Android\%binname%.java" $domain$=%domain% $caption$=%caption% $binname$=%binname%"
# setup - generate project paths
commandinstall    = "%comspec% if not exist "%androidbuildpath%\" mkdir "%androidbuildpath%""
commandinstall    = "%comspec% if not exist "%androidbuildpath%\bin\" mkdir "%androidbuildpath%\bin""
commandinstall    = "%comspec% if not exist "%androidbuildpath%\bin\classes\" mkdir "%androidbuildpath%\bin\classes""
commandinstall    = "%comspec% if not exist "%androidbuildpath%\libs\" mkdir "%androidbuildpath%\libs""
commandinstall    = "%comspec% if not exist "%androidbuildpath%\libs\armeabi" mkdir "%androidbuildpath%\libs\armeabi""
commandinstall    = "%comspec% if not exist "%androidbuildpath%\assets\" mkdir "%androidbuildpath%\assets""
commandinstall    = "%comspec% if exist "%androidbuildpath%\build.xml" del /S /Q "%androidbuildpath%\libs\*""
commandinstall    = ""%androidsdkpath%\tools\android.bat" create project -n "%binname%" -t android-3 -p "%androidbuildpath%" -a %binname% -k "%domain%""
# Setup - Inject files
commandinstall    = "%comspec% copy /Y "%prjpath%\release\Android\%binname%.java" "%androidbuildpath%\src\%domainpath%\%binname%.java""
commandinstall    = "%comspec% if exist "%prjpath%\release\Android\AndroidManifest.xml" copy /Y "%prjpath%\release\Android\AndroidManifest.xml" "%androidbuildpath%\AndroidManifest.xml""
commandinstall    = "%comspec% if exist "%prjpath%\release\Android\build.properties" copy /Y "%prjpath%\release\Android\build.properties" "%androidbuildpath%\build.properties""
commandinstall    = ""%edgeidepath%\bin\fixpath.bat" "%androidbuildpath%\bin\classes" %tooljar% xvf "%edgepath%\lib\android\edge.jar""
commandinstall    = "%comspec% copy "%binfile%%binextension%" "%androidbuildpath%\libs\armeabi\lib%binname%.so""
commandinstall    = "%comspec% echo Copying resources"
# commandinstall    = "%binfile%.2.bat"
# Setup - package
commandinstall    = ""%javapath%\bin\java.exe" -classpath "%antpath%\lib\ant-launcher.jar" org.apache.tools.ant.launch.Launcher -buildfile "%androidbuildpath%\build.xml" debug"
commandinstall    = ""%javapath%\bin\java.exe" -classpath "%antpath%\lib\ant-launcher.jar" org.apache.tools.ant.launch.Launcher -buildfile "%androidbuildpath%\build.xml" release"
commandinstall    = "%comspec% copy /Y "%androidbuildpath%\bin\*.apk" "%prjpath%\release\Android\""

#-Dant.home="%antpath%" -cp ".;%javapath%\lib\ext\QTJava.zip"   
#commandinstall    = "%toolant% -buildfile "%androidbuildpath%\build.xml" release"
#commandinstall     = "C:\android_sdk_windows_m3-rc20a\tools\adb push %binfile% /system/sbin/%binname%"
#commandinstall     = "C:\android_sdk_windows_m3-rc20a\tools\adb shell chmod 777 /system/sbin/%binname%"

# List settings
objfile_begin     = ""%objfile%""
objfile_next      = " "%objfile%""
iconfile_begin    = ""%iconfile%""
iconfile_next     = " "%iconfile%""
staticlib_begin   = ""%staticlib%""
staticlib_next    = " "%staticlib%""
dynamiclib_begin  = ""%dynamiclib%""
dynamiclib_next   = " "%dynamiclib%""
incpath_begin     = "-I "%incpath%""
incpath_next      = " -I "%incpath%""
libpath_begin     = "-L "%libpath%""
libpath_next      = " -L "%libpath%""
dsopath_begin     = "--libpath="%dsopath%""
dsopath_next      = ";"%dsopath%""
macrodef_begin    = "-D%macrodef%"
macrodef_next     = " -D%macrodef%"
installsrc_begin  = " && %toolcreatecopy% "%installsrc%" "%prjpath%\release\%platformname%\project\assets\%installdst%""
installsrc_next   = " && %toolcreatecopy% "%installsrc%" "%prjpath%\release\%platformname%\project\assets\%installdst%""

# Paths
incpath           = "%ndkplatformpath%\arch-arm\usr\include"
incpath           = "%androidndkpath%\sources\cxx-stl\system\include"
incpath           = "%edgepath%\include"
libpath           = "%edgepath%\lib\android"

# System libraries
staticlib         = "-lstdc++"
staticlib         = "-lsupc++"
staticlib         = "-ledge"
staticlib         = "-ledgerender"
staticlib         = "-lz"

# Macro list
macrodef          = "__ARM_ARCH_5__"
macrodef          = "__ARM_ARCH_5T__"
macrodef          = "__ARM_ARCH_5E__"
macrodef          = "__ARM_ARCH_5TE__"
macrodef          = "ANDROID"
macrodef          = "NDEBUG"
macrodef          = "APP_UID=0x%appuid%"

# Other settings
binextension      = ".so"

# Configuration notices, remove this section when done editing
notice           = "Android NDK path is set to default value: c:\program files\android\android-ndk-r6"
notice           = "Android SDK path is set to default value: c:\program files\android\android-sdk"
notice           = "JDK path is set to default value: c:\Program Files\Java\jdk"
notice           = "Ant path is set to default value: c:\Program Files\android\apache-ant-1.8.2"
notice           = "Change default values by editing android.ini"
notice           = "Remove this notice by removing the notice section at the bottom of android.ini"
