aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2020-12-12 21:53:03 +0000
committerJussi Pakkanen <jpakkane@gmail.com>2020-12-12 21:53:03 +0000
commit6998c93a99361b2ddd9c2d82c1cae7c62e1a8c0b (patch)
treeba3e052435fc1798673d3d28519ec19e87eba0e6
parent8d04b3ce745821b18c78ba5ee19e4f00726d8d89 (diff)
downloadmeson-6998c93a99361b2ddd9c2d82c1cae7c62e1a8c0b.zip
meson-6998c93a99361b2ddd9c2d82c1cae7c62e1a8c0b.tar.gz
meson-6998c93a99361b2ddd9c2d82c1cae7c62e1a8c0b.tar.bz2
Add VCS ignore files to build dir on creation. Closes #6509.ignorebuilddir
-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: