Skip to content

Commit

Permalink
upgrade android_new -> android + android -> android_old. Closes #497
Browse files Browse the repository at this point in the history
  • Loading branch information
tito committed May 15, 2017
1 parent b656922 commit 127c581
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 30 deletions.
35 changes: 17 additions & 18 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Buildozer currently supports packaging for Android via the `python-for-android
<http://github.com/kivy/python-for-android/>`_
project, and for iOS via the kivy-ios project. iOS and OSX are still under work.

For Android: please have a look at `Android-SDK-NDK-Informations
For Android: please have a look at `Android-SDK-NDK-Informations
<https://github.com/kivy/kivy/wiki/Android-SDK-NDK-Informations>`_. Please note that
the default SDK/NDK coded in Buildozer works for Python 2.

Expand Down Expand Up @@ -42,7 +42,7 @@ Installing Buildozer with python2 support:

buildozer init
# edit the buildozer.spec, then
buildozer android_new debug deploy run
buildozer android debug deploy run

Installing Buildozer with python3 support:
------------------------------------------
Expand Down Expand Up @@ -71,10 +71,9 @@ The pip package does not yet support python3.

#. Finally, build, deploy and run the app on your phone::

buildozer android_new debug deploy run

#. Please note the "android_new" buildozer target, and use that for any and all buildozer commands you run (even if the docs just say "android"). Python3 only works with the **android_new** toolchain.
buildozer android debug deploy run

#. Please note the "android" buildozer target, and use that for any and all buildozer commands you run (even if the docs just say "android").


Examples of Buildozer commands:
Expand All @@ -83,17 +82,17 @@ Examples of Buildozer commands:
::

# buildozer target command
buildozer android_new clean
buildozer android_new update
buildozer android_new deploy
buildozer android_new debug
buildozer android_new release
buildozer android clean
buildozer android update
buildozer android deploy
buildozer android debug
buildozer android release

# or all in one (compile in debug, deploy on device)
buildozer android_new debug deploy
buildozer android debug deploy

# set the default command if nothing set
buildozer setdefault android_new debug deploy run
buildozer setdefault android debug deploy run


Usage
Expand All @@ -106,9 +105,9 @@ Usage
buildozer --version

Available targets:
android Android target, based on python-for-android project (old toolchain)
ios iOS target, based on kivy-ios project
android_new Android target, based on python-for-android project (new toolchain)
android Android target, based on python-for-android project
ios iOS target, based on kivy-ios project
android_old Android target, based on python-for-android project (old toolchain)

Global commands (without target):
distclean Clean the whole Buildozer environment.
Expand All @@ -127,7 +126,7 @@ Usage
run Run the application on the device
serve Serve the bin directory via SimpleHTTPServer

Target "android" commands:
Target "android_old" commands:
adb Run adb from the Android SDK. Args must come after --, or
use --alias to make an alias
logcat Show the log from the device
Expand All @@ -136,7 +135,7 @@ Usage
list_identities List the available identities to use for signing.
xcode Open the xcode project.

Target "android_new" commands:
Target "android" commands:
adb Run adb from the Android SDK. Args must come after --, or
use --alias to make an alias
logcat Show the log from the device
Expand Down Expand Up @@ -196,7 +195,7 @@ Using your devices via the VM
There is a little icon on the bottom left that represent an USB plug.
Select it, and select your android device on it. Then you can check:

- `buildozer android_new adb -- devices`
- `buildozer android adb -- devices`

If it doesn't, use Google. They are so many differents way / issues
depending your phone that Google will be your only source of
Expand Down
24 changes: 21 additions & 3 deletions buildozer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def __init__(self, filename='buildozer.spec', target=None):
def set_target(self, target):
'''Set the target to use (one of buildozer.targets, such as "android")
'''
target = self.translate_target(target)
self.targetname = target
m = __import__('buildozer.targets.{0}'.format(target),
fromlist=['buildozer'])
Expand Down Expand Up @@ -914,6 +915,23 @@ def package_full_name(self):
# command line invocation
#

def translate_target(self, target, inverse=False):
# FIXME at some point, refactor to remove completely android old toolchain
if inverse:
if target == "android":
target = "android_old"
elif target == "android_new":
target = "android"
else:
if target == "android":
target = "android_new"
elif target == "android_new":
self.error("ERROR: The target android_new is now android")
exit(1)
elif target == "android_old":
target = "android"
return target

def targets(self):
for fn in listdir(join(dirname(__file__), 'targets')):
if fn.startswith('.') or fn.startswith('__'):
Expand All @@ -924,7 +942,7 @@ def targets(self):
try:
m = __import__('buildozer.targets.{0}'.format(target),
fromlist=['buildozer'])
yield target, m
yield self.translate_target(target, inverse=True), m
except NotImplementedError:
pass
except:
Expand Down Expand Up @@ -1032,8 +1050,8 @@ def run_command(self, args):

# maybe it's a target?
targets = [x[0] for x in self.targets()]
if command not in targets:
print('Unknown command/target {}'.format(command))
if self.translate_target(command, inverse=True) not in targets:
print('Unknown command/target {}'.format(self.translate_target(command, inverse=True)))
exit(1)

self.set_target(command)
Expand Down
2 changes: 1 addition & 1 deletion buildozer/default.spec
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ android.arch = armeabi-v7a
# (str) Filename to the hook for p4a
#p4a.hook =

# (str) Bootstrap to use for android builds (android_new only)
# (str) Bootstrap to use for android builds
# p4a.bootstrap = sdl2


Expand Down
2 changes: 1 addition & 1 deletion buildozer/targets/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@


class TargetAndroid(Target):
targetname = 'android'
targetname = 'android_old'
p4a_directory = "python-for-android"
p4a_branch = 'old_toolchain'
p4a_apk_cmd = "python build.py"
Expand Down
4 changes: 2 additions & 2 deletions buildozer/targets/android_new.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
'''
Android target, based on python-for-android project (new toolchain)
Android target, based on python-for-android project
'''

import sys
Expand All @@ -11,7 +11,7 @@


class TargetAndroidNew(TargetAndroid):
targetname = 'android_new'
targetname = 'android'
p4a_branch = "stable"
p4a_directory = "python-for-android-master"
p4a_apk_cmd = "apk --debug --bootstrap="
Expand Down
7 changes: 4 additions & 3 deletions buildozer/targets/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
$provisioningProfiles = glob('*.mobileprovision');
$plists = glob('*.plist');
$sr = stristr( $_SERVER['SCRIPT_URI'], '.php' ) === false ?
$sr = stristr( $_SERVER['SCRIPT_URI'], '.php' ) === false ?
$_SERVER['SCRIPT_URI'] : dirname($_SERVER['SCRIPT_URI']) . '/';
$provisioningProfile = $sr . $provisioningProfiles[0];
$ipa = $sr . $ipas[0];
$itmsUrl = urlencode( $sr . 'index.php?plist=' . str_replace( '.plist', '', $plists[0] ) );
if ($_GET['plist']) {
$plist = file_get_contents( dirname(__FILE__)
. DIRECTORY_SEPARATOR
$plist = file_get_contents( dirname(__FILE__)
. DIRECTORY_SEPARATOR
. preg_replace( '/![A-Za-z0-9-_]/i', '', $_GET['plist']) . '.plist' );
$plist = str_replace('_URL_', $ipa, $plist);
header('content-type: application/xml');
Expand Down Expand Up @@ -59,6 +59,7 @@
'''

class TargetIos(Target):
targetname = "ios"

def check_requirements(self):
checkbin = self.buildozer.checkbin
Expand Down
1 change: 1 addition & 0 deletions buildozer/targets/osx.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@


class TargetOSX(Target):
targetname = "osx"

def ensure_sdk(self):
self.buildozer.info('Check if kivy-sdk-packager exists')
Expand Down
4 changes: 2 additions & 2 deletions buildozer/tools/packer/http/welcome/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ <h2>How to use the VM</h2>
# update the build directory (issue with virtualbox shared folder and symlink)
build_dir = /build/myapp
</pre></li>
<li>Build your application: <code>buildozer android_new debug</code></li>
<li>Build and deploy, run and get the logs: <code>buildozer android_new debug deploy run logcat</code></li>
<li>Build your application: <code>buildozer android debug</code></li>
<li>Build and deploy, run and get the logs: <code>buildozer android debug deploy run logcat</code></li>
</ol>

<h2 id="sharefolder">Share a folder</h2>
Expand Down

0 comments on commit 127c581

Please sign in to comment.