-
Notifications
You must be signed in to change notification settings - Fork 31
Support side by side NDK installations in SDK #76
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -11,5 +11,5 @@ src/*.dll | |
| bin | ||
| **/obj | ||
| packages/ | ||
| TestResult-*.xml | ||
| TestResult*.xml | ||
| .vs/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -140,7 +140,36 @@ public virtual bool ValidateJavaSdkLocation (string loc) | |
| } | ||
|
|
||
| /// <summary> | ||
| /// Checks that a value is the location of an Android SDK. | ||
| /// Searches all Android SDK locations for nested NDK installations. | ||
| /// </summary> | ||
| protected IEnumerable<string> FindNdkPathsInAndroidSdkPaths () | ||
| { | ||
| string ndk; | ||
| var sdks = new List<string> (); | ||
| if (!string.IsNullOrEmpty (AndroidSdkPath)) | ||
| sdks.Add (AndroidSdkPath); | ||
|
|
||
| sdks.AddRange (AllAndroidSdks); | ||
| foreach (var sdk in sdks.Distinct ()) { | ||
| // Check for the "ndk-bundle" directory inside the SDK directories | ||
| if (Directory.Exists (ndk = Path.Combine (sdk, "ndk-bundle"))) { | ||
| if (ValidateAndroidNdkLocation (ndk)) { | ||
| yield return ndk; | ||
| } | ||
| } | ||
| // Check for any versioned "ndk/$(VERSION)" directory inside the SDK directories | ||
| if (Directory.Exists (ndk = Path.Combine (sdk, "ndk"))) { | ||
| foreach (var versionedNdk in GetSortedToolDirectoryPaths (ndk)) { | ||
| if (ValidateAndroidNdkLocation (versionedNdk)) { | ||
| yield return versionedNdk; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Checks that a value is the location of an Android NDK. | ||
| /// </summary> | ||
| public bool ValidateAndroidNdkLocation (string loc) | ||
| { | ||
|
|
@@ -167,6 +196,23 @@ static string GetExecutablePath (string dir, string exe) | |
| return e; | ||
| return exe; | ||
| } | ||
|
|
||
| public Version TryParseVersion (string v) | ||
| { | ||
| Version.TryParse (v, out Version version); | ||
| return version; | ||
| } | ||
pjcollins marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public IEnumerable<string> GetSortedToolDirectoryPaths (string topToolDirectory) | ||
|
Contributor
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 wonder if the sorting here is being done at the wrong "scope". For example, consider Is this a problem? ¯_(ツ)_/¯ (It's also likely a rare scenario, but ignoring that...) For example, Similarly, if (though some bizarro happenstance) there are multiple Android SDKs present in Again, is this a problem? I don't know. I think I'd want to know. If it is a problem, things get slightly more complicated. You can't just use the directory name to infer the version, as However, that then implies that the sorting is done at the wrong level; it needs to be done within e.g. |
||
| { | ||
| var sorted = from p in Directory.EnumerateDirectories (topToolDirectory) | ||
| let version = TryParseVersion (Path.GetFileName (p)) | ||
| where version != null | ||
| orderby version descending | ||
| select p; | ||
|
|
||
| return sorted; | ||
| } | ||
| } | ||
| } | ||
|
|
||
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.
Should this provide an
IEqualityComparer<string>, e.g.If (somehow)
sdkscontains case-differing paths on Windows, you'll have duplicates if you don't useStringComparer.OrdinalIgnoreCase. This may or may not matter.