| @@ -1,34 +1,34 @@ | | | @@ -1,34 +1,34 @@ |
1 | $NetBSD: patch-mesonbuild_environment.py,v 1.3 2020/07/28 22:43:01 tnn Exp $ | | 1 | $NetBSD: patch-mesonbuild_environment.py,v 1.4 2020/07/28 23:28:23 tnn Exp $ |
2 | | | 2 | |
3 | Specify c++ language when making CXX parse standard input. | | 3 | Specify c++ language when making CXX parse standard input. |
4 | Fixes problem where graphics/MesaLib fails to build due to: | | 4 | Fixes problem where graphics/MesaLib fails to build due to: |
5 | | | 5 | |
6 | > clang++ -std=c++14 -dM -E - | | 6 | > clang++ -std=c++14 -dM -E - |
7 | > error: invalid argument '-std=c++14' not allowed with 'C' | | 7 | > error: invalid argument '-std=c++14' not allowed with 'C' |
8 | | | 8 | |
9 | --- mesonbuild/environment.py.orig 2020-07-05 20:13:14.000000000 +0000 | | 9 | --- mesonbuild/environment.py.orig 2020-07-05 20:13:14.000000000 +0000 |
10 | +++ mesonbuild/environment.py | | 10 | +++ mesonbuild/environment.py |
11 | @@ -708,7 +708,10 @@ class Environment: | | 11 | @@ -708,7 +708,10 @@ class Environment: |
12 | """ | | 12 | """ |
13 | # Arguments to output compiler pre-processor defines to stdout | | 13 | # Arguments to output compiler pre-processor defines to stdout |
14 | # gcc, g++, and gfortran all support these arguments | | 14 | # gcc, g++, and gfortran all support these arguments |
15 | - args = compiler + ['-E', '-dM', '-'] | | 15 | - args = compiler + ['-E', '-dM', '-'] |
16 | + args = compiler + ['-E', '-dM' ] | | 16 | + args = compiler + ['-E', '-dM' ] |
17 | + if "++" in compiler[0]: | | 17 | + if compiler[0].endswith('++'): |
18 | + args += [ '-x', 'c++' ] | | 18 | + args += [ '-x', 'c++' ] |
19 | + args += [ '-' ] | | 19 | + args += [ '-' ] |
20 | p, output, error = Popen_safe(args, write='', stdin=subprocess.PIPE) | | 20 | p, output, error = Popen_safe(args, write='', stdin=subprocess.PIPE) |
21 | if p.returncode != 0: | | 21 | if p.returncode != 0: |
22 | raise EnvironmentException('Unable to detect GNU compiler type:\n' + output + error) | | 22 | raise EnvironmentException('Unable to detect GNU compiler type:\n' + output + error) |
23 | @@ -750,7 +753,10 @@ class Environment: | | 23 | @@ -750,7 +753,10 @@ class Environment: |
24 | """ | | 24 | """ |
25 | Get the list of Clang pre-processor defines | | 25 | Get the list of Clang pre-processor defines |
26 | """ | | 26 | """ |
27 | - args = compiler + ['-E', '-dM', '-'] | | 27 | - args = compiler + ['-E', '-dM', '-'] |
28 | + args = compiler + ['-E', '-dM' ] | | 28 | + args = compiler + ['-E', '-dM' ] |
29 | + if "++" in compiler[0]: | | 29 | + if compiler[0].endswith('++'): |
30 | + args += [ '-x', 'c++' ] | | 30 | + args += [ '-x', 'c++' ] |
31 | + args += [ '-' ] | | 31 | + args += [ '-' ] |
32 | p, output, error = Popen_safe(args, write='', stdin=subprocess.PIPE) | | 32 | p, output, error = Popen_safe(args, write='', stdin=subprocess.PIPE) |
33 | if p.returncode != 0: | | 33 | if p.returncode != 0: |
34 | raise EnvironmentException('Unable to get clang pre-processor defines:\n' + output + error) | | 34 | raise EnvironmentException('Unable to get clang pre-processor defines:\n' + output + error) |