Skip to content

Commit 6f7ef8a

Browse files
committed
Merge branch 'ibobalo-master'
2 parents a30fc53 + a0497f6 commit 6f7ef8a

File tree

16 files changed

+385
-114
lines changed

16 files changed

+385
-114
lines changed

pythonforandroid/bootstraps/pygame/__init__.py

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, logger, info_main, which
1+
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, info_main
22
from os.path import join, exists
33
from os import walk
44
import glob
@@ -19,6 +19,9 @@ def run_distribute(self):
1919
# self.name)
2020
src_path = join(self.bootstrap_dir, 'build')
2121

22+
# AND: Hardcoding armeabi - naughty!
23+
arch = ArchAndroid(self.ctx)
24+
2225
with current_directory(self.dist_dir):
2326

2427
info('Creating initial layout')
@@ -40,21 +43,14 @@ def run_distribute(self):
4043
info('Copying python distribution')
4144
hostpython = sh.Command(self.ctx.hostpython)
4245
# AND: This *doesn't* need to be in arm env?
43-
shprint(hostpython, '-OO', '-m', 'compileall', self.ctx.get_python_install_dir())
46+
shprint(hostpython, '-OO', '-m', 'compileall', self.ctx.get_python_install_dir(),
47+
_tail=10, _filterout="^Listing", _critical=True)
4448
if not exists('python-install'):
4549
shprint(sh.cp, '-a', self.ctx.get_python_install_dir(), './python-install')
4650

47-
info('Copying libs')
48-
# AND: Hardcoding armeabi - naughty!
49-
shprint(sh.mkdir, '-p', join('libs', 'armeabi'))
50-
for lib in glob.glob(join(self.build_dir, 'libs', 'armeabi', '*')):
51-
shprint(sh.cp, '-a', lib, join('libs', 'armeabi'))
52-
for lib in glob.glob(join(self.ctx.get_libs_dir('armeabi'), '*')):
53-
shprint(sh.cp, '-a', lib, join('libs', 'armeabi'))
54-
55-
info('Copying java files')
56-
for filename in glob.glob(self.ctx.javaclass_dir):
57-
shprint(sh.cp, '-a', filename, 'src')
51+
self.distribute_libs(arch, [join(self.build_dir, 'libs', arch.arch), self.ctx.get_libs_dir(arch.arch)]);
52+
self.distribute_aars(arch)
53+
self.distribute_javaclasses(self.ctx.javaclass_dir)
5854

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

9389

94-
info('Stripping libraries')
95-
env = ArchAndroid(self.ctx).get_env()
96-
strip = which('arm-linux-androideabi-strip', env['PATH'])
97-
if strip is None:
98-
warning('Can\'t find strip in PATH...')
99-
strip = sh.Command(strip)
100-
filens = shprint(sh.find, join(self.dist_dir, 'private'), join(self.dist_dir, 'libs'),
101-
'-iname', '*.so', _env=env).stdout.decode('utf-8')
102-
logger.info('Stripping libraries in private dir')
103-
for filen in filens.split('\n'):
104-
try:
105-
strip(filen, _env=env)
106-
except sh.ErrorReturnCode_1:
107-
logger.debug('Failed to strip ' + 'filen')
108-
90+
self.strip_libraries(arch)
10991
super(PygameBootstrap, self).run_distribute()
11092

11193
bootstrap = PygameBootstrap()

pythonforandroid/bootstraps/pygame/build/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def select(fn):
183183
tf = tarfile.open(tfn, 'w:gz', format=tarfile.USTAR_FORMAT)
184184
dirs = []
185185
for fn, afn in files:
186-
print('%s: %s' % (tfn, fn))
186+
# print('%s: %s' % (tfn, fn))
187187
dn = dirname(afn)
188188
if dn not in dirs:
189189
# create every dirs first if not exist yet

pythonforandroid/bootstraps/pygame/build/src/org/renpy/android/AssetExtract.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public boolean extractTar(String asset, String target) {
6060
break;
6161
}
6262

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

6565
if (entry.isDirectory()) {
6666

pythonforandroid/bootstraps/sdl2/__init__.py

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, logger, info_main, which
1+
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, info_main
22
from os.path import join, exists
33
from os import walk
44
import glob
@@ -20,6 +20,9 @@ def run_distribute(self):
2020
with open('local.properties', 'w') as fileh:
2121
fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir))
2222

23+
# AND: Hardcoding armeabi - naughty!
24+
arch = ArchAndroid(self.ctx)
25+
2326
with current_directory(self.dist_dir):
2427
info('Copying python distribution')
2528

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

38-
info('Copying libs')
39-
# AND: Hardcoding armeabi - naughty!
40-
shprint(sh.mkdir, '-p', join('libs', 'armeabi'))
41-
for lib in glob.glob(join(self.ctx.get_libs_dir('armeabi'), '*')):
42-
shprint(sh.cp, '-a', lib, join('libs', 'armeabi'))
43-
44-
info('Copying java files')
45-
for filename in glob.glob(self.ctx.javaclass_dir):
46-
shprint(sh.cp, '-a', filename, 'src')
42+
self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)])
43+
self.distribute_aars(arch)
44+
self.distribute_javaclasses(self.ctx.javaclass_dir)
4745

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

84-
85-
info('Stripping libraries')
86-
env = ArchAndroid(self.ctx).get_env()
87-
strip = which('arm-linux-androideabi-strip', env['PATH'])
88-
if strip is None:
89-
warning('Can\'t find strip in PATH...')
90-
strip = sh.Command(strip)
91-
filens = shprint(sh.find, join(self.dist_dir, 'private'), join(self.dist_dir, 'libs'),
92-
'-iname', '*.so', _env=env).stdout.decode('utf-8')
93-
logger.info('Stripping libraries in private dir')
94-
for filen in filens.split('\n'):
95-
try:
96-
strip(filen, _env=env)
97-
except sh.ErrorReturnCode_1:
98-
logger.debug('Failed to strip ' + 'filen')
82+
self.strip_libraries(arch)
9983
super(SDL2Bootstrap, self).run_distribute()
10084

10185
bootstrap = SDL2Bootstrap()

pythonforandroid/bootstraps/sdl2/build/build.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def select(fn):
166166
tf = tarfile.open(tfn, 'w:gz', format=tarfile.USTAR_FORMAT)
167167
dirs = []
168168
for fn, afn in files:
169-
print('%s: %s' % (tfn, fn))
169+
# print('%s: %s' % (tfn, fn))
170170
dn = dirname(afn)
171171
if dn not in dirs:
172172
# create every dirs first if not exist yet
@@ -249,6 +249,10 @@ def make_package(args):
249249
default_icon = 'templates/kivy-icon.png'
250250
shutil.copy(args.icon or default_icon, 'res/drawable/icon.png')
251251

252+
default_presplash = 'templates/kivy-presplash.jpg'
253+
shutil.copy(args.presplash or default_presplash,
254+
'res/drawable/presplash.jpg')
255+
252256
versioned_name = (args.name.replace(' ', '').replace('\'', '') +
253257
'-' + args.version)
254258

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

328340
if args is None:
329341
args = sys.argv[1:]
@@ -333,6 +345,9 @@ def parse_args(args=None):
333345
if args.permissions is None:
334346
args.permissions = []
335347

348+
if args.meta_data is None:
349+
args.meta_data = []
350+
336351
make_package(args)
337352

338353
if __name__ == "__main__":

pythonforandroid/bootstraps/sdl2/build/src/org/kivy/android/PythonActivity.java

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,34 @@
77
import java.io.FileWriter;
88
import java.io.File;
99

10+
import android.view.ViewGroup;
11+
import android.view.SurfaceView;
1012
import android.app.Activity;
1113
import android.util.Log;
1214
import android.widget.Toast;
1315
import android.os.Bundle;
16+
import android.os.PowerManager;
17+
import android.graphics.PixelFormat;
18+
import android.view.SurfaceHolder;
19+
import android.content.Context;
20+
import android.content.pm.PackageManager;
21+
import android.content.pm.ApplicationInfo;
1422

1523
import org.libsdl.app.SDLActivity;
1624

1725
import org.renpy.android.ResourceManager;
1826
import org.renpy.android.AssetExtract;
1927

28+
2029
public class PythonActivity extends SDLActivity {
2130
private static final String TAG = "PythonActivity";
2231

2332
public static PythonActivity mActivity = null;
2433

25-
private ResourceManager resourceManager;
26-
34+
private ResourceManager resourceManager = null;
35+
private Bundle mMetaData = null;
36+
private PowerManager.WakeLock mWakeLock = null;
37+
2738
@Override
2839
protected void onCreate(Bundle savedInstanceState) {
2940
Log.v(TAG, "My oncreate running");
@@ -48,6 +59,25 @@ protected void onCreate(Bundle savedInstanceState) {
4859

4960

5061
// nativeSetEnv("ANDROID_ARGUMENT", getFilesDir());
62+
63+
try {
64+
Log.v(TAG, "Access to our meta-data...");
65+
this.mMetaData = this.mActivity.getPackageManager().getApplicationInfo(
66+
this.mActivity.getPackageName(), PackageManager.GET_META_DATA).metaData;
67+
68+
PowerManager pm = (PowerManager) this.mActivity.getSystemService(Context.POWER_SERVICE);
69+
if ( this.mMetaData.getInt("wakelock") == 1 ) {
70+
this.mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "Screen On");
71+
}
72+
if ( this.mMetaData.getInt("surface.transparent") != 0 ) {
73+
Log.v(TAG, "Surface will be transparent.");
74+
getSurface().setZOrderOnTop(true);
75+
getSurface().getHolder().setFormat(PixelFormat.TRANSPARENT);
76+
} else {
77+
Log.i(TAG, "Surface will NOT be transparent");
78+
}
79+
} catch (PackageManager.NameNotFoundException e) {
80+
}
5181
}
5282

5383
// This is just overrides the normal SDLActivity, which just loads
@@ -169,6 +199,13 @@ public void unpackData(final String resource, File target) {
169199
Log.w("python", e);
170200
}
171201
}
202+
}
203+
204+
public static ViewGroup getLayout() {
205+
return mLayout;
206+
}
172207

208+
public static SurfaceView getSurface() {
209+
return mSurface;
173210
}
174211
}

pythonforandroid/bootstraps/sdl2/build/src/org/renpy/android/AssetExtract.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public boolean extractTar(String asset, String target) {
6060
break;
6161
}
6262

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

6565
if (entry.isDirectory()) {
6666

pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.xml.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
android:allowBackup="true"
3939
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
4040
android:hardwareAccelerated="true" >
41+
42+
{% for m in args.meta_data %}
43+
<meta-data android:name="{{ m.split('=', 1)[0] }}" android:value="{{ m.split('=', 1)[-1] }}"/>{% endfor %}
44+
<meta-data android:name="wakelock" android:value="{% if args.wakelock %}1{% else %}0{% endif %}"/>
45+
4146
<activity android:name="org.kivy.android.PythonActivity"
4247
android:label="@string/app_name"
4348
android:configChanges="keyboardHidden|orientation"

pythonforandroid/bootstraps/sdl2python3/__init__.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, logger, info_main, which
1+
from pythonforandroid.toolchain import Bootstrap, shprint, current_directory, info, warning, ArchAndroid, info_main
22
from os.path import join, exists
33
from os import walk
44
import glob
@@ -22,6 +22,9 @@ def run_distribute(self):
2222
with open('local.properties', 'w') as fileh:
2323
fileh.write('sdk.dir={}'.format(self.ctx.sdk_dir))
2424

25+
# AND: Hardcoding armeabi - naughty!
26+
arch = ArchAndroid(self.ctx)
27+
2528
with current_directory(self.dist_dir):
2629
info('Copying python distribution')
2730

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

40-
info('Copying libs')
41-
# AND: Hardcoding armeabi - naughty!
42-
shprint(sh.mkdir, '-p', join('libs', 'armeabi'))
43-
for lib in glob.glob(join(self.ctx.libs_dir, '*')):
44-
shprint(sh.cp, '-a', lib, join('libs', 'armeabi'))
45-
46-
info('Copying java files')
47-
for filename in glob.glob(join(self.ctx.build_dir, 'java', '*')):
48-
shprint(sh.cp, '-a', filename, 'src')
43+
self.distribute_libs(arch, [self.ctx.libs_dir])
44+
self.distribute_aars(arch)
45+
self.distribute_javaclasses(join(self.ctx.build_dir, 'java'))
4946

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

8784

88-
info('Stripping libraries')
89-
env = ArchAndroid(self.ctx).get_env()
90-
strip = which('arm-linux-androideabi-strip', env['PATH'])
91-
if strip is None:
92-
warning('Can\'t find strip in PATH...')
93-
strip = sh.Command(strip)
94-
filens = shprint(sh.find, join(self.dist_dir, 'private'), join(self.dist_dir, 'libs'),
95-
'-iname', '*.so', _env=env).stdout.decode('utf-8')
96-
logger.info('Stripping libraries in private dir')
97-
for filen in filens.split('\n'):
98-
try:
99-
strip(filen, _env=env)
100-
except sh.ErrorReturnCode_1:
101-
logger.debug('Failed to strip ' + 'filen')
85+
self.strip_libraries(arch)
10286
super(SDL2Bootstrap, self).run_distribute()
10387

10488
bootstrap = SDL2Bootstrap()

pythonforandroid/bootstraps/sdl2python3/build/src/org/renpy/android/AssetExtract.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public boolean extractTar(String asset, String target) {
6060
break;
6161
}
6262

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

6565
if (entry.isDirectory()) {
6666

pythonforandroid/recipes/pygame/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def prebuild_armeabi(self):
3434
join(self.get_build_dir('armeabi'), 'Setup'))
3535
self.apply_patch(join('patches', 'fix-surface-access.patch'))
3636
self.apply_patch(join('patches', 'fix-array-surface.patch'))
37+
self.apply_patch(join('patches', 'fix-sdl-spam-log.patch'))
3738
shprint(sh.touch, join(self.get_build_container_dir('armeabi'), '.patched'))
3839

3940
def build_armeabi(self):
@@ -59,7 +60,8 @@ def build_armeabi(self):
5960
with current_directory(self.get_build_dir('armeabi')):
6061
info('hostpython is ' + self.ctx.hostpython)
6162
hostpython = sh.Command(self.ctx.hostpython)
62-
shprint(hostpython, 'setup.py', 'install', '-O2', _env=env)
63+
shprint(hostpython, 'setup.py', 'install', '-O2', _env=env,
64+
_tail=10, _critical=True)
6365

6466
info('strip is ' + env['STRIP'])
6567
build_lib = glob.glob('./build/lib*')

0 commit comments

Comments
 (0)