Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file |
| 3 | # for details. All rights reserved. Use of this source code is governed by a |
| 4 | # BSD-style license that can be found in the LICENSE file. |
| 5 | |
Ian Zerny | 3f54e22 | 2019-02-12 10:51:17 +0100 | [diff] [blame] | 6 | import defines |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 7 | import os |
| 8 | import sys |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 9 | |
Ian Zerny | 3f54e22 | 2019-02-12 10:51:17 +0100 | [diff] [blame] | 10 | JDK_DIR = os.path.join(defines.THIRD_PARTY, 'openjdk') |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 11 | |
| 12 | def GetJdkHome(): |
| 13 | root = os.path.join(JDK_DIR, 'openjdk-9.0.4') |
Ian Zerny | 3f54e22 | 2019-02-12 10:51:17 +0100 | [diff] [blame] | 14 | if defines.IsLinux(): |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 15 | return os.path.join(root, 'linux') |
Ian Zerny | 3f54e22 | 2019-02-12 10:51:17 +0100 | [diff] [blame] | 16 | elif defines.IsOsX(): |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 17 | return os.path.join(root, 'osx') |
Ian Zerny | 3f54e22 | 2019-02-12 10:51:17 +0100 | [diff] [blame] | 18 | elif defines.IsWindows(): |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 19 | return os.path.join(root, 'windows') |
| 20 | else: |
| 21 | return os.environ['JAVA_HOME'] |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 22 | |
| 23 | def GetJavaExecutable(jdkHome=None): |
| 24 | jdkHome = jdkHome if jdkHome else GetJdkHome() |
Ian Zerny | 3f54e22 | 2019-02-12 10:51:17 +0100 | [diff] [blame] | 25 | executable = 'java.exe' if defines.IsWindows() else 'java' |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 26 | return os.path.join(jdkHome, 'bin', executable) if jdkHome else executable |
| 27 | |
| 28 | def GetJavacExecutable(jdkHome=None): |
| 29 | jdkHome = jdkHome if jdkHome else GetJdkHome() |
Ian Zerny | 3f54e22 | 2019-02-12 10:51:17 +0100 | [diff] [blame] | 30 | executable = 'javac.exe' if defines.IsWindows() else 'javac' |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 31 | return os.path.join(jdkHome, 'bin', executable) if jdkHome else executable |
| 32 | |
Ian Zerny | 5fffb0a | 2019-02-11 13:54:22 +0100 | [diff] [blame] | 33 | def Main(): |
| 34 | print GetJdkHome() |
| 35 | |
| 36 | if __name__ == '__main__': |
| 37 | sys.exit(Main()) |