forked from bincrafters/conan-java_installer
-
Notifications
You must be signed in to change notification settings - Fork 4
/
conanfile.py
72 lines (59 loc) · 2.58 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import platform
from conan import ConanFile
from conan.tools.files import get
from conan.tools.files import copy
from conan.errors import ConanInvalidConfiguration
class ZuluOpenJDKConan(ConanFile):
name = 'java_installer'
url = 'https://github.com/datalogics/conan-java_installer'
description = 'Java installer distributed via Conan'
license = 'https://azul.com'
topics = ("java", "jdk", "openjdk")
settings = 'os', 'arch'
@property
def _jni_folder(self):
folder = {'Linux': 'linux',
'Macos': 'darwin',
'Windows': 'win32',
'AIX': 'aix',
'SunOS': 'solaris'}.get(str(self.settings.os))
return os.path.join('include', folder)
@property
def _binary_key(self):
return '{0}_{1}'.format(self.settings.os, self.settings.arch)
@property
def _source_subfolder(self):
return "source_subfolder"
def config_options(self):
data = self.conan_data["binaries"][self.version].get(self._binary_key, None)
if data is None:
raise ConanInvalidConfiguration("Unsupported Architecture. No data was found in {0} for OS "
"{1} with arch {2}".format(self.version, self.settings.os,
self.settings.arch))
if self.settings.os == 'Macos' and self.settings.arch == 'x86':
raise ConanInvalidConfiguration(
'Unsupported System (32-bit Mac OS X)')
def build(self):
self.output.info('Downloading {0}'.format(
self.conan_data["binaries"][self.version][self._binary_key].get('url')))
get(self, **self.conan_data["binaries"][self.version][self._binary_key],
destination=self._source_subfolder, strip_root=True)
def package(self):
self.copy(pattern='*', dst='.', src=self._source_subfolder)
def package_id(self):
del self.info.settings.os.version
def package_info(self):
self.cpp_info.includedirs.append(self._jni_folder)
self.cpp_info.bindirs = ['bin']
self.cpp_info.libdirs = []
java_home = self.package_folder
self.output.info(
'Creating JAVA_HOME environment variable with : {0}'.format(java_home))
self.env_info.JAVA_HOME = java_home
bin_path = os.path.join(java_home, 'bin')
self.output.info(
'Prepending PATH environment variable with : {0}'.format(bin_path))
self.env_info.PATH.append(bin_path)