diff --git a/src/android/build.py b/src/android/build.py index 1d42bdc..2afab2f 100644 --- a/src/android/build.py +++ b/src/android/build.py @@ -263,7 +263,7 @@ def _collect_jars(self, paths): return jar_files def compile_java(self, source_dirs, output_dir, extra_jars=[], - debug=False, target='1.5'): + debug=False, target='1.6'): """Compile all *.java files in ``source_dirs`` (a list of directories) and store the class files in ``output_dir``. @@ -327,6 +327,7 @@ def compile(self, manifest, project_dir, source_dirs, resource_dir, For directories that you do not specifiy a tenmporary directory will be used and deleted after the build. """ + to_delete = [] if not source_gen_dir: source_gen_dir = tempfile.mkdtemp() @@ -367,6 +368,7 @@ def pack_resources(self, manifest, resource_dir, asset_dir=None, if not output: _, output = tempfile.mkstemp(suffix='.ap_') output = path.abspath(output) + kwargs = dict( command='package', manifest=manifest, @@ -431,7 +433,7 @@ def align(self, apk, output=None): return Apk(self, outfile) -def get_platform(sdk_path, ndk_dir, target=None): +def get_platform(sdk_path, target=None, ndk_dir=None): """Return path and filename information for the given SDK target. If no target is given, the most recent target is chosen. @@ -563,13 +565,39 @@ def __init__(self, manifest, name=None, platform=None, sdk_dir=None, if target is None: target = self.manifest_parsed.find('uses-sdk')\ .attrib['{http://schemas.android.com/apk/res/android}targetSdkVersion'] - platform = get_platform(sdk_dir, ndk_dir, target) + platform = get_platform(sdk_dir, ndk_dir=ndk_dir, target=target) self.platform = platform # Optional values self.extra_source_dirs = [] self.extra_jars = [] + self.extra_resource_dirs = [] + + # project directory needed for library project dependecies + if project_dir != None: + # get project path + f = open(os.path.join(project_dir,"project.properties")) + lines = f.readlines() + + # workspace dir + fs = project_dir.split("/") + fs.pop() + + workspace_path = "/" + + for fn in fs: + workspace_path = os.path.join(workspace_path,fn) + + # search for library projects in project.properties + for line in lines: + if line.startswith("android.library"): + lname = line.split("/")[-1].rstrip() + library_project = os.path.join(workspace_path, lname) + + self.extra_source_dirs.append(os.path.join(library_project,"src")) + self.extra_jars.append(os.path.join(library_project,"libs")) + self.extra_resource_dirs.append(os.path.join(library_project,"res")) # if no name is given, inspect the manifest self.name = name or self.manifest_parsed.attrib['package'] @@ -589,7 +617,7 @@ def compile(self): manifest=self.manifest, project_dir = self.project_dir, source_dirs=[self.source_dir] + self.extra_source_dirs, - resource_dir=self.resource_dir, + resource_dir=[self.resource_dir] + self.extra_resource_dirs, source_gen_dir=self.gen_dir, class_gen_dir=path.join(self.out_dir, 'classes'), extra_jars=only_existing([self.lib_dir])+self.extra_jars @@ -617,7 +645,7 @@ def build(self, output=None, config=None, package_name=None, self.out_dir, '%s.%s.ap_' % (self.name, config)) kwargs = dict( manifest=self.manifest, - resource_dir=self.resource_dir, + resource_dir=[self.resource_dir] + self.extra_resource_dirs, configurations=config, output=resource_filename, package_name=package_name, diff --git a/src/android/tools.py b/src/android/tools.py index 4963695..7a74dc2 100644 --- a/src/android/tools.py +++ b/src/android/tools.py @@ -17,6 +17,7 @@ import sys import os import subprocess +import collections __all__ = ('ProgramFailedError', 'Aapt', 'Aidl', 'LlvmRs', 'ApkBuilder', @@ -74,6 +75,13 @@ def __call__(self, arguments, env=None, shell=False): Child implementations must not forget to pass this return value along to their caller. """ +<<<<<<< HEAD + cmdline = " ".join([self.executable] + arguments) + + process = subprocess.Popen([self.executable] + arguments, + stderr=subprocess.PIPE, + stdout=subprocess.PIPE) +======= cmdline = [self.executable] + arguments if shell and not sys.platform=="win32": # This is required for scripts that lack the +x flag @@ -89,6 +97,7 @@ def __call__(self, arguments, env=None, shell=False): env=custom_env, stderr=subprocess.PIPE, stdout=subprocess.PIPE) +>>>>>>> upstream/master process.wait() if process.returncode != 0: raise ProgramFailedError( @@ -138,7 +147,10 @@ def __call__(self, command, manifest=None, resource_dir=None, args = [command] self.extend_args(args, ['-m'], make_dirs) self.extend_args(args, ['-M', manifest]) - self.extend_args(args, ['-S', resource_dir]) + + for item in resource_dir: + self.extend_args(args, ['-S', item]) + self.extend_args(args, ['-A', asset_dir]) self.extend_args(args, ['-c', configurations]) if overwrite_version_code: @@ -152,6 +164,9 @@ def __call__(self, command, manifest=None, resource_dir=None, self.extend_args(args, ['-F', apk_output]) self.extend_args(args, ['-J', r_output]) self.extend_args(args, ['-f'], overwrite) + self.extend_args(args, ["--auto-add-overlay"]) + self.extend_args(args, ["--no-crunch"]) + return Program.__call__(self, args) @@ -181,7 +196,10 @@ def __call__(self, aidl_file, preprocessed=None, search_path=None, self.extend_args(args, [aidl_file]) return Program.__call__(self, args) +<<<<<<< HEAD +======= +>>>>>>> upstream/master class LlvmRs(Program): """Interface to the command line llvm renderscript compiler, ``llvm-rs-cc`` """ @@ -208,6 +226,7 @@ def __call__(self, project_path): """ args = [] self.extend_args(args, ["-C", project_path]) + return Program.__call__(self, args) class NdkClean(Program): @@ -270,12 +289,33 @@ def __call__(self, files, output=None): """ files A set of class files, .zip/.jar/.apk archives or - directories. + directories.q output Target output file (--output). """ args = ['--dex'] + + jar_list = [] + for item in files: + if item.endswith(".jar"): + fname = item.split('/') + fname = fname[-1] + + jar_list.append(fname) + + counter_list = collections.Counter(jar_list) + repeated_elements = [i for i in counter_list if counter_list[i] > 1] + + for jar in files: + fname = jar.split("/") + fname = fname[-1] + + for item in repeated_elements: + if item == fname: + files.remove(jar) + repeated_elements.remove(item) + self.extend_args(args, ["--output=%s" % output]) args.extend(files) return Program.__call__(self, args) @@ -313,6 +353,7 @@ def __call__(self, outputfile, dex=None, zips=[], source_dirs=[], args = [outputfile] args.extend(['-u']) # unsigned self.extend_args(args, ['-f', dex]) + for zip in zips: args.extend(['-z', zip]) for source_dir in source_dirs: