From 1b1c0b9537d85c0bfb5e0e42cdf188f8046638f8 Mon Sep 17 00:00:00 2001 From: Igor Oliveira Date: Thu, 7 Dec 2017 08:08:19 -0200 Subject: [PATCH 1/3] Add android tor build script It is used to help the developer to fetch and build the app. Initially, three commands were add: 1. fetch: It fetches the external dependencies 2. build: Build the project in release or debug mode --- BUILD | 26 +++----------- tor-droid-make.sh | 92 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 22 deletions(-) create mode 100755 tor-droid-make.sh diff --git a/BUILD b/BUILD index 7bec2fca..9b5a32be 100644 --- a/BUILD +++ b/BUILD @@ -26,30 +26,12 @@ Android platform supports (ICS 4.x or android-15) Be sure that you have all of the git submodules up-to-date: - git submodule update --init --recursive + ./tor-droid-make.sh fetch -To begin building, from the Orbot root directory, you first need to build all -external C/native dependencies: +To begin building, from the Orbot root directory, it builds all submodules and +the project. - export ANDROID_NDK_HOME={PATH TO YOUR NDK INSTALL} - make -C external - -At this point, you'll have Tor and Polipo binaries that can be run on an -Android handset. You can verify the ARM binary was properly built using the -following command: - - file external/bin/tor external/bin/polipo - -You should see something like: - external/bin/tor: ELF 32-bit LSB executable, ARM, version 1 (SYSV), - dynamically linked (uses shared libs), not stripped - external/bin/polipo: ELF 32-bit LSB executable, ARM, version 1 (SYSV), - dynamically linked (uses shared libs), not stripped - -This isn't enough though and we'll now sew up the binary into a small package -that will handle basic Tor controlling features. - - android update project --name Orbot --target android-15 --path . + ./tor-droid-make.sh build Now build the Android app diff --git a/tor-droid-make.sh b/tor-droid-make.sh new file mode 100755 index 00000000..eb15c4fb --- /dev/null +++ b/tor-droid-make.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env bash + +set -e + +fetch_submodules() +{ + if [ -n "$1" ]; then + echo "Cleaning repository" + git reset --hard + git clean -fdx + git submodule foreach git reset --hard + git submodule foreach git clean -fdx + fi + echo "Fetching git submodules" + git submodule sync + git submodule foreach git submodule sync + git submodule update --init --recursive +} + +check_android_dependencies() +{ + if [ -z $ANDROID_HOME ]; then + echo "ANDROID_HOME must be set!" + exit + fi + + if [ -z $ANDROID_NDK_HOME ]; then + echo "ANDROID_NDK_HOME not set and 'ndk-build' not in PATH" + exit + fi +} + +build_external_dependencies() +{ + check_android_dependencies + make -C external +} + +build_app() +{ + echo "Building Orfox" + build_external_dependencies + $ANDROID_HOME/tools/android update project --name $2 --target $3 --path ./tor-android-binary/src/main/ + + if [ -z $1 ] || [ $1 = 'debug' ]; then + ./gradlew assembleDebug + else + ./gradlew assembleRelease + fi +} + +show_options() +{ + echo "usage: ./orbot-tools.sh command arguments" + echo "" + echo "Commands:" + echo " fetch Fetch git submodules" + echo " build Build the project" + echo "" + echo "Options:" + echo " -b Build type, it can be release or debug (default: debug)" + echo " -c Clean the repository (Used together with the fetch command)" + echo " -n Project name (default: Orbot)" + echo " -t Project target (default: android-23)" + echo "" + exit +} + +option=$1 +build_type="debug" +name="Orbot" +target="android-23" + +if [ -z $option ]; then + show_options +fi +shift + +while getopts 'c:b:n:t' opts; do + case $opts in + c) clean=clean ;; + b) build_type=${OPTARG:-$build_type} ;; + n) name=${OPTARG:-$Orbot} ;; + t) target=${OPTARG:-$target} ;; + esac +done + +case "$option" in + "fetch") fetch_submodules $clean ;; + "build") build_app $build_type $name $target ;; + *) show_options ;; +esac From fa5aff40cc7ebf3e7baeb9a2262824c7aedfae7d Mon Sep 17 00:00:00 2001 From: n8fr8 Date: Thu, 7 Dec 2017 10:53:51 -0500 Subject: [PATCH 2/3] update some strings in the script --- tor-droid-make.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tor-droid-make.sh b/tor-droid-make.sh index eb15c4fb..39708aa5 100755 --- a/tor-droid-make.sh +++ b/tor-droid-make.sh @@ -38,7 +38,7 @@ build_external_dependencies() build_app() { - echo "Building Orfox" + echo "Building tor-android" build_external_dependencies $ANDROID_HOME/tools/android update project --name $2 --target $3 --path ./tor-android-binary/src/main/ @@ -51,7 +51,7 @@ build_app() show_options() { - echo "usage: ./orbot-tools.sh command arguments" + echo "usage: ./tor-droid-make.sh command arguments" echo "" echo "Commands:" echo " fetch Fetch git submodules" @@ -60,7 +60,7 @@ show_options() echo "Options:" echo " -b Build type, it can be release or debug (default: debug)" echo " -c Clean the repository (Used together with the fetch command)" - echo " -n Project name (default: Orbot)" + echo " -n Project name (default: tor-android-binary)" echo " -t Project target (default: android-23)" echo "" exit @@ -68,7 +68,7 @@ show_options() option=$1 build_type="debug" -name="Orbot" +name="tor-android-binary" target="android-23" if [ -z $option ]; then From 13d0bddc8ce3220f91ed47a5d0eb1c53738401fc Mon Sep 17 00:00:00 2001 From: n8fr8 Date: Thu, 7 Dec 2017 12:36:38 -0500 Subject: [PATCH 3/3] update script to build for x86 and armeabi --- tor-droid-make.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tor-droid-make.sh b/tor-droid-make.sh index 39708aa5..1fdbb04a 100755 --- a/tor-droid-make.sh +++ b/tor-droid-make.sh @@ -33,7 +33,10 @@ check_android_dependencies() build_external_dependencies() { check_android_dependencies - make -C external + APP_ABI=armeabi make -C external clean + APP_ABI=armeabi make -C external + APP_ABI=x86 make -C external clean + APP_ABI=x86 make -C external } build_app()