Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
836327c
added .aar bundle (binary distribution of an Android Library Project)…
Oct 14, 2015
f3668e0
fixed aar support for recipes
Oct 14, 2015
0369158
added .aar bundle (binary distribution of an Android Library Project)…
Oct 14, 2015
05d1aea
fixed aar support for recipes
Oct 14, 2015
5933feb
Merge branch 'master' of https://github.com/ibobalo/python-for-android
Oct 14, 2015
28bb26c
cosmetic pygame log spam removed
Oct 14, 2015
60acd88
experimental recipe for VLC mediapleyer support
Oct 14, 2015
ab8bf58
recipes code cosmetic
Oct 19, 2015
ce4ea62
code cosmetic
Oct 19, 2015
cc50d62
cosmetic fixed minor logging in pygame bootstrap
Oct 27, 2015
fdcf5e7
added sdl2 bootstrap meta and presplash
Oct 27, 2015
c86c80f
sdl2 bootstrap default presplash image added
Oct 27, 2015
9bc52b6
fix for android native in sdl2 bootstrap transparent surface
ibobalo Oct 27, 2015
f891bdc
cosmetic toolchain logging outputs
ibobalo Oct 27, 2015
0284511
cosmetic toolchain log output beautification
ibobalo Oct 27, 2015
d891395
Merge remote-tracking branch 'upstream/master'
ibobalo Oct 28, 2015
9a036bb
added wakelock option for sdl2 bootstrap
ibobalo Oct 28, 2015
1a36bc0
toolchain log output cosmetic
ibobalo Oct 28, 2015
4275955
toolchain log output cosmetic
ibobalo Oct 28, 2015
f9b3976
toolchain log output cosmetic
ibobalo Oct 28, 2015
d1f1654
vlc recipe procompiled aar bundle handling improved
ibobalo Oct 29, 2015
e800908
toolchain log output cosmetic
ibobalo Oct 29, 2015
07b61c5
toolchain: improved functions to apply recipe patches
ibobalo Oct 30, 2015
e3f0f2e
toolchain log output cosmetic
ibobalo Nov 4, 2015
a614b14
Merge remote-tracking branch 'upstream/master'
ibobalo Nov 4, 2015
8ae6758
cosmetic logs
ibobalo Nov 4, 2015
406b236
Merge remote-tracking branch 'upstream/master'
ibobalo Nov 5, 2015
5bdaf52
toolchain log output cosmetic
ibobalo Nov 9, 2015
02f0a87
Merge remote-tracking branch 'upstream/master'
ibobalo Nov 9, 2015
8f04c7b
Merge remote-tracking branch 'upstream/master'
ibobalo Nov 16, 2015
4407cfa
toolchain log output cosmetic
ibobalo Nov 11, 2015
5fdbbd6
Merge remote-tracking branch 'upstream/master'
ibobalo Nov 24, 2015
f80d1f6
Merge remote-tracking branch 'upstream/master' into master
ibobalo Nov 25, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 10 additions & 28 deletions pythonforandroid/bootstraps/pygame/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, logger, info_main, which
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, info_main
from os.path import join, exists
from os import walk
import glob
Expand All @@ -19,6 +19,9 @@ def run_distribute(self):
# self.name)
src_path = join(self.bootstrap_dir, 'build')

# AND: Hardcoding armeabi - naughty!
arch = ArchAndroid(self.ctx)

with current_directory(self.dist_dir):

info('Creating initial layout')
Expand All @@ -40,21 +43,14 @@ def run_distribute(self):
info('Copying python distribution')
hostpython = sh.Command(self.ctx.hostpython)
# AND: This *doesn't* need to be in arm env?
shprint(hostpython, '-OO', '-m', 'compileall', self.ctx.get_python_install_dir())
shprint(hostpython, '-OO', '-m', 'compileall', self.ctx.get_python_install_dir(),
_tail=10, _filterout="^Listing", _critical=True)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do these extra arguments do? I thought they would be sh arguments, but couldn't find them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its new args of shprint. for pretty log optputs.
_tail mean show only N last lines of stdout. stderr will out full. like
command args | tail 10
_filterout mean do not print stdout lines matching regexp. like command
args | grep -v -e "re"
also _filter available
and _critical mean stop processing immediate after error, and do not
re-raise exception.
all this changes tot effect commands execution (except critical), just
butify its printout

2015-11-27 0:40 GMT+02:00 Alexander Taylor notifications@github.com:

In pythonforandroid/bootstraps/pygame/init.py
#480 (comment)
:

@@ -40,21 +43,14 @@ def run_distribute(self):
info('Copying python distribution')
hostpython = sh.Command(self.ctx.hostpython)
# AND: This doesn't need to be in arm env?

  •        shprint(hostpython, '-OO', '-m', 'compileall', self.ctx.get_python_install_dir())
    
  •        shprint(hostpython, '-OO', '-m', 'compileall', self.ctx.get_python_install_dir(),
    
  •                _tail=10, _filterout="^Listing", _critical=True)
    

What do these extra arguments do? I thought they would be sh arguments,
but couldn't find them.


Reply to this email directly or view it on GitHub
https://github.com/kivy/python-for-android/pull/480/files#r46009216.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a reason for limiting to the last 10 lines? If we're passing the output through to the user, don't we want to pass all of it (or, if debug is not enabled, none of it)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 its ok to drop patchall
2 presplash it was just experiment, actually no presplash code for sdl2 so
it is my fault to commit unused image
3. some commands produce really long outputs > 1000 lines. it was a big
problem for me to find error reason.
actually, in current state of p4a there no stdout listing at all (even id
debug) - just exception traceback and shortened last line. so, 10 lines is
much better then zero ?
anyway feel free to increase it to any reasonable number of lines you want
:)

2015-11-27 0:56 GMT+02:00 Alexander Taylor notifications@github.com:

In pythonforandroid/bootstraps/pygame/init.py
#480 (comment)
:

@@ -40,21 +43,14 @@ def run_distribute(self):
info('Copying python distribution')
hostpython = sh.Command(self.ctx.hostpython)
# AND: This doesn't need to be in arm env?

  •        shprint(hostpython, '-OO', '-m', 'compileall', self.ctx.get_python_install_dir())
    
  •        shprint(hostpython, '-OO', '-m', 'compileall', self.ctx.get_python_install_dir(),
    
  •                _tail=10, _filterout="^Listing", _critical=True)
    

Do you have a reason for limiting to the last 10 lines? If we're passing
the output through to the user, don't we want to pass all of it (or, if
debug is not enabled, none of it)?


Reply to this email directly or view it on GitHub
https://github.com/kivy/python-for-android/pull/480/files#r46009546.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, ignore my last reply, I understand better now and it seems good (though is there a reason for picking this tail number in particular?).

if not exists('python-install'):
shprint(sh.cp, '-a', self.ctx.get_python_install_dir(), './python-install')

info('Copying libs')
# AND: Hardcoding armeabi - naughty!
shprint(sh.mkdir, '-p', join('libs', 'armeabi'))
for lib in glob.glob(join(self.build_dir, 'libs', 'armeabi', '*')):
shprint(sh.cp, '-a', lib, join('libs', 'armeabi'))
for lib in glob.glob(join(self.ctx.get_libs_dir('armeabi'), '*')):
shprint(sh.cp, '-a', lib, join('libs', 'armeabi'))

info('Copying java files')
for filename in glob.glob(self.ctx.javaclass_dir):
shprint(sh.cp, '-a', filename, 'src')
self.distribute_libs(arch, [join(self.build_dir, 'libs', arch.arch), self.ctx.get_libs_dir(arch.arch)]);
self.distribute_aars(arch)
self.distribute_javaclasses(self.ctx.javaclass_dir)

info('Filling private directory')
if not exists(join('private', 'lib')):
Expand Down Expand Up @@ -91,21 +87,7 @@ def run_distribute(self):
shprint(sh.rm, '-rf', 'lib-dynload/_testcapi.so')


info('Stripping libraries')
env = ArchAndroid(self.ctx).get_env()
strip = which('arm-linux-androideabi-strip', env['PATH'])
if strip is None:
warning('Can\'t find strip in PATH...')
strip = sh.Command(strip)
filens = shprint(sh.find, join(self.dist_dir, 'private'), join(self.dist_dir, 'libs'),
'-iname', '*.so', _env=env).stdout.decode('utf-8')
logger.info('Stripping libraries in private dir')
for filen in filens.split('\n'):
try:
strip(filen, _env=env)
except sh.ErrorReturnCode_1:
logger.debug('Failed to strip ' + 'filen')

self.strip_libraries(arch)
super(PygameBootstrap, self).run_distribute()

bootstrap = PygameBootstrap()
2 changes: 1 addition & 1 deletion pythonforandroid/bootstraps/pygame/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def select(fn):
tf = tarfile.open(tfn, 'w:gz', format=tarfile.USTAR_FORMAT)
dirs = []
for fn, afn in files:
print('%s: %s' % (tfn, fn))
# print('%s: %s' % (tfn, fn))
dn = dirname(afn)
if dn not in dirs:
# create every dirs first if not exist yet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public boolean extractTar(String asset, String target) {
break;
}

Log.i("python", "extracting " + entry.getName());
Log.v("python", "extracting " + entry.getName());

if (entry.isDirectory()) {

Expand Down
36 changes: 10 additions & 26 deletions pythonforandroid/bootstraps/sdl2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, logger, info_main, which
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, info_main
from os.path import join, exists
from os import walk
import glob
Expand All @@ -20,6 +20,9 @@ def run_distribute(self):
with open('local.properties', 'w') as fileh:
fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir))

# AND: Hardcoding armeabi - naughty!
arch = ArchAndroid(self.ctx)

with current_directory(self.dist_dir):
info('Copying python distribution')

Expand All @@ -31,19 +34,14 @@ def run_distribute(self):
hostpython = sh.Command(self.ctx.hostpython)
# AND: This *doesn't* need to be in arm env?
shprint(hostpython, '-OO', '-m', 'compileall',
self.ctx.get_python_install_dir())
self.ctx.get_python_install_dir(),
_tail=10, _filterout="^Listing", _critical=True)
if not exists('python-install'):
shprint(sh.cp, '-a', self.ctx.get_python_install_dir(), './python-install')

info('Copying libs')
# AND: Hardcoding armeabi - naughty!
shprint(sh.mkdir, '-p', join('libs', 'armeabi'))
for lib in glob.glob(join(self.ctx.get_libs_dir('armeabi'), '*')):
shprint(sh.cp, '-a', lib, join('libs', 'armeabi'))

info('Copying java files')
for filename in glob.glob(self.ctx.javaclass_dir):
shprint(sh.cp, '-a', filename, 'src')
self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)])
self.distribute_aars(arch)
self.distribute_javaclasses(self.ctx.javaclass_dir)

info('Filling private directory')
if not exists(join('private', 'lib')):
Expand Down Expand Up @@ -81,21 +79,7 @@ def run_distribute(self):
# shprint(sh.rm, '-rf', 'lib-dynload/_ctypes_test.so')
# shprint(sh.rm, '-rf', 'lib-dynload/_testcapi.so')


info('Stripping libraries')
env = ArchAndroid(self.ctx).get_env()
strip = which('arm-linux-androideabi-strip', env['PATH'])
if strip is None:
warning('Can\'t find strip in PATH...')
strip = sh.Command(strip)
filens = shprint(sh.find, join(self.dist_dir, 'private'), join(self.dist_dir, 'libs'),
'-iname', '*.so', _env=env).stdout.decode('utf-8')
logger.info('Stripping libraries in private dir')
for filen in filens.split('\n'):
try:
strip(filen, _env=env)
except sh.ErrorReturnCode_1:
logger.debug('Failed to strip ' + 'filen')
self.strip_libraries(arch)
super(SDL2Bootstrap, self).run_distribute()

bootstrap = SDL2Bootstrap()
17 changes: 16 additions & 1 deletion pythonforandroid/bootstraps/sdl2/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def select(fn):
tf = tarfile.open(tfn, 'w:gz', format=tarfile.USTAR_FORMAT)
dirs = []
for fn, afn in files:
print('%s: %s' % (tfn, fn))
# print('%s: %s' % (tfn, fn))
dn = dirname(afn)
if dn not in dirs:
# create every dirs first if not exist yet
Expand Down Expand Up @@ -249,6 +249,10 @@ def make_package(args):
default_icon = 'templates/kivy-icon.png'
shutil.copy(args.icon or default_icon, 'res/drawable/icon.png')

default_presplash = 'templates/kivy-presplash.jpg'
shutil.copy(args.presplash or default_presplash,
'res/drawable/presplash.jpg')

versioned_name = (args.name.replace(' ', '').replace('\'', '') +
'-' + args.version)

Expand Down Expand Up @@ -324,6 +328,14 @@ def parse_args(args=None):
help='A png file to use as the icon for the application.')
ap.add_argument('--permission', dest='permissions', action='append',
help='The permissions to give this app.')
ap.add_argument('--meta-data', dest='meta_data', action='append',
help='Custom key=value to add in application metadata')
ap.add_argument('--presplash', dest='presplash',
help=('A jpeg file to use as a screen while the '
'application is loading.'))
ap.add_argument('--wakelock', dest='wakelock', action='store_true',
help=('Indicate if the application needs the device '
'to stay on'))

if args is None:
args = sys.argv[1:]
Expand All @@ -333,6 +345,9 @@ def parse_args(args=None):
if args.permissions is None:
args.permissions = []

if args.meta_data is None:
args.meta_data = []

make_package(args)

if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,34 @@
import java.io.FileWriter;
import java.io.File;

import android.view.ViewGroup;
import android.view.SurfaceView;
import android.app.Activity;
import android.util.Log;
import android.widget.Toast;
import android.os.Bundle;
import android.os.PowerManager;
import android.graphics.PixelFormat;
import android.view.SurfaceHolder;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.ApplicationInfo;

import org.libsdl.app.SDLActivity;

import org.renpy.android.ResourceManager;
import org.renpy.android.AssetExtract;


public class PythonActivity extends SDLActivity {
private static final String TAG = "PythonActivity";

public static PythonActivity mActivity = null;

private ResourceManager resourceManager;

private ResourceManager resourceManager = null;
private Bundle mMetaData = null;
private PowerManager.WakeLock mWakeLock = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
Log.v(TAG, "My oncreate running");
Expand All @@ -48,6 +59,25 @@ protected void onCreate(Bundle savedInstanceState) {


// nativeSetEnv("ANDROID_ARGUMENT", getFilesDir());

try {
Log.v(TAG, "Access to our meta-data...");
this.mMetaData = this.mActivity.getPackageManager().getApplicationInfo(
this.mActivity.getPackageName(), PackageManager.GET_META_DATA).metaData;

PowerManager pm = (PowerManager) this.mActivity.getSystemService(Context.POWER_SERVICE);
if ( this.mMetaData.getInt("wakelock") == 1 ) {
this.mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "Screen On");
}
if ( this.mMetaData.getInt("surface.transparent") != 0 ) {
Log.v(TAG, "Surface will be transparent.");
getSurface().setZOrderOnTop(true);
getSurface().getHolder().setFormat(PixelFormat.TRANSPARENT);
} else {
Log.i(TAG, "Surface will NOT be transparent");
}
} catch (PackageManager.NameNotFoundException e) {
}
}

// This is just overrides the normal SDLActivity, which just loads
Expand Down Expand Up @@ -169,6 +199,13 @@ public void unpackData(final String resource, File target) {
Log.w("python", e);
}
}
}

public static ViewGroup getLayout() {
return mLayout;
}

public static SurfaceView getSurface() {
return mSurface;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public boolean extractTar(String asset, String target) {
break;
}

Log.i("python", "extracting " + entry.getName());
Log.v("python", "extracting " + entry.getName());

if (entry.isDirectory()) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
android:allowBackup="true"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:hardwareAccelerated="true" >

{% for m in args.meta_data %}
<meta-data android:name="{{ m.split('=', 1)[0] }}" android:value="{{ m.split('=', 1)[-1] }}"/>{% endfor %}
<meta-data android:name="wakelock" android:value="{% if args.wakelock %}1{% else %}0{% endif %}"/>

<activity android:name="org.kivy.android.PythonActivity"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 8 additions & 24 deletions pythonforandroid/bootstraps/sdl2python3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, logger, info_main, which
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, info_main
from os.path import join, exists
from os import walk
import glob
Expand All @@ -22,6 +22,9 @@ def run_distribute(self):
with open('local.properties', 'w') as fileh:
fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir))

# AND: Hardcoding armeabi - naughty!
arch = ArchAndroid(self.ctx)

with current_directory(self.dist_dir):
info('Copying python distribution')

Expand All @@ -37,15 +40,9 @@ def run_distribute(self):
if not exists('python-install'):
shprint(sh.cp, '-a', join(self.ctx.build_dir, 'python-install'), '.')

info('Copying libs')
# AND: Hardcoding armeabi - naughty!
shprint(sh.mkdir, '-p', join('libs', 'armeabi'))
for lib in glob.glob(join(self.ctx.libs_dir, '*')):
shprint(sh.cp, '-a', lib, join('libs', 'armeabi'))

info('Copying java files')
for filename in glob.glob(join(self.ctx.build_dir, 'java', '*')):
shprint(sh.cp, '-a', filename, 'src')
self.distribute_libs(arch, [self.ctx.libs_dir])
self.distribute_aars(arch)
self.distribute_javaclasses(join(self.ctx.build_dir, 'java'))

info('Filling private directory')
if not exists(join('private', 'lib')):
Expand Down Expand Up @@ -85,20 +82,7 @@ def run_distribute(self):
# shprint(sh.rm, '-rf', 'lib-dynload/_testcapi.so')


info('Stripping libraries')
env = ArchAndroid(self.ctx).get_env()
strip = which('arm-linux-androideabi-strip', env['PATH'])
if strip is None:
warning('Can\'t find strip in PATH...')
strip = sh.Command(strip)
filens = shprint(sh.find, join(self.dist_dir, 'private'), join(self.dist_dir, 'libs'),
'-iname', '*.so', _env=env).stdout.decode('utf-8')
logger.info('Stripping libraries in private dir')
for filen in filens.split('\n'):
try:
strip(filen, _env=env)
except sh.ErrorReturnCode_1:
logger.debug('Failed to strip ' + 'filen')
self.strip_libraries(arch)
super(SDL2Bootstrap, self).run_distribute()

bootstrap = SDL2Bootstrap()
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public boolean extractTar(String asset, String target) {
break;
}

Log.i("python", "extracting " + entry.getName());
Log.v("python", "extracting " + entry.getName());

if (entry.isDirectory()) {

Expand Down
4 changes: 3 additions & 1 deletion pythonforandroid/recipes/pygame/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def prebuild_armeabi(self):
join(self.get_build_dir('armeabi'), 'Setup'))
self.apply_patch(join('patches', 'fix-surface-access.patch'))
self.apply_patch(join('patches', 'fix-array-surface.patch'))
self.apply_patch(join('patches', 'fix-sdl-spam-log.patch'))
shprint(sh.touch, join(self.get_build_container_dir('armeabi'), '.patched'))

def build_armeabi(self):
Expand All @@ -59,7 +60,8 @@ def build_armeabi(self):
with current_directory(self.get_build_dir('armeabi')):
info('hostpython is ' + self.ctx.hostpython)
hostpython = sh.Command(self.ctx.hostpython)
shprint(hostpython, 'setup.py', 'install', '-O2', _env=env)
shprint(hostpython, 'setup.py', 'install', '-O2', _env=env,
_tail=10, _critical=True)

info('strip is ' + env['STRIP'])
build_lib = glob.glob('./build/lib*')
Expand Down
Loading