Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added symlink_java_src dev option #894

Merged
merged 3 commits into from
Oct 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 8 additions & 4 deletions pythonforandroid/bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from os.path import (join, dirname, isdir, splitext, basename, realpath)
from os import listdir
from os import listdir, mkdir
import sh
import glob
import json
Expand Down Expand Up @@ -89,10 +89,14 @@ def prepare_build_dir(self):
self.build_dir = self.get_build_dir()
shprint(sh.cp, '-r',
join(self.bootstrap_dir, 'build'),
# join(self.ctx.root_dir,
# 'bootstrap_templates',
# self.name),
self.build_dir)
if self.ctx.symlink_java_src:
info('Symlinking java src instead of copying')
shprint(sh.rm, '-r', join(self.build_dir, 'src'))
shprint(sh.mkdir, join(self.build_dir, 'src'))
for dirn in listdir(join(self.bootstrap_dir, 'build', 'src')):
shprint(sh.ln, '-s', join(self.bootstrap_dir, 'build', 'src', dirn),
join(self.build_dir, 'src'))
with current_directory(self.build_dir):
with open('project.properties', 'w') as fileh:
fileh.write('target=android-{}'.format(self.ctx.android_api))
Expand Down
3 changes: 2 additions & 1 deletion pythonforandroid/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class Context(object):
libs_dir = None # where Android libs are cached after build but
# before being placed in dists
aars_dir = None
javaclass_dir = None

ccache = None # whether to use ccache
cython = None # the cython interpreter name
Expand All @@ -46,6 +45,8 @@ class Context(object):

recipe_build_order = None # Will hold the list of all built recipes

symlink_java_src = False # If True, will symlink instead of copying during build

@property
def packages_path(self):
'''Where packages are downloaded before being unpacked'''
Expand Down
9 changes: 9 additions & 0 deletions pythonforandroid/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ def __init__(self):
'--ndk-version', '--ndk_version', dest='ndk_version', default='',
help=('The version of the Android NDK. This is optional, '
'we try to work it out automatically from the ndk_dir.'))
generic_parser.add_argument(
'--symlink-java-src', '--symlink_java_src',
action='store_true',
dest='symlink_java_src',
default=False,
help=('If True, symlinks the java src folder during build and dist '
'creation. This is useful for development only, it could also '
'cause weird problems.'))

default_storage_dir = user_data_dir('python-for-android')
if ' ' in default_storage_dir:
Expand Down Expand Up @@ -454,6 +462,7 @@ def add_parser(subparsers, *args, **kwargs):
self.ndk_dir = args.ndk_dir
self.android_api = args.android_api
self.ndk_version = args.ndk_version
self.ctx.symlink_java_src = args.symlink_java_src

self._archs = split_argument_list(args.arch)

Expand Down
4 changes: 4 additions & 0 deletions test_builds/tests/test_apk.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

from pythonforandroid.toolchain import main
from pythonforandroid.recipe import Recipe

from os import path
import sys
Expand Down Expand Up @@ -51,11 +52,14 @@ def set_argv(argv):
@pytest.mark.parametrize('args', argument_combinations)
def test_build_sdl2(args):

Recipe.recipes = {}

set_argv(('apk --requirements={requirements} --private '
'{app_dir} --package=net.p4a.{packagename} --name={packagename} '
'--version=0.1 --bootstrap={bootstrap} --android_api=19 '
'--ndk_dir={ndk_dir} --ndk_version={ndk_version} --debug '
'--permission VIBRATE '
'--symlink-java-src '
'--orientation portrait --dist_name=test-{packagename}').format(
**args).split(' '))

Expand Down