aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/msetup.py
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/msetup.py')
-rw-r--r--mesonbuild/msetup.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/mesonbuild/msetup.py b/mesonbuild/msetup.py
index 95e6b79..a5bba56 100644
--- a/mesonbuild/msetup.py
+++ b/mesonbuild/msetup.py
@@ -31,6 +31,16 @@ from . import mintro
from .mconf import make_lower_case
from .mesonlib import MesonException
+git_ignore_file = '''# This file is autogenerated by Meson. If you change or delete it, it won't be recreated.
+*
+'''
+
+hg_ignore_file = '''# This file is autogenerated by Meson. If you change or delete it, it won't be recreated.
+syntax: glob
+**/*
+'''
+
+
def add_arguments(parser: argparse.ArgumentParser) -> None:
coredata.register_builtin_arguments(parser)
parser.add_argument('--native-file',
@@ -131,8 +141,17 @@ class MesonApp:
return ndir2, ndir1
raise MesonException('Neither directory contains a build file {}.'.format(environment.build_filename))
+ def add_vcs_ignore_files(self, build_dir: str) -> None:
+ if os.listdir(build_dir):
+ return
+ with open(os.path.join(build_dir, '.gitignore'), 'w') as ofile:
+ ofile.write(git_ignore_file)
+ with open(os.path.join(build_dir, '.hgignore'), 'w') as ofile:
+ ofile.write(hg_ignore_file)
+
def validate_dirs(self, dir1: str, dir2: str, reconfigure: bool, wipe: bool) -> T.Tuple[str, str]:
(src_dir, build_dir) = self.validate_core_dirs(dir1, dir2)
+ self.add_vcs_ignore_files(build_dir)
priv_dir = os.path.join(build_dir, 'meson-private/coredata.dat')
if os.path.exists(priv_dir):
if not reconfigure and not wipe: