Continuous Integration with Jenkins for React Native (iOS + Android) project - android

It is possible to implement Continuous Integration for a React Native app using Jenkins? I haven't found a guide to do this. If there are also other solution, what is the best one? Also, a Mac OS machine is mandatory for iOS project?

Yes, it is totally possible. You only have to execute all actions from the command line instead of XCode or the IDE of your choice. In the case of iOS, have a look at the react-native bundle command to create the JS bundle and xcodebuild and xcrun for compiling the native code. In Android it is a bit easier, since you have the gradle assembleRelease task. Before that you have to run npm install to get all your dependencies, but that should roughly be it.
As for iOS development, unfortunately there is no way around it, you do need an OS X machine.

The first thing is to get a command line build working for both Android and iOS. You can peak at the Xcode or Android Studio logs and copy some of the commands.
I put a build.sh script in the ios and android folders that I can call from a Jenkins job to build respective targets. You could have a build.sh in your project root that calls both.
Todo: I want to figure out how to run eslint airbnb in a Jenkins job and generate a report?
Here is my iOS build.sh script that works with Xcode 9:
#!/bin/sh
############################################
# File: build.sh
# -----------------------
# Author: edOfTheMountain#acme.com
#
# Command line build:
# 1) clean
# 2) build
# 3) archive
# 4) export IPA
#
# http://shashikantjagtap.net/xcodebuild-deploy-ios-app-command-line/
# https://help.apple.com/itc/apploader/e3#/apdATD1E53-D1E1A1303-D1E53A1126
#
isInPath=$(which xcodebuild)
if [ ! -x "${isInPath}" ] ; then
echo "*** Error xcodebuild not found in path"
exit 1
fi
isInPath=$(which xcrun)
if [ ! -x "${isInPath}" ] ; then
echo "*** Error xcrun not found in path"
exit 1
fi
echo "### Start: Cleaning ###############################################################"
rm -rf build
xcodebuild -project MyApp.xcodeproj -scheme MyApp -destination generic/platform=iOS clean
echo "### Done: Cleaning ###############################################################"
# Analyze
# xcodebuild -project MyApp.xcodeproj -scheme MyApp -sdk iphoneos clean analyze
echo "### Start: Building ###############################################################"
# xcodebuild -project MyApp.xcodeproj -target MyApp -showBuildSettings
# xcodebuild -project MyApp.xcodeproj -scheme MyApp -destination generic/platform=iOS build
# Run pod install once before building workspace
pod install
# Now using a Podfile so have to build workspace not build project
xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -destination generic/platform=iOS build
echo "### Done: Building ###############################################################"
CFBundleShortVersionString=`/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" ./MyApp/Info.plist`
CFBundleVersion=`/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" ./MyApp/Info.plist`
echo "CFBundleShortVersionString: ${CFBundleShortVersionString}"
echo "CFBundleVersion: ${CFBundleVersion}"
ipaFileName=MyApp.ipa
renameIpaFileName="field-scout-${CFBundleShortVersionString}.${CFBundleVersion}.ipa"
echo "### Start: Archiving ###############################################################"
# xcodebuild -project MyApp.xcodeproj -scheme MyApp -sdk iphoneos -configuration AppStoreDistribution archive -archivePath $PWD/build/MyApp.xcarchive
# Now using a Podfile so have to build workspace not build project
xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -sdk iphoneos -configuration AppStoreDistribution archive -archivePath $PWD/build/MyApp.xcarchive
echo "### Done: Archiving ###############################################################"
echo "### Start: Exporting ###############################################################"
xcodebuild -exportArchive -archivePath $PWD/build/MyApp.xcarchive -exportOptionsPlist MyApp/ExportOptions.plist -exportPath $PWD/build
ls -al build
echo "### Done: Exporting ###############################################################"
appArchiveFile=build/${ipaFileName}
if [ ! -f "${appArchiveFile}" ]; then
echo "*** Error file not found: ${appArchiveFile}"
exit 1
fi
# Extract and verify archive contents
echo "### Unzip: ${ipaFileName} ###############################################################"
( cd build; unzip -q ${ipaFileName} )
( cd build/Payload; xcrun codesign -dv MyApp.app/ )
outputFile=build/Payload/MyApp.app
if [ ! -d "${outputFile}" ]; then
echo "*** Error file not found: ${outputFile}"
exit 1
fi
rm -rf ./build/Payload
rm -rf ./build/Symbols
# altool is used to verify iOS IPA files
altool_path=/Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/Current/Support
isInPath=$(which altool)
if [ ! -x "${isInPath}" ] ; then
echo "*** Error altool not found in path"
echo "Expected altool path:\n ${altool_path}"
exit 1
fi
# altool validate will trigger a user dialog first time it is run.
# On a jenkins slave you will need to execute manually in a console once, to allow keychain access.
# $ altool --validate-app -f file -u username [-p password] [--output-format xml]
# $ altool --upload-app -f file -u username [-p password] [--output-format xml]
altool --validate-app -f build/${ipaFileName} -u edOfTheMountain#acme.com -p #keychain:"Application Loader: edOfTheMountain#acme.com"
altool --validate-app -f build/${ipaFileName} -u edOfTheMountain#acme.com -p #keychain:"Application Loader: edOfTheMountain#acme.com" --output-format xml > build/validate.xml
altoolValidate=$?
if [ ${altoolValidate} -ne 0 ]; then
echo "*** Error IPA failed to validate: build/${ipaFileName}"
echo "See: build/validate.xml"
exit 1
fi
echo "Rename build/${ipaFileName} to build/${renameIpaFileName}"
mv ./build/${ipaFileName} ./build/${renameIpaFileName}
echo ##############################
echo Done
echo ##############################
echo Ready to upload archive to iTunes:
echo " ${appArchiveFile}"
echo
uploadExample="$( echo altool --upload-app -f build/${renameIpaFileName} -u edOfTheMountain#acme.com -p #keychain:"Application Loader: edOfTheMountain#acme.com" )"
echo "Upload Example:\n ${uploadExample}"
echo

Related

android Alexa auto find downloaded ndk path

This is the setup-android-toolchin.sh file `
#!/bin/bash
set -e
THISDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source ${THISDIR}/common.sh
# Default external values
: ${NDK_PACKAGE:="android-ndk-r16b"}
: ${NDK_SHA1SUM:="42aa43aae89a50d1c66c3f9fdecd676936da6128"}
# Extra options
ANDROID_ABI=${1}
API_LEVEL=${2}
#
# Param checks
#
if [ -z ${ANDROID_TOOLCHAIN} ]; then
error "ANDROID_TOOLCHAIN is not set"
fi
if [ -z ${ANDROID_ABI} ] || [ -z ${API_LEVEL} ]; then
error "Please specify ABI/API"
fi
# Android toolchain path
ANDROID_NDK="${ANDROID_TOOLCHAIN}/ndk"
ANDROID_SDK="${ANDROID_TOOLCHAIN}/sdk"
# Standard Android path
ANDROID_NDK_HOME="${ANDROID_NDK}/ndk-bundle/${NDK_PACKAGE}"
# OS detection
if [ $(uname) = "Darwin" ]; then
HOST="darwin"
else
HOST="linux"
fi
install() {
filename=${1}
checksum=${2}
dest=${3}
tmpdir=${ANDROID_TOOLCHAIN}
tmpfile=${tmpdir}/${filename}
if [ -e ${tmpfile} ] && [ ! "$(sha1sum ${tmpfile})" = "${checksum}" ]; then
warn "SHA1 checksum is wrong, re-download NDK package..."
rm ${tmpfile}
fi
if [ ! -e ${dest} ]; then
note "Downloading file ${filename}"
wget --no-check-certificate https://dl.google.com/android/repository/${filename} -P ${tmpdir}
sha1sum ${tmpfile}
fi
mkdir -p ${dest}
pushd ${dest}
unzip -q ${tmpfile}
popd
}
generate_toolchain() {
case ${ANDROID_ABI} in
x86)
ARCH="x86"
;;
x86_64)
ARCH="x86_64"
;;
armeabi-v7a)
ARCH="arm"
;;
arm64-v8a)
ARCH="arm64"
;;
*)
error "Unknown ABI: ${ANDROID_ABI}"
esac
TOOLCHAIN="${ANDROID_NDK}/toolchains/${NDK_PACKAGE}/toolchain-${ANDROID_ABI}/android-${API_LEVEL}"
if [ ! -d ${TOOLCHAIN} ]; then
note "Generating Standalone Toolchain..."
${ANDROID_NDK}/ndk-bundle/${NDK_PACKAGE}/build/tools/make_standalone_toolchain.py \
--arch="${ARCH}" \
--api="${API_LEVEL}" \
--stl="libc++" \
--force \
--install-dir="${TOOLCHAIN}"
fi
}
note "Checking Android toolchain installation (${ANDROID_ABI}/${API_LEVEL})..."
if [ ! -d ${ANDROID_NDK_HOME} ]; then
note "Installing NDK (${NDK_PACKAGE})..."
install ${NDK_PACKAGE}-${HOST}-x86_64.zip ${NDK_SHA1SUM} ${ANDROID_NDK}/ndk-bundle
fi
if [ ! -d ${ANDROID_SDK} ]; then
note "Installing SDK Tools..."
install sdk-tools-${HOST}-3859397.zip "7eab0ada7ff28487e1b340cc3d866e70bcb4286e" ${ANDROID_SDK}
fi
generate_toolchain
`. After running the script it downloaded the NDK in /workdir/android. I am not getting where it has downloaded the NDK as I am not able to find it through finder(Mac OS High Sierra). Can anyone tell the path to where I can find the NDK. Using search option is not helping me.

How to install Android Studio from cli

I am curling the latest Android Studio dmg file, mounting the image and copying the .app directory into the Applications directory. When I attempt to open the directory I receive this warning, and when I query the application state, I also receive the code below. Any idea how I can generically install Android Studio from the cli?
Warning:
"Android Studio" is damaged and can't be opened. You should move it to the Trash. Google Chrome.app downloaded this file on
...
| => spctl -a /Applications/Android\ Studio.app/
/Applications/Android Studio.app/: a sealed resource is missing or invalid
...
| => codesign --display --verbose=4 /Applications/Android\ Studio.app/
Executable=/Applications/Android Studio.app/Contents/MacOS/studio
Identifier=com.google.android.studio
Format=app bundle with Mach-O universal (i386 x86_64)
CodeDirectory v=20200 size=537 flags=0x0(none) hashes=11+3 location=embedded
OSPlatform=36
OSSDKVersion=657664
OSVersionMin=657408
Hash type=sha256 size=32
CandidateCDHash sha1=4456b3e77035b4318af16276667c88f7b7d4f9ac
CandidateCDHash sha256=6d95335c6815111d93abd1e87b9fd4648d991bdd
Hash choices=sha1,sha256
Page size=4096
CDHash=6d95335c6815111d93abd1e87b9fd4648d991bdd
Signature size=8948
Authority=Developer ID Application: Google, Inc. (EQHXZ8M8AV)
Authority=Developer ID Certification Authority
Authority=Apple Root CA
Timestamp=Dec 1, 2016, 4:57:25 PM
Info.plist entries=22
TeamIdentifier=EQHXZ8M8AV
Sealed Resources version=2 rules=12 files=11250
Internal requirements count=1 size=188
Android Install Script
#!/usr/bin/env bash
echo "Installing Android Studio"
ANDROID_STUDIO_DMG=$(curl -0 https://developer.android.com/studio/index.html | grep -o --regexp='https://dl.google.com/dl/android/studio/install/[a-zA-Z0-9./?=_-]*/android-studio-ide-[a-zA-Z0-9./?=_-]*-mac.dmg')
./dmginstall.sh $ANDROID_STUDIO_DMG
DMG Install Script - (Modified:https://gist.github.com/rahulgautam/6695872)
#!/usr/bin/env bash
# Downloads and install a .dmg from a URL
#
# Usage
# $ dmginstall [url]
#
# For example, for installing android-studio-ide
# $ dmginstall https://dl.google.com/dl/android/studio/install/2.2.3.0/android-studio-ide-145.3537739-mac.dmg
#
# TODO
# - currently only handles .dmg with .app folders, not .pkg files
# - handle .zip files as well
if [[ $# -lt 1 ]]; then
echo "Usage: dmginstall [url]"
exit 1
fi
url=$*
# Generate a random file name
tmp_file=/tmp/`openssl rand -base64 10 | tr -dc '[:alnum:]'`.dmg
# Download file
echo "Downloading $url..."
curl -# -L -o $tmp_file $url
echo "Please copy and paste the Volumes directory you would like to use"
echo "-----------------------------------------------------------------"
hdiutil mount $tmp_file
IFS= read -r -p "Enter volume: " volume
echo "$volume"
# Locate .app folder and move to /Applications
app=`find "$volume" -name *.app -maxdepth 1 -type d -print0`
echo "Copying `echo $app | awk -F/ '{print $NF}'` into /Applications..."
cp -rv "$app" '/Applications'
# Unmount volume, delete temporal file
echo "Cleaning up..."
hdiutil unmount "$volume"
rm "$tmp_file"
echo "Done!"

compile FFMpeg for Android (Ubuntu14) - cannot locate symbol

I'm trying to compile FFMpeg for Android and I have troubles running the APK on Android 4 (on Android 5 I don't get this shitty unsatisfied link error):
05-09 15:16:18.880 22160-22304/com.gpac.Osmo4 I/LibrariesLoader﹕ Loading library avcodec...
05-09 15:16:18.910 22160-22304/com.gpac.Osmo4 E/dalvikvm﹕ dlopen("/data/app-lib/com.gpac.Osmo4-1/libavcodec.so") failed: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "log2f" referenced by "libavcodec.so"...
05-09 15:16:18.920 22160-22304/com.gpac.Osmo4 E/LibrariesLoader﹕ Failed to load library : avcodec due to link error Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "log2f" referenced by "libavcodec.so"...
java.lang.UnsatisfiedLinkError: Cannot load library: soinfo_relocate(linker.cpp:975): cannot locate symbol "log2f" referenced by "libavcodec.so"...
I'm using NDK 10d, toolchain 4.9 but I was trying with NDK 8 and 9 also and I was getting the same result.
The only difference when I compile with older NDK versions is that I get a warning message:
incompatible declaration of built-in function log2f
I checked libm.so (where log2f should be) which is on the target device and of course there is no log2f function defined there but replacing the library by hand probably would crash some other stuff + I need to root the phone.
I know this is a linker issue and it should not be that hard to fix but I ran out of ideas.
EDIT:
I'm trying to compile ffmpeg 2.4.3
The script that I'm using to configure:
#!/bin/bash
if [ "$NDK" = "" ]; then
echo NDK variable not set, assuming ${HOME}/android-ndk
export NDK=${HOME}/android-ndk
fi
echo "Compiling with NDK located at: $NDK"
ROOT_DIR=`cd ..; pwd`
CUR_DIR=`pwd`
echo "Fetching Android system headers"
if [ ! -d "$ROOT_DIR/android-source/frameworks/base" ]; then
git clone --depth=1 --branch cm-11.0 https://github.com/CyanogenMod/android_frameworks_base.git "$ROOT_DIR/android-source/frameworks/base"
fi
if [ ! -d "$ROOT_DIR/android-source/system/core" ]; then
git clone --depth=1 --branch cm-11.0 https://github.com/CyanogenMod/android_system_core.git "$ROOT_DIR/android-source/system/core"
fi
if [ ! -d "$ROOT_DIR/android-source/frameworks/av" ]; then
git clone --depth=1 --branch cm-11.0 https://github.com/CyanogenMod/android_frameworks_av "$ROOT_DIR/android-source/frameworks/av"
fi
if [ ! -d "$ROOT_DIR/android-source/hardware/libhardware" ]; then
git clone --depth=1 --branch cm-11.0 https://github.com/CyanogenMod/android_hardware_libhardware.git "$ROOT_DIR/android-source/hardware/libhardware"
fi
if [ ! -d "$ROOT_DIR/android-source/frameworks/native" ]; then
git clone --depth=1 --branch cm-11.0 https://github.com/CyanogenMod/android_frameworks_native.git "$ROOT_DIR/android-source/frameworks/native"
fi
echo "Fetching Android libraries for linking"
# Libraries from any froyo/gingerbread device/emulator should work
# fine, since the symbols used should be available on most of them.
if [ ! -d "$ROOT_DIR/android-libs" ]; then
wget http://download.cyanogenmod.org/get/jenkins/65493/cm-10.2.1.3-serranoltexx.zip -P../
unzip ../cm-10.2.1.3-serranoltexx.zip system/lib/* -d../
mv ../system/lib "$ROOT_DIR/android-libs"
rmdir ../system
rm ../cm-10.2.1.3-serranoltexx.zip
fi
ANDROID_SOURCE="$ROOT_DIR/android-source"
echo "ANDROID_SOURCE: $ANDROID_SOURCE"
ANDROID_LIBS="$ROOT_DIR/android-libs"
OBJS="$ROOT_DIR/objs"
if [ "$DEST" = "" ]; then
rm -rf $ROOT_DIR/build/stagefright
mkdir -p $ROOT_DIR/build/stagefright
DEST=$ROOT_DIR/build/stagefright
fi
#for ABI in "armeabi-v7a" "armeabi" "x86"; do
for ABI in "armeabi-v7a" "armeabi"; do
if [ "$ABI" = "x86" ]; then
ARCH="x86"
TOOLCHAIN=`echo $NDK/toolchains/x86-4.9/prebuilt/*-x86*`
else
ARCH="arm"
TOOLCHAIN=`echo $NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/*-x86*`
fi
SYSROOT=$NDK/platforms/android-18/arch-$ARCH
# Expand the prebuilt/* path into the correct one
export PATH=$TOOLCHAIN/bin:$PATH
FLAGS="--target-os=linux --arch=$ARCH"
FLAGS="$FLAGS --sysroot=$SYSROOT"
FLAGS="$FLAGS --enable-shared --disable-doc --disable-ffplay --disable-ffprobe --disable-ffserver --disable-symver"
if [ "$ARCH" = "arm" ]; then
FLAGS="$FLAGS --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- --cpu=armv7-a --enable-libstagefright-h264"
#FLAGS="$FLAGS --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- --cpu=armv7-a"
else
FLAGS="$FLAGS --cross-prefix=$TOOLCHAIN/bin/i686-linux-android- --disable-asm"
fi
EXTRA_CFLAGS="-I$DEST/$ABI/include"
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$ANDROID_SOURCE/frameworks/base/include -I$ANDROID_SOURCE/system/core/include"
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$ANDROID_SOURCE/frameworks/native/include"
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$ANDROID_SOURCE/frameworks/native/include/media/openmax"
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$ANDROID_SOURCE/frameworks/av/include"
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$ANDROID_SOURCE/frameworks/av/media/libstagefright"
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$NDK/sources/cxx-stl/gnu-libstdc++/4.9/include -I$NDK/sources/cxx-stl/gnu-libstdc++/4.9/libs/$ABI/include"
EXTRA_CFLAGS="$EXTRA_CFLAGS -I$ANDROID_SOURCE/hardware/libhardware/include"
if [ "$ARCH" = "arm" ]; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -march=armv7-a -mfloat-abi=softfp -mfpu=neon -Wl,--no-undefined" #-Werror=implicit-function-declaration"
fi
EXTRA_LDFLAGS="-Wl,--fix-cortex-a8 -L$ANDROID_LIBS -Wl,-rpath-link,$ANDROID_LIBS -L$NDK/sources/cxx-stl/gnu-libstdc++/4.9/libs/$ABI"
EXTRA_CXXFLAGS="-Wno-multichar -fno-exceptions -fno-rtti"
FLAGS="$FLAGS --prefix=$DEST/$ABI"
mkdir -p $DEST/$ABI
mkdir -p $OBJS/$ABI
echo $FLAGS --extra-cflags="$EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS" --extra-cxxflags="$EXTRA_CXXFLAGS" > $DEST/$ABI/info.txt
echo "Configuring ..."
cd $OBJS/$ABI
$ROOT_DIR/configure $FLAGS --extra-cflags="$EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS" --extra-cxxflags="$EXTRA_CXXFLAGS" | tee $DEST/$ABI/configuration.txt
[ $PIPESTATUS == 0 ] || exit 1
echo "Making ..."
#make clean
make -j4 || exit 1
make install || exit 1
cd $CUR_DIR
done
You can use the latest NDK, only set platform to android-19 and not the latest android-21.
You use the libraries from some cyanogenmod build, which are "too good". For example, you get from there a libm.so that has log2(). Instead, you need the least common denominator of libm.so versions on supported devices. You don't need to look for such library; you have the "official" version in NDK.
I understand that to enable hardware codec, you need some "unofficial" libs. But be careful and put the directory with the downloaded libs closer to the end of your lookup list. Or safer still, only copy the few libs (like libcutils.so) that your link really needs.

How to build a Kony iOS Project using commandline

My aim is to build a Kony Project for the Jenkins CI. So basically I need to know how to build the project on the unix commandline. When using Kony Studio my project builds without issues.
I've already managed to build an android .apk using ant on the build.xml in the project directory. This also builds a .kar file for ios. How do I now trigger the ipa build via xcode using the commandline?
Environment: Mac OSX 10.10.2 with Kony Studio 6.0.
You need to copy the "com.kony.ios_5.5.x.jar" file and rename it to "com.kony.ios_5.5.x.zip".
Unzip the "com.kony.ios_5.5.x.zip",
The unzipped folder contains 5 files, one of it is "**iOS-GA-5.5.x.zip**".
Make sure that you DO NOT delete any of these 5 files.
Unzip the "iOS-GA-5.5.x.zip" , it will give you the "VMAppWithKonylib" folder.
Now, close all the xcodes you might have open.
Then delete data at path Users/(UserName)/Library/Developer/Xcode/DerivedData
Now go to Terminal
Navigates upto Gen folder using cd (e.g. cd /Users/foo/Desktop/VMAppWithKonylib/gen)
Type pearl extract.pl <KAR file path> and launch the Xcode and do a build. (e.g. perl extract.pl /Users/foo/Downloads/konyappiphone-193.kAR)
Now type open <xcodeproj path>. (e.g. open /Users/foo/Desktop/VMAppWithKonylib/VMAppWithKonylib.xcodeproj)
Now the app will run in xcode. Archive and proceed with IPA generation.
EDIT START
As of Kony 7 there is a better way to do headless builds:
http://docs.kony.com/konylibrary/visualizer/visualizer_user_guide/Content/CommandLine.htm
Basically use the HeadlessBuild.properties to configure your build and launch it with ant. It's a struggle in the beginning but we got a successful build of android and iOS via Jenkins.
Note: Building multiple projects at the same time does not seem to work (e.g. for multiple build types) and results in an error message. You'll have to build sequentially.
Comment if you're interested in the further build process and I'll consider writing a blog post about this :)
EDIT END
Finished a first version of a shell script to build a Kony Project for Android and iOS for Jenkins. Its far from elegant or perferct but it might be a good start for anyone who stumbles accross this post.
First I created a settings script which contains the configuration of my build (all values-to-be-entered are shown as <value> tags):
#!/bin/bash
# This script builds a Kony Project with following steps
# 1. Inject settings into global.properties, build.properties, middleware properties
# 2. Build Project by executing ant build.xml
# 2.1 When building android apps these are already packed as .apk
# 2.2 APK is signed
# 3. If iOS app is build the iOS dumyWorkspace (VMAppWithKonylib) is unzipped and filled with KAR file from ant build
# 3.1 the iOS app is archived
# 3.2 this iOS app is signed and exported as ipa
# 4. all APK and IPA files are copied to deploys folder.
# Note: The Directory the Kony Project is inside must be the name of the Kony Project. otherwise it will not build. This means, that if you clone your project from repository you'll have to put it into a folder or already have it checkedin as a folder.
_project_name=<Kony Application Project name. e.g. KonyTemplate>
# Targets
_target_android_phone=true
_target_android_tablet=false
_target_ios_phone=true
_target_ios_tablet=false
# Middleware Config
_middleware_ipaddress=127.0.0.1
_middleware_httpport=8080
_middleware_httpsport=443
# tools
_android_home=<android sdk home>
_android_zipalign=<zipalign in android build-tools>
_eclipse_equinox=<eclipse equinox jar in kony studio. e.g. /Users/userxyz/Kony_Studio/plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
_ant_bin_dir=<ant binary directory e.g. /usr/local/bin>
# you will need this parameter if you build an ios project. It is the You can retrieve it like this:
# - search for file "com.kony.ios_x.x.x.GA_vxxxxxxxxxxxx.jar" in Kony_Studio/plugins/ Folder
# - copy it to another folder and rename it as .zip
# - unzip
# - retrieve file "iOS-GA-x.x.x.zip" and copy it to destination referenced in _ios_dummy_project_zip variable
_ios_dummy_project_zip=<location of kony ios workspaced (zipeed). e.g. /Applications/Kony/Kony_Studio/iOS-GA-6.0.2.zip>
# OS Code Signing
_ios_code_sign_identity='<code sign identity>'
_ios_provisioning_profile_uuid='<xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx>'
_ios_provisioning_profile_name='<provisioning profile name'
# Android signing
_android_storepass=<keystore password>
_android_keyalias=<keystore alias>
_android_keypass=<key password>
_android_keystore=<keystore file within kony project directory. e.g. keystore.jks>
# Settings End
############################################################
# Execute
sh ./jenkins_build_internal.sh $_project_name $_target_android_phone $_target_android_tablet $_target_ios_phone $_target_ios_tablet $_middleware_ipaddress $_middleware_httpport $_middleware_httpsport $_removeprintstatements $_build $_android_home $_eclipse_equinox $_ant_bin_dir $_ios_dummy_project_zip "$_ios_code_sign_identity" "$_ios_provisioning_profile_uuid" "$_ios_provisioning_profile_name" $_android_zipalign $_android_storepass $_android_keyalias $_android_keypass $_android_keystore
I then have the actual script which does the build job as descripted at the top of the first script. Here we also do the Magic which Sam posted.
#!/bin/bash
####################
# Settings
_project_name=$1
# Targets
_target_android_phone=$2
_target_android_tablet=$3
_target_ios_phone=$4
_target_ios_tablet=$5
# Middleware Config
_middleware_ipaddress=$6
_middleware_httpport=$7
_middleware_httpsport=$8
# Build confif
_removeprintstatements=$9
_build=${10}
# Build tools Config
_android_home=${11}
_eclipse_equinox=${12}
_ant_bin_dir=${13}
_ios_dummy_project_zip=${14}
# OS Code Signing
_ios_code_sign_identity=${15}
_ios_provisioning_profile_uuid=${16}
_ios_provisioning_profile_name=${17}
# Android signing
_android_zipalign=${18}
_android_storepass=${19}
_android_keyalias=${20}
_android_keypass=${21}
_android_keystore=${22}
_sleep_while_xcode_startup=15
#######################
# Define functions
function escape_slashes {
sed 's/\//\\\//g'
}
function change_line {
local OLD_LINE_PATTERN=$1; shift
local NEW_LINE=$1; shift
local FILE=$1
local NEW=$(echo "${NEW_LINE}" | escape_slashes)
sed -i .bak '/'"${OLD_LINE_PATTERN}"'/s/.*/'"${NEW}"'/' "${FILE}"
mv "${FILE}.bak" /tmp/
}
#######################
# Dump Settings
echo "##### Executing Jenkins Kony Build #####"
echo "# Android Phone = " $_target_android_phone
echo "# Android Tablet = " $_target_android_tablet
echo "# iOS Phone = " $_target_ios_phone
echo "# iOS Tablet = " $_target_ios_tablet
echo "##### Executing Jenkins Kony Build #####"
echo ''
#######################
# Clean
echo "# cleaning up"
rm -rf binaries
rm -rf jssrc
#######################
# Inject properties
echo "# injecting properties"
change_line "^android=" "android=$_target_android_phone" build.properties
change_line "^androidtablet=" "androidtablet=$_target_android_tablet" build.properties
change_line "^iphone=" "iphone=$_target_ios_phone" build.properties
change_line "^ipad=" "ipad=$_target_ios_tablet" build.properties
change_line "^android.home=" "android.home=$_android_home" global.properties
change_line "^eclipse.equinox.path=" "eclipse.equinox.path=$_eclipse_equinox" global.properties
change_line "^httpport=" "httpport=$_middleware_httpport" middleware.properties
change_line "^httpsport=" "httpsport=$_middleware_httpsport" middleware.properties
change_line "^ipaddress=" "ipaddress=$_middleware_ipaddress" middleware.properties
#######################
# Execute Main Build - Ant
echo "## Execute Kony Ant Build - Start ##"
export PATH=$PATH:${_ant_bin_dir}
ant -file build.xml
echo "## Execute Kony Ant Build - Done ##"
echo ''
#######################
# Android app signing
if [ ${_target_android_phone} == "true" -o ${_target_android_tablet} == "true" ]
then
set +x
echo "## Execute Android signing APK - Start ##"
cd binaries/android
jarsigner -storepass "${_android_storepass}" -keypass "${_android_keypass}" -keystore ../../${_android_keystore} luavmandroid.apk ${_android_keyalias} -signedjar luavmandroid-signed_unaligned.apk
${_android_zipalign} -v 4 luavmandroid-signed_unaligned.apk luavmandroid-signed.apk
cd -
echo "## Execute Android signing APK - Done ##"
echo ''
fi
#######################
# Check and execute optional ios Workspace build for iphone
if [ ${_target_ios_phone} == "true" ]
then
echo "## Execute Kony iOS Workspace creation - Start ##"
cd ..
echo "# unzipping workspace #"
rm -rf VMAppWithKonylibiphone
unzip $_ios_dummy_project_zip -d .
mv VMAppWithKonylib VMAppWithKonylibiphone
cd VMAppWithKonylibiphone
cd gen
echo "# filling workspace #"
perl extract.pl ../../webapps/KonyTemplater/kbf/konyappiphone.KAR
# back to ios Workspace
cd ..
echo "## Execute Kony iOS iPhone Workspace creation - Done ##"
# dirty piece of code to create the scheme files... open xcode and close it again :)
echo "# opening project to generate scheme"
open VMAppWithKonylib.xcodeproj
sleep ${_sleep_while_xcode_startup}
echo "# close project"
osascript -e 'quit app "Xcode"'
echo "## Execute Kony iOS Archive - Start ##"
# create signed archive
xcodebuild -scheme KRelease -archivePath build/Archive.xcarchive archive PROVISIONING_PROFILE="${_ios_provisioning_profile_uuid}" CODE_SIGN_IDENTITY="${_ios_code_sign_identity}"
echo "## Execute Kony iOS Archive - Done ##"
echo "## Execute Kony iOS IPA Generation - Start ##"
# create ipa
xcodebuild -exportArchive -exportFormat IPA -archivePath build/Archive.xcarchive -exportPath build/KonyiOSApp.ipa -exportProvisioningProfile "${_ios_provisioning_profile_name}"
echo "## Execute Kony iOS IPA Generation - Done ##"
echo ''
fi
#######################
# Check and execute optional ios Workspace build for ipad
if [ ${_target_ios_tablet} == "true" ]
then
echo "## Execute Kony iOS Workspace creation - Start ##"
cd ..
echo "# unzipping workspace #"
rm -rf VMAppWithKonylibipad
unzip $_ios_dummy_project_zip -d .
mv VMAppWithKonylib VMAppWithKonylibipad
cd VMAppWithKonylibipad
cd gen
echo "# filling workspace #"
perl extract.pl ../../webapps/KonyTemplater/kbf/konyappipad.KAR
# back to ios Workspace
cd ..
echo "## Execute Kony iOS iPhone Workspace creation - Done ##"
echo "# opening project to generate scheme"
open VMAppWithKonylib.xcodeproj
sleep ${_sleep_while_xcode_startup}
echo "# close project"
osascript -e 'quit app "Xcode"'
echo "## Execute Kony iOS Archive - Start ##"
# create signed archive
xcodebuild -scheme KRelease -archivePath build/Archive.xcarchive archive PROVISIONING_PROFILE="${_ios_provisioning_profile_uuid}" CODE_SIGN_IDENTITY="${_ios_code_sign_identity}"
echo "## Execute Kony iOS Archive - Done ##"
echo "## Execute Kony iOS IPA Generation - Start ##"
# create ipa
xcodebuild -exportArchive -exportFormat IPA -archivePath build/Archive.xcarchive -exportPath build/KonyiOSApp.ipa -exportProvisioningProfile "${_ios_provisioning_profile_name}"
echo "## Execute Kony iOS IPA Generation - Done ##"
echo ''
fi
echo "## Copy Binaries to ./deploys/ ##"
cd ..
mkdir deploys
cp VMAppWithKonylibipad/build/KonyiOSApp.ipa deploys/app-release-ipad.ipa
cp VMAppWithKonylibiphone/build/KonyiOSApp.ipa deploys/app-release-iphone.ipa
cp ${_project_name}/binaries/android/luavmandroid-signed.apk deploys/app-release-android.apk
echo ''
echo ''
echo "## JENKINS BUILD SUCCESS ##"
echo ''
In the jenkins configuration I now only call the first script by executing a shell script:
cd KonyTemplate
sh ./jenkins_build.sh
If anyone has any suggestions to improve this little script (and there most definitely are plenty), I'm sure we'll all be happy to hear them.

Android valgrind build fails

Hello I'm trying to build valgrind for android-arm. On Linux Mint 13 it fails with:
$ make
echo "# This is a generated file, composed of the following suppression rules:" > default.supp
echo "# " exp-sgcheck.supp xfree-3.supp xfree-4.supp glibc-2.X-drd.supp glibc-2.34567-NPTL-helgrind.supp glibc-2.X.supp >> default.supp
cat exp-sgcheck.supp xfree-3.supp xfree-4.supp glibc-2.X-drd.supp glibc-2.34567-NPTL-helgrind.supp glibc-2.X.supp >> default.supp
make all-recursive
make[1]: Entering directory `/home/matt/Desktop/valgrind/valgrind-3.8.1'
Making all in include
make[2]: Entering directory `/home/matt/Desktop/valgrind/valgrind-3.8.1/include'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/matt/Desktop/valgrind/valgrind-3.8.1/include'
Making all in VEX
make[2]: Entering directory `/home/matt/Desktop/valgrind/valgrind-3.8.1/VEX'
make all-am
make[3]: Entering directory `/home/matt/Desktop/valgrind/valgrind-3.8.1/VEX'
gcc -DHAVE_CONFIG_H -I. -I.. -I.. -I../include -I../VEX/pub -DVGA_arm=1 -DVGO_linux=1 -DVGP_arm_linux=1 -DVGPV_arm_linux_vanilla=1 -Ipriv -m32 -O2 -g -Wall -Wmissing-prototypes -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations -Wno-format-zero-length -fno-strict-aliasing -fno-builtin -marm -mcpu=cortex-a8 -Wbad-function-cast -Wcast-qual -Wcast-align -fstrict-aliasing -Wno-long-long -Wno-pointer-sign -fno-stack-protector -MT libvex_arm_linux_a-main_globals.o -MD -MP -MF .deps/libvex_arm_linux_a-main_globals.Tpo -c -o libvex_arm_linux_a-main_globals.o `test -f 'priv/main_globals.c' || echo './'`priv/main_globals.c
gcc: warning: ‘-mcpu=’ is deprecated; use ‘-mtune=’ or ‘-march=’ instead
cc1: error: unrecognised command line option ‘-marm’
priv/main_globals.c:1:0: error: bad value (cortex-a8) for -mtune= switch
make[3]: *** [libvex_arm_linux_a-main_globals.o] Error 1
make[3]: Leaving directory `/home/matt/Desktop/valgrind/valgrind-3.8.1/VEX'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/matt/Desktop/valgrind/valgrind-3.8.1/VEX'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/matt/Desktop/valgrind/valgrind-3.8.1'
make: *** [all] Error 2
I am using ndk-r8e and valgrind 3.8.1. The configure ends with:
Maximum build arch: arm
Primary build arch: arm
Secondary build arch:
Build OS: linux
Primary build target: ARM_LINUX
Secondary build target:
Platform variant: vanilla
Primary -DVGPV string: -DVGPV_arm_linux_vanilla=1
Default supp files: exp-sgcheck.supp xfree-3.supp xfree-4.supp glibc-2.X-drd.supp glibc-2.34567-NPTL-helgrind.supp glibc-2.X.supp
What can I do to fix this? Alternatively, are there any pre-built android-arm valgrind binaries that I can use?
For building and installing Valgrind for Android use the bash script below, which I prefer to call build_valgrind.sh
To run with RUN_HELLO_JNI_THROUGH_VALGRIND=true you need two additional scripts (bootstrap_valgrind.sh, start_valgrind.sh) in the directory you run the script below from.
Running the script with the RUN_HELLO_JNI_THROUGH_VALGRIND=true flag will build the hello-jni application from the samples directory inside the Android NDK HOME, deploy it to the phone and run it through Valgrind, using either callgrind or memcheck tool, which you can specify in the start_valgrind.sh script.
The other two scripts are described here: https://stackoverflow.com/a/19235439/313113
Here's my directory structure:
|-- build_valgrind.sh (the script below)
|-- bootstrap_valgrind.sh (second script from https://stackoverflow.com/a/19235439/313113)
|-- start_valgrind.sh (first script from https://stackoverflow.com/a/19235439/313113)
|-- valgrind-3.10.0 (will be extracted by build_valgrind.sh)
`-- valgrind-3.10.0.tar.bz2 (will be downloaded by build_valgrind.sh)
I've tested that its working (memcheck and callgrind tools) on a Samsung Galaxy Nexus device with CyanogenMod 10.2.1 and Android 4.3.1 and CyanogenMod 11 20140804 snapshot, Android 4.4.4
You can see the file size of the generated output with: adb shell ls -lR "/sdcard/*grind*"
The build_valgrind.sh script:
#!/usr/bin/env bash
#set -x
function extract()
{
if [ -f "$1" ] ; then
case "$1" in
*.tar.bz2) tar xvjf "$1" ;;
*.tar.gz) tar xvzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar x "$1" ;;
*.gz) gunzip "$1" ;;
*.tar) tar xvf "$1" ;;
*.tbz2) tar xvjf "$1" ;;
*.tgz) tar xvzf "$1" ;;
*.zip) unzip "$1" ;;
*.Z) uncompress "$1" ;;
*.7z) 7z x "$1" ;;
*) echo "$1 cannot be extracted via >extract<" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
RUN_HELLO_JNI_THROUGH_VALGRIND=true
VALGRIND_VERSION="3.10.0"
VALGRIND_EXTENSION=".tar.bz2"
VALGRIND_DIRECTORY="valgrind-${VALGRIND_VERSION}"
VALGRIND_TARBALL="valgrind-${VALGRIND_VERSION}${VALGRIND_EXTENSION}"
# Only download Valgrind tarball again if not already downloaded
if [[ ! -f "${VALGRIND_TARBALL}" ]]; then
wget -v -nc "http://valgrind.org/downloads/${VALGRIND_TARBALL}"
fi
# Only extract Valgrind tarball again if not already extracted
if [[ ! -d "$VALGRIND_DIRECTORY" ]]; then
extract "$VALGRIND_TARBALL"
fi
# Ensure ANDROID_NDK_HOME is set
if [[ ! -z "$ANDROID_NDK_HOME" ]]; then
export ANDROID_NDK_HOME="$HOME/Software/Android/android-ndk-r10c"
fi
# Ensure ANDOID_SDK_HOME is set
if [[ ! -z "$ANDROID_SDK_HOME" ]]; then
export ANDROID_SDK_HOME="$HOME/Software/Android/android-sdk/"
fi
if [[ ! -d "$VALGRIND_DIRECTORY" ]];
then
echo "Problem with extracting Valgrind from $VALGRIND_TARBALL into $VALGRIND_DIRECTORY!!!"
exit -1
fi
# Move to extracted directory
cd "$VALGRIND_DIRECTORY"
# ARM Toolchain
ARCH_ABI="arm-linux-androideabi-4.9"
export AR="$ANDROID_NDK_HOME/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar"
export LD="$ANDROID_NDK_HOME/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld"
export CC="$ANDROID_NDK_HOME/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc"
export CXX="$ANDROID_NDK_HOME/toolchains/${ARCH_ABI}/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++"
[[ ! -d "$ANDROID_NDK_HOME" || ! -f "$AR" || ! -f "$LD" || ! -f "$CC" || ! -f "$CXX" ]] && echo "Make sure AR, LD, CC, CXX variables are defined correctly. Ensure ANDROID_NDK_HOME is defined also" && exit -1
# Configure build
export HWKIND="nexus_s"
ANDROID_PLATFORM=android-18
export CPPFLAGS="--sysroot=$ANDROID_NDK_HOME/platforms/${ANDROID_PLATFORM}/arch-arm -DANDROID_HARDWARE_$HWKIND"
export CFLAGS="--sysroot=$ANDROID_NDK_HOME/platforms/${ANDROID_PLATFORM}/arch-arm"
# BUG: For some reason file command is unable to detect if the file does not exist with ! -f , it says it doesn't exist even when it does!!!
BUILD=false
if [[ "${VALGRIND_DIRECTORY}/Inst/data/local/Inst/bin/valgrind" = *"No such file or directory"* ]]; then
BUILD=true
fi
if [[ "$BUILD" = true ]];
then
./configure --prefix="/data/local/Inst" \
--host="armv7-unknown-linux" \
--target="armv7-unknown-linux" \
--with-tmpdir="/sdcard "
[[ $? -ne 0 ]] && echo "Can't configure!" && exit -1
# Determine the number of jobs (commands) to be run simultaneously by GNU Make
NO_CPU_CORES=$(grep -c ^processor /proc/cpuinfo)
if [ $NO_CPU_CORES -le 8 ]; then
JOBS=$(($NO_CPU_CORES+1))
else
JOBS=${NO_CPU_CORES}
fi
# Compile Valgrind
make -j "${JOBS}"
[[ $? -ne 0 ]] && echo "Can't compile!" && exit -1
# Install Valgrind locally
make -j "${JOBS}" install DESTDIR="$(pwd)/Inst"
[[ $? -ne 0 ]] && echo "Can't install!" && exit -1
fi
# Push local Valgrind installtion to the phone
if [[ $(adb shell ls -ld /data/local/Inst/bin/valgrind) = *"No such file or directory"* ]];
then
adb root
adb remount
adb shell "[ ! -d /data/local/Inst ] && mkdir /data/local/Inst"
adb push Inst /
adb shell "ls -l /data/local/Inst"
# Ensure Valgrind on the phone is running
adb shell "/data/local/Inst/bin/valgrind --version"
# Add Valgrind executable to PATH (this might fail)
adb shell "export PATH=$PATH:/data/local/Inst/bin/"
fi
if [ $RUN_HELLO_JNI_THROUGH_VALGRIND = true ]; then
PACKAGE="com.example.hellojni"
# The location of the Hello JNI sample application
HELLO_JNI_PATH="$ANDROID_NDK_HOME/samples/hello-jni"
pushd "$HELLO_JNI_PATH"
# Update build target to the desired Android SDK version
ANDROID_PROJECT_TARGET="android-18"
android update project --target "$ANDROID_PROJECT_TARGET" --path . --name hello-jni --subprojects
# Enable Android NDK build with Ant
echo '<?xml version="1.0" encoding="utf-8"?>
<project name="HelloJni" basedir="." default="debug">
<target name="-pre-build">
<exec executable="${ndk.dir}/ndk-build" failonerror="true"/>
</target>
<target name="clean" depends="android_rules.clean">
<exec executable="${ndk.dir}/ndk-build" failonerror="true">
<arg value="clean"/>
</exec>
</target>
</project>
' > "custom_rules.xml"
# Set NDK HOME for Ant (only if not already set)
if ! grep -P -q "ndk.dir=.+" "local.properties" ; then
echo -e "\nndk.dir=$ANDROID_NDK_HOME" >> "local.properties"
fi
# Fix for Java 8 warning (warning: [options] source value 1.5 is obsolete and will be removed in a future release)
echo "java.compilerargs=-Xlint:-options" >> "ant.properties"
# Workaround INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES error
adb uninstall "$PACKAGE"
# Build Hello JNI project in debug mode and install it on the device
ant clean && ant debug && ant installd
popd
cd ..
# Start HelloJNI app
adb shell am start -a android.intent.action.MAIN -n $PACKAGE/.HelloJni
# Make the script executable
chmod a+x bootstrap_valgrind.sh
# Run application through Valgrind on the phone
/usr/bin/env bash bootstrap_valgrind.sh
adb shell ls -lR "/sdcard/*grind*"
adb shell ls -lR "/storage/sdcard0/*grind*"
adb shell ls -lR "/storage/sdcard1/*grind*"
fi
exit 0
This gets valgrind to compile for me on linux. (using android-ndk-r8e and valgrind-3.8.1)
There was no need to run autogen.sh since I downloaded the tar ball from the website.
Also make sure the TOOLCHAIN= line points to a valid toolchain.
export NDK_HOME=$HOME/Downloads/android-ndk-r8e
export HWKIND=generic
export TOOLCHAIN=$NDK_HOME/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi
export AR=$TOOLCHAIN-ar
export LD=$TOOLCHAIN-ld
export CC=$TOOLCHAIN-gcc
CPPFLAGS="--sysroot=$NDK_HOME/platforms/android-14/arch-arm -DANDROID_HARDWARE_$HWKIND" \
CFLAGS="--sysroot=$NDK_HOME/platforms/android-14/arch-arm" \
./configure --prefix=/data/local/Inst \
--host=armv7-unknown-linux --target=armv7-unknown-linux \
--with-tmpdir=/sdcard
make
It eventually came up with a compile error saying
$NDK_HOME/platforms/android-14/arch-arm/usr/include/elf.h:58:3: error: unknown type name 'uint32_t'
It seem like someone forgot to add #include <stdint.h> somewhere. To fix this I edited $NDK_HOME/platforms/android-14/arch-arm/usr/include/elf.h and added #include <stdint.h> to the include section of this header. NOTE: This is probably not the best fix but it is the one that I came up with that fixed the compilation errors.
On mac I was able to get it to compile up until the unknown type uint32_t part by changing how the configure script checks the kernel version.
Inside the configure script search of a line kernel=`uname -r` and change it to kernel=3.9.2. (There are two kernel=`uname -r` lines replace the first one or both if you feel like it)
This stops the configure script from looking at the host kernel when deciding how it should build valgrind. (uname -r grabs the host kernel)
I believe adding the #include <stdint.h> to elf.h should work on mac to but I have not tested it.
in android tutorial one option is missed
RANLIB, after I set it - I finally compiled valgrind-3.11.0 on osx for android
#/bin/sh
echo "NKDROOT: " $NDKROOT
export ANRDOID_TOOLCHAIN="arm-linux-androideabi-4.9"
# Set up toolchain paths.
#
# For ARM
export AR=$NDKROOT/toolchains/$ANRDOID_TOOLCHAIN/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ar
export LD=$NDKROOT/toolchains/$ANRDOID_TOOLCHAIN/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ld
export CC=$NDKROOT/toolchains/$ANRDOID_TOOLCHAIN/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc
export CXX=$NDKROOT/toolchains/$ANRDOID_TOOLCHAIN/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-g++
export RANLIB=$NDKROOT/toolchains/$ANRDOID_TOOLCHAIN/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ranlib
echo "AR: " $AR
echo "LD: " $LD
echo "CC: " $CC
echo "CXX: " $CXX
[[ ! -d "$NDKROOT" || ! -f "$AR" || ! -f "$LD" || ! -f "$CC" || ! -f "$CXX" ]] && echo "Make sure AR, LD, CC, CXX variables are defined correctly. Ensure NDKROOT is defined also" && exit -1
./autogen.sh
#if [ $? -ne 0 ]
#then
# exit 1
#else
# echo "autogen success!"
#fi
# for ARM
ANDROID_PLATFORM=android-3
ANDROID_SYSROOT="$NDKROOT/platforms/${ANDROID_PLATFORM}/arch-arm"
echo "SYSROOT: " $ANDROID_SYSROOT
export HWKIND=generic
export CPPFLAGS="--sysroot=$ANDROID_SYSROOT -DANDROID_HARDWARE_$HWKIND"
export CFLAGS="--sysroot=$ANDROID_SYSROOT -DANDROID_HARDWARE_$HWKIND"
export LDFLAGS="--sysroot=$ANDROID_SYSROOT -DANDROID_HARDWARE_$HWKIND"
export ARFLAGS="--sysroot=$ANDROID_SYSROOT -DANDROID_HARDWARE_$HWKIND"
./configure \
--prefix=/data/local/Inst \
--host=armv7-unknown-linux --target=armv7-unknown-linux \
--with-tmpdir=/sdcard
if [ $? -ne 0 ]
then
exit 1
else
echo "configure success!"
fi
# note: on android emulator, android-14 platform was also tested and works.
# It is not clear what this platform nr really is.
make -j7
if [ $? -ne 0 ]
then
exit 1
else
echo "build success!"
fi
make -j7 install DESTDIR=`pwd`/Inst
The problem I had was that the configure script was ignoring the environment variables. To configure the make file I instead did this:
sudo ./configure --prefix=/data/local/Inst --host=armv7-unknown-linux --target=armv7-unknown-linux --with-tmpdir=/sdcard0 CPPFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm -DANDROID_HARDWARE_$HWKIND" CFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm" CC=$CC LD=$LD AR=$AR
This ensures the variables are set properly and works with Linux Mint 13. It does not work on OSX Mountain Lion however. I'd advise anyone using OSX without access to a linux installation to try using linux on a virtual machine.

Categories

Resources