internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: mesonbuild/meson

Issue:
Compiler options with colons in them are not passed correctly
The Microsoft compiler has many options that include colons. These are not handled correctly when they get included in the ninja.build file. For instance, if you try to pass the ```/Zc:wchar_t``` compiler option, it shows up in the build.ninja file as ```"/Zc$:wchar_t"```


Discussion:
Colon should be escaped like that https://ninja-build.org/manual.html#_lexical_syntax
I don't think so, because that is how it ends up getting passed to the MSVC compiler, which it doesn't understand. According to that doc page, it is only needed on a build line. So I think the problem is that meson does an overaggressive escape for the option and it isn't needed.

Resolving patch:
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -38,8 +38,12 @@
     execute_wrapper = ''
     rmfile_prefix = 'rm -f {} &&'
 
-def ninja_quote(text):
-    for char in ('$', ' ', ':'):
+def ninja_quote(text, is_build_line=False):
+    if is_build_line:
+        qcs = ('$', ' ', ':')
+    else:
+        qcs = ('$', ' ')
+    for char in qcs:
         text = text.replace(char, '$' + char)
     if '\n' in text:
         errmsg = '''Ninja does not support newlines in rules. The content was:
@@ -87,13 +91,13 @@ def add_item(self, name, elems):
 
     def write(self, outfile):
         self.check_outputs()
-        line = 'build %s: %s %s' % (' '.join([ninja_quote(i) for i in self.outfilenames]),
+        line = 'build %s: %s %s' % (' '.join([ninja_quote(i, True) for i in self.outfilenames]),
                                     self.rule,
-                                    ' '.join([ninja_quote(i) for i in self.infilenames]))
+                                    ' '.join([ninja_quote(i, True) for i in self.infilenames]))
         if len(self.deps) > 0:
-            line += ' | ' + ' '.join([ninja_quote(x) for x in self.deps])
+            line += ' | ' + ' '.join([ninja_quote(x, True) for x in self.deps])
         if len(self.orderdeps) > 0:
-            line += ' || ' + ' '.join([ninja_quote(x) for x in self.orderdeps])
+            line += ' || ' + ' '.join([ninja_quote(x, True) for x in self.orderdeps])
         line += '\n'
         # This is the only way I could find to make this work on all
         # platforms including Windows command shell. Slash is a dir separator


Test patch:
Repository: mesonbuild/meson

Issue:
Installation messages are inconsistent if DESTDIR is present
For install subdirectories it does not include DESTDIR in log message, but for files it does.
This was tested on released 0.44 version and master.
I believe correct behavior would be to show actual destination path, including DESTDIR.

```
$ env DESTDIR=/tmp/root ninja -C bd install -j1 
...
[4/5] Installing files.
Installing subdir /home/XXX/dev/bacs-project/bunsan/test/include/bunsan to /usr/local/include
Installing subdir /home/XXX/dev/bacs-project/bunsan/common/include/bunsan to /usr/local/include
Installing subdir /home/XXX/dev/bacs-project/bunsan/crypto/include/bunsan to /usr/local/include
Installing bunsan/test/libbunsan_test.so.0.1.0 to /tmp/root/usr/local/lib/libbunsan_test.so.0.1.0
Installing bunsan/common/libbunsan_common.so.0.1.0 to /tmp/root/usr/local/lib/libbunsan_common.so.0.1.0
Installing bunsan/crypto/libbunsan_crypto.so.0.1.0 to /tmp/root/usr/local/lib/libbunsan_crypto.so.0.1.0
```

Sidenote:
I can fix this since I am already working on #2869, pending #2994.


Discussion:

Resolving patch:
diff --git a/mesonbuild/scripts/meson_install.py b/mesonbuild/scripts/meson_install.py
--- a/mesonbuild/scripts/meson_install.py
+++ b/mesonbuild/scripts/meson_install.py
@@ -218,11 +218,11 @@ def do_install(datafilename):
 
 def install_subdirs(d):
     for (src_dir, dst_dir, mode, exclude) in d.install_subdirs:
-        print('Installing subdir %s to %s' % (src_dir, dst_dir))
-        dst_dir = get_destdir_path(d, dst_dir)
-        d.dirmaker.makedirs(dst_dir, exist_ok=True)
-        do_copydir(d, src_dir, dst_dir, exclude)
-        set_mode(dst_dir, mode)
+        full_dst_dir = get_destdir_path(d, dst_dir)
+        print('Installing subdir %s to %s' % (src_dir, full_dst_dir))
+        d.dirmaker.makedirs(full_dst_dir, exist_ok=True)
+        do_copydir(d, src_dir, full_dst_dir, exclude)
+        set_mode(full_dst_dir, mode)
 
 def install_data(d):
     for i in d.data:


Test patch:
Repository: mesonbuild/meson

Issue:
When using PCHs in a target with C and C++ both headers are passed to targets if the *_pch arguments are not lists
basically this works
```meson
mytarget = executable(
  ['source.c', 'source.cpp'],
  c_pch : ['pch/c.c', 'pch/c.h'],
  cpp_pch : ['pch/cpp.cpp', 'pch/cpp.h'],
)
```
but this doesn't
```meson
mytarget = executable(
  ['source.c', 'source.cpp'],
  c_pch : 'pch/c.h',
  cpp_pch : 'pch/cpp.h',
)
```

I'm actively working on fixing this right now, but I'm filing a bug as documentation for the future.


Discussion:

Resolving patch:
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -407,16 +407,10 @@ def get_pch_include_args(self, compiler, target):
         args = []
         pchpath = self.get_target_private_dir(target)
         includeargs = compiler.get_include_args(pchpath, False)
-        for lang in ['c', 'cpp']:
-            p = target.get_pch(lang)
-            if not p:
-                continue
-            if compiler.can_compile(p[-1]):
-                header = p[0]
-                args += compiler.get_pch_use_args(pchpath, header)
-        if len(args) > 0:
-            args = includeargs + args
-        return args
+        p = target.get_pch(compiler.get_language())
+        if p:
+            args += compiler.get_pch_use_args(pchpath, p[0])
+        return includeargs + args
 
     @staticmethod
     def escape_extra_args(compiler, args):


Test patch:
diff --git a/test cases/common/15 mixed pch/meson.build b/test cases/common/15 mixed pch/meson.build
--- a/test cases/common/15 mixed pch/meson.build	
+++ b/test cases/common/15 mixed pch/meson.build	
@@ -1,6 +1,19 @@
 project('mixed C and C++ pch test', 'cpp', 'c')
 
 
-exe = executable('prog', 'main.cc', 'func.c',
-c_pch : ['pch/func.h', 'pch/func_pch.c'],
-cpp_pch : ['pch/main_pch.cc', 'pch/main.h'])
+exe = executable(
+  'prog',
+  files('main.cc', 'func.c'),
+  c_pch : ['pch/func.h', 'pch/func_pch.c'],
+  cpp_pch : ['pch/main_pch.cc', 'pch/main.h'],
+)
+
+cc = meson.get_compiler('c')
+if cc.get_id() != 'msvc'
+  exe2 = executable(
+    'prog2',
+    files('main.cc', 'func.c'),
+    c_pch : 'pch/func.h',
+    cpp_pch : 'pch/main.h',
+  )
+endif
Repository: mesonbuild/meson

Issue:
0.45.0 changes behavior of install_dir
Given this code:
```meson
    configure_file(
      input: 'foo.in',
      output: 'foo.out',
      configuration: conf,
      install_dir: get_option('some-option') ? 'a-directory' : '',
    )
```
In 0.44.1 `install_dir` being set to `''` meant do not install. In 0.45.0 this results in the destination being `$datadir/$project-name` for some reason.



Discussion:

Resolving patch:
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2973,9 +2973,11 @@ def func_configure_file(self, node, args, kwargs):
             conffile = os.path.normpath(inputfile.relative_name())
             if conffile not in self.build_def_files:
                 self.build_def_files.append(conffile)
-        # Install file if requested
+        # Install file if requested, we check for the empty string
+        # for backwards compatibility. That was the behaviour before
+        # 0.45.0 so preserve it.
         idir = kwargs.get('install_dir', None)
-        if isinstance(idir, str):
+        if isinstance(idir, str) and idir:
             cfile = mesonlib.File.from_built_file(ofile_path, ofile_fname)
             self.build.data.append(build.Data([cfile], idir))
         return mesonlib.File.from_built_file(self.subdir, output)


Test patch:
diff --git a/test cases/common/16 configure file/meson.build b/test cases/common/16 configure file/meson.build
--- a/test cases/common/16 configure file/meson.build	
+++ b/test cases/common/16 configure file/meson.build	
@@ -131,3 +131,9 @@ configure_file(
   configuration : conf6
 )
 test('test6', executable('prog6', 'prog6.c'))
+
+# test empty install dir string
+cfile = configure_file(input : 'config.h.in',
+  output : 'do_not_get_installed.h',
+  install_dir : '',
+  configuration : conf)
Repository: mesonbuild/meson

Issue:
Meson 0.43 module build.py fix to known_kwargs for jar targets
When the jar() function is used to create a Java target, build.py issues a warning message:
'WARNING: Unknown keyword argument(s) in target <your_target>: target_type.' This occurs because class Jar in build.py doesn't known about the target_type argument passed to it. 

In build.py, top level, just after setting known_exe_kwargs, add these two lines:

known_jar_kwargs = known_basic_kwargs.copy()
known_jar_kwargs.update({'target_type': 'jar',
                         })

In the definition of class Jar in build.py, override the check_unknown_kwargs() method inherited from class BuildTarget with:

    def check_unknown_kwargs(self, kwargs):
        self.check_unknown_kwargs_int(kwargs, known_jar_kwargs)

That should eliminate the warning message .


Discussion:
Can you open a PR with those changes?
Hello,

Thank you for your response. I'm afraid I'm a rank amateur when it comes to
all modern source code control systems, and to Git and Github is
particular.  I plan to learn more, but for now I test and report. If an
experienced person could cast these proposed changes (issues 2569-2571 and
2580) as modifications, I'll try to follow along and learn something.

Thanks,
Ron

On Mon, Nov 6, 2017 at 2:19 AM, Elliott Sales de Andrade <
notifications@github.com> wrote:

> Can you open a PR with those changes?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/mesonbuild/meson/issues/2580#issuecomment-342076287>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AfYYrUDtFqRmqSHtJFuuCoyqPUzHKyWsks5szsEtgaJpZM4QR07X>
> .
>



-- 
James Ronald Lovell <ron163264@gmail.com>
Huntsville, AL, USA


Resolving patch:
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -85,6 +85,8 @@
 known_exe_kwargs.update({'implib': True,
                          'export_dynamic': True
                          })
+known_jar_kwargs = known_basic_kwargs.copy()
+known_jar_kwargs.update({'target_type': 'jar'})
 
 class InvalidArguments(MesonException):
     pass
@@ -1824,6 +1826,8 @@ def validate_cross_install(self, environment):
         # All jar targets are installable.
         pass
 
+    def check_unknown_kwargs(self, kwargs):
+        self.check_unknown_kwargs_int(kwargs, known_jar_kwargs)
 
 class CustomTargetIndex:
 


Test patch:
Repository: mesonbuild/meson

Issue:
Disable CI for documentation only changes
Probably fail-fast approach can work. @jpakkane noted that in the past an attempt was made to implement this but coverage was broken because of this, so let's be careful this time.


Discussion:

Resolving patch:
diff --git a/skip_ci.py b/skip_ci.py
new file mode 100755
--- /dev/null
+++ b/skip_ci.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python3
+# Copyright 2018 The Meson development team
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+#     http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from __future__ import print_function
+
+import argparse
+import os
+import subprocess
+import sys
+import traceback
+
+
+def check_pr(is_pr_env):
+    if is_pr_env not in os.environ:
+        print('This is not pull request: {} is not set'.format(is_pr_env))
+        sys.exit()
+    elif os.environ[is_pr_env] == 'false':
+        print('This is not pull request: {} is false'.format(is_pr_env))
+        sys.exit()
+
+
+def get_base_branch(base_env):
+    if base_env not in os.environ:
+        print('Unable to determine base branch: {} is not set'.format(base_env))
+        sys.exit()
+    return os.environ[base_env]
+
+
+def get_git_files(base):
+    diff = subprocess.check_output(['git', 'diff', '--name-only', base + '...HEAD'])
+    return diff.strip().split(b'\n')
+
+
+def is_documentation(filename):
+    return filename.startswith(b'docs/')
+
+
+def main():
+    try:
+        parser = argparse.ArgumentParser(description='CI Skipper')
+        parser.add_argument('--base-branch-env', required=True,
+                            help='Branch push is targeted to')
+        parser.add_argument('--is-pull-env', required=True,
+                            help='Variable set if it is a PR')
+        args = parser.parse_args()
+        check_pr(args.is_pull_env)
+        base = get_base_branch(args.base_branch_env)
+        if all(is_documentation(f) for f in get_git_files(base)):
+            print("Don't run CI for documentation-only changes, add '[skip ci]' to commit title.")
+            print('See http://mesonbuild.com/Contributing.html#skipping-integration-tests')
+            sys.exit(1)
+    except Exception:
+        # If this script fails we want build to proceed.
+        # Failure likely means some corner case we did not consider or bug.
+        # Either case this should not prevent CI from running if it is needed,
+        # and we tolerate it if it is run where it is not required.
+        traceback.print_exc()
+        print('There is a BUG in skip_ci.py, exiting.')
+        sys.exit()
+
+if __name__ == '__main__':
+    main()


Test patch:
Repository: mesonbuild/meson

Issue:
meson test --suite SUITE does not work?
Hi,
I cannot find the way to use the option `--suite` of `meson test`

I have defined some tests in this way
```
test('test_name', executable, suite: '1D')
```
everything works fine if I run
```
meson test
```
or 
```
ninja test
```
but if I run
```
meson test --suite '1D'
```
it tells me
```
No suitable tests defined.
```
is the option `--suite` still working? how can I select just a subset of tests to be executed?



Discussion:

Resolving patch:
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
--- a/mesonbuild/mtest.py
+++ b/mesonbuild/mtest.py
@@ -476,6 +476,25 @@ def test_in_suites(test, suites):
             (prj_match, st_match) = TestHarness.split_suite_string(suite)
             for prjst in test.suite:
                 (prj, st) = TestHarness.split_suite_string(prjst)
+
+                # the SUITE can be passed as
+                #     suite_name
+                # or
+                #     project_name:suite_name
+                # so we need to select only the test belonging to project_name
+
+                # this if hanlde the first case (i.e., SUITE == suite_name)
+
+                # in this way we can run tests belonging to different
+                # (sub)projects which share the same suite_name
+                if not st_match and st == prj_match:
+                    return True
+
+                # these two conditions are needed to handle the second option
+                # i.e., SUITE == project_name:suite_name
+
+                # in this way we select the only the tests of
+                # project_name with suite_name
                 if prj_match and prj != prj_match:
                     continue
                 if st_match and st != st_match:


Test patch:
Repository: mesonbuild/meson

Issue:
meson introspect fails when options.builddir is None
In run(args)  (mesonbuild/mintro.py, line 202), options.builddir is checked to see if it is None, but cdata.load(options.builddir) is called anyway, resulting in:

```python
Traceback (most recent call last):
  File "/usr/bin/meson", line 26, in <module>
    sys.exit(main())
  File "/usr/bin/meson", line 23, in main
    return mesonmain.run(sys.argv[1:], launcher)
  File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 293, in run
    return mintro.run(remaining_args)
  File "/usr/lib/python3.6/site-packages/mesonbuild/mintro.py", line 212, in run
    coredata = cdata.load(options.builddir)
  File "/usr/lib/python3.6/site-packages/mesonbuild/coredata.py", line 344, in load
    filename = os.path.join(build_dir, 'meson-private', 'coredata.dat')
```

I worked around it for now by inserting an else clause:

```python
def run(args):
    datadir = 'meson-private'
    options = parser.parse_args(args)
    if options.builddir is not None:
        datadir = os.path.join(options.builddir, datadir)
    else:
        options.builddir='./'
```

I'm using meson 0.45.0, Fedora 28 prerelease, with meson being called from gnome-builder 3.28.0.



Discussion:
Just wanted to say I ran into this problem as well, and m-j-b's solution fixed the issue.
can confirm as well, running up-to-date openSUSE Tumbleweed with meson 0.45.0 & gnome-builder 3.28.0.

Resolving patch:
diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py
--- a/mesonbuild/mintro.py
+++ b/mesonbuild/mintro.py
@@ -46,7 +46,7 @@ def buildparser():
                         help='List external dependencies.')
     parser.add_argument('--projectinfo', action='store_true', dest='projectinfo', default=False,
                         help='Information about projects.')
-    parser.add_argument('builddir', nargs='?', help='The build directory')
+    parser.add_argument('builddir', nargs='?', default='.', help='The build directory')
     return parser
 
 def determine_installed_path(target, installdata):


Test patch:
Repository: mesonbuild/meson

Issue:
Linking when using the cross-compile llvm-mingw toolchain fails
Using the (very recent and probably bleeding-edge) [llvm-mingw](https://github.com/mstorsjo/llvm-mingw) toolchain to cross-compile with meson, linking will fail as meson tries to use `-soname` which is (currently?) not supported by `lld` when I cross compile for Windows.


Discussion:
Note that additionally threads seem to not be detected properly and meson tries to use `-lpthread` even though that does not seem to work.

Resolving patch:
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -944,9 +944,11 @@ def get_gcc_soname_args(gcc_type, prefix, shlib_name, suffix, path, soversion, i
         sostr = ''
     else:
         sostr = '.' + soversion
-    if gcc_type in (GCC_STANDARD, GCC_MINGW, GCC_CYGWIN):
-        # Might not be correct for mingw but seems to work.
+    if gcc_type == GCC_STANDARD:
         return ['-Wl,-soname,%s%s.%s%s' % (prefix, shlib_name, suffix, sostr)]
+    elif gcc_type in (GCC_MINGW, GCC_CYGWIN):
+        # For PE/COFF the soname argument has no effect with GNU LD
+        return []
     elif gcc_type == GCC_OSX:
         if is_shared_module:
             return []


Test patch:
Repository: mesonbuild/meson

Issue:
ld.gold: fatal error: May not nest groups
When cross compiling for Android, cc.find_library('iconv') gives me this error:

```
Command line:  ccache aarch64-linux-android-gcc -L/home/xclaesse/programmation/cerbero/build/android-ndk-16/platforms/android-21/arch-arm64/usr/lib -L/home/xclaesse/programmation/cerbero/build/dist/android_arm64/lib /tmp/tmpmpem9ks6/testfile.c -pipe -D_FILE_OFFSET_BITS=64 -o /tmp/tmpmpem9ks6/output.exe -Wall -g -Os -isysroot /home/xclaesse/programmation/cerbero/build/android-ndk-16/sysroot -isystem /home/xclaesse/programmation/cerbero/build/dist/android_arm64/include -isystem /home/xclaesse/programmation/cerbero/build/android-ndk-16/sysroot/usr/include -isystem /home/xclaesse/programmation/cerbero/build/android-ndk-16/sysroot/usr/include/aarch64-linux-android -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -fPIC -DANDROID -DPIC -D__ANDROID_API__=21 -Wa,--noexecstack -DNVALGRIND=1 -specs=/home/xclaesse/programmation/cerbero/build/sources/android_arm64/glib-2.56.0/_builddir/meson-gcc-specs-file.txt --sysroot /home/xclaesse/programmation/cerbero/build/android-ndk-16/platforms/android-21/arch-arm64 -fPIC -no-canonical-prefixes -Wl,-no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,-dynamic-linker,/system/bin/linker -fuse-ld=gold -O0 -Wl,--start-group -Wl,--start-group -liconv -Wl,--end-group -Wl,--end-group 

Code:
 int main(int argc, char **argv) { return 0; }
Compiler stdout:
 
Compiler stderr:
 /home/xclaesse/programmation/cerbero/build/android-ndk-16/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld.gold: fatal error: May not nest groups
collect2: error: ld returned 1 exit status


meson.build:1532:6: ERROR:  C library 'iconv' not found
```


Discussion:

Resolving patch:
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -329,7 +329,7 @@ def compiles(self, code, env, extra_args=None, dependencies=None, mode='compile'
 
     def _build_wrapper(self, code, env, extra_args, dependencies=None, mode='compile', want_output=False):
         args = self._get_compiler_check_args(env, extra_args, dependencies, mode)
-        return self.compile(code, args.to_native(), mode, want_output=want_output)
+        return self.compile(code, args, mode, want_output=want_output)
 
     def links(self, code, env, extra_args=None, dependencies=None):
         return self.compiles(code, env, extra_args, dependencies, mode='link')


Test patch:
Repository: mesonbuild/meson

Issue:
MSI Installer: Support upgrade
I just attempted to upgrade from meson `0.42.1` to `0.43` and was presented with this screen using the MSI installer

![2017-10-11 14_37_47-windows installer](https://user-images.githubusercontent.com/3422847/31468523-efdaf1d2-ae92-11e7-8c93-04b1978479cf.png)

At the very least, that error message should be a bit more clear.

Besides that - a huge :+1: for having a windows installer!


Discussion:
If someone knows how to do this, please file an MR. I don't have the knowledge to do that. Also, that error message comes either from WiX or Windows itself. We can't change it as far as I know.
IIRC this error occurs because the Product GUID has stayed the same throughout each msi. So, while the upgrade guid is used to show they are the same, the product guid should change from release to release. 

I believe if you change [this](https://github.com/mesonbuild/meson/blob/master/msi/createmsi.py#L41) to `self.guid = "*"`, this issue shouldn't occur in the future (Wix will generate a new Product GUID every time you run a build). 

Resolving patch:
diff --git a/msi/createmsi.py b/msi/createmsi.py
--- a/msi/createmsi.py
+++ b/msi/createmsi.py
@@ -38,7 +38,7 @@ def __init__(self):
         self.product_name = 'Meson Build System'
         self.manufacturer = 'The Meson Development Team'
         self.version = coredata.version.replace('dev', '')
-        self.guid = 'DF5B3ECA-4A31-43E3-8CE4-97FC8A97212E'
+        self.guid = '*'
         self.update_guid = '141527EE-E28A-4D14-97A4-92E6075D28B2'
         self.main_xml = 'meson.wxs'
         self.main_o = 'meson.wixobj'


Test patch: