diff options
Diffstat (limited to 'classes')
-rw-r--r-- | classes/openjdk-build-helper.bbclass | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/classes/openjdk-build-helper.bbclass b/classes/openjdk-build-helper.bbclass index 785ddf0..78906b0 100644 --- a/classes/openjdk-build-helper.bbclass +++ b/classes/openjdk-build-helper.bbclass | |||
@@ -14,3 +14,38 @@ def openjdk_build_helper_get_parallel_make(d): | |||
14 | return 1 | 14 | return 1 |
15 | 15 | ||
16 | return pm.partition('-j')[2].strip().split(' ')[0] | 16 | return pm.partition('-j')[2].strip().split(' ')[0] |
17 | |||
18 | # All supported cross compilers support the compiler flags that were | ||
19 | # added to make compilation with gcc6 work. But the host compiler for | ||
20 | # native compilation is a different story: it may be too old (for example, | ||
21 | # gcc 4.9.2 on Debian Wheezy). In that case we need to check what the | ||
22 | # version is and only add the flags that are appropriate for that GCC | ||
23 | # version. | ||
24 | def openjdk_build_helper_get_cflags_by_cc_version(d, version): | ||
25 | if version.isdigit(): | ||
26 | return d.getVar('FLAGS_GCC%d' % int(version)) or '' | ||
27 | return '' | ||
28 | |||
29 | def openjdk_build_helper_get_build_cflags(d): | ||
30 | def get_build_cc_version(build_cc): | ||
31 | from subprocess import Popen, PIPE | ||
32 | cmd = d.expand('%s -dumpversion' % build_cc).split() | ||
33 | cc = Popen(cmd, stdout=PIPE, stderr=PIPE) | ||
34 | return cc.communicate()[0].decode('utf-8')[0] | ||
35 | |||
36 | build_cc = d.getVar('BUILD_CC') | ||
37 | version = get_build_cc_version(build_cc) | ||
38 | return openjdk_build_helper_get_cflags_by_cc_version(d, version) | ||
39 | |||
40 | def openjdk_build_helper_get_target_cflags(d): | ||
41 | import re | ||
42 | |||
43 | # in the cross case, trust that GCCVERSION is correct. This won't | ||
44 | # work if the native toolchain is Clang, but as of this writing that | ||
45 | # doesn't work anyway. | ||
46 | version = d.getVar('GCCVERSION')[0] | ||
47 | # skip non digit characters at the beginning, e.g. from "linaro-6.2%" | ||
48 | match = re.search("\d", version) | ||
49 | if match: | ||
50 | version = version[match.start():] | ||
51 | return openjdk_build_helper_get_cflags_by_cc_version(d, version) | ||