Infer android api version #34

Merged
merged 8 commits into from Mar 10, 2014

Projects

None yet

1 participant

@townxelliot

This uses the platforms/ directory inside the Android SDK to infer the androidAPILevel if not set. For example, if a user has "android-18" and "android-19", API level is set to 19. It can still be manually set/overridden with the androidAPILevel property.

Once that's available, searches for the required pieces of the Android SDK now use globs, so that multiple candidates are returned. For example, if androidAPILevel is 19, the glob for aapt is "build-tools/19_/aapt"; if multiple files are returned, we choose the "latest" one. NB this copes with mixed environments where you might have "android-4.3" and "19.0.0" in the build-tools directory (depending on how the SDK was installed/updated): any "android-_" directory is converted into a "N.N.N" style directory. So "android-4.4" is treated as "19.0.0" for the purposes of sorting.

Because we have better version sorting, we can dispense with androidAPIVersion, and just pick up the latest tools for the API level instead (e.g. if the user has both "19.0.1" and "19.0.2" and androidAPILevel is 19, we use "19.0.2").

Fixes #26

townxelliot added some commits Mar 7, 2014
@townxelliot townxelliot Only use androidAPILevel, not androidAPIVersion
For the moment, default to using API level 19, and glob to
find the tools matching that API level (e.g. build-tools/19*/aapt);
if multiple matching files are found, use the last one in the list
(which is sorted alphabetically).
ac308a4
@townxelliot townxelliot When looking for files by API level, sort by version
When we're looking for (for example) aapt, which may occur
in two or more directories, sort the results by the
version number which is implicit in the parent directories of
the found aapt binaries.

For example, if we have 19.0.0 and 19.0.1 versions of aapt,
we want the 19.0.1 version, so we need to sort all the matching
19* versions and return the latest one.
58a4480
@townxelliot townxelliot Env should sort results returned by Finder
The results of a file search (e.g. for aapt) should be returned
as plain arrays (Android SDK agnostic) to Env; then Env should
take responsibility for choosing the "latest" matching file.

This is done by passing a filter function to findFiles(), which
optionally selects a single item from the array of files
returned (either by glob or by guessing directories). The
single returned path can then be returned as the location of the
desired "piece".

findDirectories() also now returns multiple matching directories,
and the last of them is selected as the desired "piece".

This allows all code which is Android-specific to stay in Env and
not have to go into Finder.
128a1db
@townxelliot townxelliot Search platforms/ directory to set default Android API level
If androidAPILevel is not explicitly set in config, look
at the platforms/android-* directories and choose the
last one found after alpha sorting.
ae67336
@townxelliot townxelliot [Finder] findDirectories() should reject with tried paths
On failure, findDirectories() should reject the promise with
an array of paths tried, for consistency with findFiles().
636986d
@townxelliot townxelliot Sort Android directories by basename only
On Windows, some paths were being returned with forward
slashes for path separators, and others with double back
slash, which caused the sort to be incorrect.

Just sort by the basename of the paths under platforms/
(the android-* part) to work around this.
d64c45e
@townxelliot townxelliot Safely fall back if no platforms/ directories 16ca369
@townxelliot townxelliot Ensure that file separators are correctly fixed ef046a4
@townxelliot townxelliot merged commit 7e1e222 into master Mar 10, 2014
@townxelliot townxelliot deleted the infer-android-api-version-26 branch Mar 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment