1 |
On pon, 2017-05-29 at 16:58 -0400, Mike Gilbert wrote: |
2 |
> --- |
3 |
> eclass/meson.eclass | 74 +++++++++++++++++++++++++++++++++++++++++------------ |
4 |
> 1 file changed, 57 insertions(+), 17 deletions(-) |
5 |
> |
6 |
> diff --git a/eclass/meson.eclass b/eclass/meson.eclass |
7 |
> index 758e4180ba7a..0fdb1d848973 100644 |
8 |
> --- a/eclass/meson.eclass |
9 |
> +++ b/eclass/meson.eclass |
10 |
> @@ -39,8 +39,7 @@ esac |
11 |
> |
12 |
> if [[ -z ${_MESON_ECLASS} ]]; then |
13 |
> |
14 |
> -# FIXME: We will need to inherit toolchain-funcs as well to support crossdev. |
15 |
> -inherit ninja-utils |
16 |
> +inherit ninja-utils toolchain-funcs |
17 |
> |
18 |
> fi |
19 |
> |
20 |
> @@ -71,17 +70,52 @@ DEPEND=">=dev-util/meson-0.39.1 |
21 |
> # Optional meson arguments as Bash array; this should be defined before |
22 |
> # calling meson_src_configure. |
23 |
> |
24 |
> -# Create a cross file for meson |
25 |
> -# fixme: This function should write a cross file as described at the |
26 |
> -# following url. |
27 |
> -# http://mesonbuild.com/Cross-compilation.html |
28 |
> -# _meson_create_cross_file() { |
29 |
> -# touch "${T}"/meson.crossfile |
30 |
> -# } |
31 |
> +# @FUNCTION: _meson_create_cross_file |
32 |
> +# @INTERNAL |
33 |
> +# @DESCRIPTION: |
34 |
> +# Creates a cross file. meson uses this to define settings for |
35 |
> +# cross-compilers. This function is called from meson_src_configure. |
36 |
> +_meson_create_cross_file() { |
37 |
> + # Reference: http://mesonbuild.com/Cross-compilation.html |
38 |
> + |
39 |
> + # system roughly corresponds to uname -s (lowercase) |
40 |
> + local system=unknown |
41 |
> + case ${CHOST} in |
42 |
> + *-aix*) system=aix ;; |
43 |
> + *-cygwin*) system=cygwin ;; |
44 |
> + *-darwin*) system=darwin ;; |
45 |
> + *-freebsd*) system=freebsd ;; |
46 |
> + *-linux*) system=linux ;; |
47 |
> + *-solaris*) system=sunos ;; |
48 |
|
49 |
Don't you want to die on unknown system? Or is it likely to work anyway? |
50 |
|
51 |
> + esac |
52 |
> + |
53 |
> + local cpu_family=$(tc-arch) |
54 |
> + case ${cpu_family} in |
55 |
> + amd64) cpu_family=x86_64 ;; |
56 |
> + arm64) cpu_family=aarch64 ;; |
57 |
|
58 |
That's purely mapping from known-wrong values, correct? Maybe it'd be |
59 |
reasonable to assert for all correct too, and fail on unknown? |
60 |
|
61 |
> + esac |
62 |
> + |
63 |
> + # This may require adjustment based on CFLAGS |
64 |
> + local cpu=${CHOST%%-*} |
65 |
> + |
66 |
> + cat > "${T}/meson.${CHOST}" <<-EOF |
67 |
> + [binaries] |
68 |
> + ar = '${AR}' |
69 |
> + c = '${CC}' |
70 |
> + cpp = '${CXX}' |
71 |
> + strip = '${STRIP}' |
72 |
> + |
73 |
> + [host_machine] |
74 |
> + system = '${system}' |
75 |
> + cpu_family = '${cpu_family}' |
76 |
> + cpu = '${cpu}' |
77 |
> + endian = '$(tc-endian)' |
78 |
> + EOF |
79 |
> +} |
80 |
> |
81 |
> # @FUNCTION: meson_src_configure |
82 |
> # @DESCRIPTION: |
83 |
> -# This is the meson_src_configure function |
84 |
> +# This is the meson_src_configure function. |
85 |
> meson_src_configure() { |
86 |
> debug-print-function ${FUNCNAME} "$@" |
87 |
> |
88 |
> @@ -94,13 +128,19 @@ meson_src_configure() { |
89 |
> --sysconfdir "${EPREFIX}/etc" |
90 |
> ) |
91 |
> |
92 |
> -# fixme: uncomment this for crossdev support |
93 |
> -# if tc-is-cross-compiler; then |
94 |
> -# _meson_create_cross_file || die "unable to write meson cross file" |
95 |
> -# mesonargs+=( |
96 |
> -# --cross-file "${T}"/meson.crossfile |
97 |
> -# ) |
98 |
> -# fi |
99 |
> + # Both meson(1) and _meson_create_cross_file need these |
100 |
> + tc-export AR CC CXX STRIP |
101 |
|
102 |
Wouldn't it be reasonable to make them local first anyway? I would try |
103 |
to avoid polluting the environment. |
104 |
|
105 |
> + |
106 |
> + if tc-is-cross-compiler; then |
107 |
> + _meson_create_cross_file || die "unable to write meson cross file" |
108 |
> + mesonargs+=( |
109 |
> + --cross-file "${T}"/meson.${CHOST} |
110 |
> + ) |
111 |
> + # In cross mode, meson uses CC/CXX as the "build" compilers |
112 |
> + local -x AR=$(tc-getBUILD_AR) |
113 |
> + local -x CC=$(tc-getBUILD_CC) |
114 |
> + local -x CXX=$(tc-getBUILD_CXX) |
115 |
> + fi |
116 |
> |
117 |
> # Append additional arguments from ebuild |
118 |
> mesonargs+=("${emesonargs[@]}") |
119 |
|
120 |
-- |
121 |
Best regards, |
122 |
Michał Górny |