diff options
author | David Herman <davidherman@google.com> | 2014-10-20 10:36:53 -0700 |
---|---|---|
committer | David Herman <davidherman@google.com> | 2014-10-23 11:56:57 -0700 |
commit | ea29cd16b2ae3f04294165ba0b5e4d839dfc8406 (patch) | |
tree | 7cf0692184661ce8629282a2828062d4345777b3 /find_java/src/source/find_java_lib.cpp | |
parent | 171072b90ed953304b1bbfa96022ab71b82d9969 (diff) | |
download | sdk-ea29cd16b2ae3f04294165ba0b5e4d839dfc8406.zip sdk-ea29cd16b2ae3f04294165ba0b5e4d839dfc8406.tar.gz sdk-ea29cd16b2ae3f04294165ba0b5e4d839dfc8406.tar.bz2 |
New -path arg for find_java
Previously, the only way to specify a custom java.exe location for
find_java was through JAVA_HOME, but now we have one more hook.
If you pass in a custom path, and it is found, the rest of
find_java will be skipped, and that path will be used.
This has a few advantages:
1) Passing in an explicit custom path is really intuitive.
2) JAVA_HOME may be used by other applications, and asking users
to override it for us could cause compatibility issues.
3) This makes life much easier for our installer, which does not
want to blindly overwrite the user's JAVA_HOME environment
variable.
4) If we ever change where we store a java path (new registry, in
a file somewhere), we don't have to recompile find_java.exe to
account for it. All we have to do is update find_java.bat.
5) This gives us a really easy way to tell users who run into
find_java bugs a way to fix them.
Change-Id: I1d7bd95c9225f34c22d987005f32af256f81d908
Diffstat (limited to 'find_java/src/source/find_java_lib.cpp')
-rwxr-xr-x | find_java/src/source/find_java_lib.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/find_java/src/source/find_java_lib.cpp b/find_java/src/source/find_java_lib.cpp index 93bc705..134c38b 100755 --- a/find_java/src/source/find_java_lib.cpp +++ b/find_java/src/source/find_java_lib.cpp @@ -124,19 +124,28 @@ static int checkBinPath(CPath *inOutPath) { }
// Test for the existence of java.exe in a custom path
-int checkJavaInPath(const CPath &path, int minVersion) {
+int findJavaInPath(const CPath &path, CPath *outJavaPath, bool isJdk, int minVersion) {
SetLastError(0);
- int currVersion = 0;
+ int version = 0;
CPath temp(path);
- currVersion = checkBinPath(&temp);
- if (currVersion > minVersion) {
- if (gIsDebug) {
- fprintf(stderr, "Java %d found in path: %s\n", currVersion, temp.cstr());
+ if (!isJdk) {
+ version = checkPath(&temp);
+ }
+ else {
+ if (isJdkPath(temp)) {
+ version = checkBinPath(&temp);
}
}
- return currVersion;
+ if (version >= minVersion) {
+ if (gIsDebug) {
+ fprintf(stderr, "Java %d found in path: %s\n", version, temp.cstr());
+ }
+ *outJavaPath = temp;
+ return version;
+ }
+ return 0;
}
// Search java.exe in the environment
|