-
Notifications
You must be signed in to change notification settings - Fork 15
Added library project dependency #7
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
base: master
Are you sure you want to change the base?
Changes from all commits
94d5f8d
a6ffbb0
4309f03
2e70faf
ffe39a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good change, though ideally, it would also be a separate commit. |
||
|
|
||
| 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")) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's possible this file doesn't exist, if Eclipse isn't used. There should be an alternative way to specify library projects, via an attribute for example, where I can list paths to library projects manually. Also, is it possible that a library projects references other library projects (recursion?) |
||
| lines = f.readlines() | ||
|
|
||
| # workspace dir | ||
| fs = project_dir.split("/") | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this part doing? I don't understand... Maybe a comment should explain it. |
||
| 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, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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: | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For backwards-compatibility, allow resource_dir to be a list, or a single item. |
||
| 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 | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Superfluous character. |
||
|
|
||
| output | ||
| Target output file (--output). | ||
| """ | ||
| args = ['--dex'] | ||
|
|
||
| jar_list = [] | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know; this seems overly complicated; but also possibly wrong. From what I can tell it is supposed to remove duplicate jars (why are there duplicates in the first place?). I see two possible problems:
How does Android's Ant build process deal with this? |
||
| 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: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see such a change, if necessary, in a separate commit.