aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael <michaelbrockus@gmail.com>2020-03-01 15:00:29 -0800
committerXavier Claessens <xclaesse@gmail.com>2020-03-02 13:50:58 -0500
commit2f080b1f2e9ca076d04af8c67d18004970a03658 (patch)
treeb9e147d55ad4f6c2f4820bf785eab7da3a5992d8
parent6e865fc08d0d13b3846d00e80c9f3ea090645fb8 (diff)
downloadmeson-2f080b1f2e9ca076d04af8c67d18004970a03658.zip
meson-2f080b1f2e9ca076d04af8c67d18004970a03658.tar.gz
meson-2f080b1f2e9ca076d04af8c67d18004970a03658.tar.bz2
add -C to meson init
-rw-r--r--docs/markdown/snippets/cd_arguments_with_init_command.md5
-rw-r--r--mesonbuild/minit.py7
2 files changed, 12 insertions, 0 deletions
diff --git a/docs/markdown/snippets/cd_arguments_with_init_command.md b/docs/markdown/snippets/cd_arguments_with_init_command.md
new file mode 100644
index 0000000..d6441e6
--- /dev/null
+++ b/docs/markdown/snippets/cd_arguments_with_init_command.md
@@ -0,0 +1,5 @@
+## Added `-C` argument to `meson init` command
+
+The meson init assumes that it is run inside the project
+root directory. If this isn't the case, you can now use
+`-C` to specify the actual project source directory.
diff --git a/mesonbuild/minit.py b/mesonbuild/minit.py
index 85d4a0f..2cb225c 100644
--- a/mesonbuild/minit.py
+++ b/mesonbuild/minit.py
@@ -18,6 +18,8 @@ from pathlib import Path
from enum import Enum
import subprocess
import shutil
+import sys
+import os
import re
from glob import glob
from mesonbuild import mesonlib
@@ -210,6 +212,7 @@ def add_arguments(parser):
Meson project.
'''
parser.add_argument("srcfiles", metavar="sourcefile", nargs="*", help="source files. default: all recognized files in current directory")
+ parser.add_argument('-C', default='.', dest='wd', help='directory to cd into before running')
parser.add_argument("-n", "--name", help="project name. default: name of current directory")
parser.add_argument("-e", "--executable", help="executable name. default: project name")
parser.add_argument("-d", "--deps", help="dependencies, comma-separated")
@@ -224,6 +227,10 @@ def run(options) -> int:
'''
Here we generate the new Meson sample project.
'''
+ if not Path(options.wd).exists():
+ sys.exit('Project source root directory not found. Run this command in build directory root.')
+ os.chdir(options.wd)
+
if not glob('*'):
autodetect_options(options, sample=True)
if not options.language: