aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2017-07-04 09:15:00 +1000
committerJussi Pakkanen <jpakkane@gmail.com>2018-02-22 20:26:16 +0200
commit6b550ae91f166a5c5161ab23c500760a9a155909 (patch)
tree50a3a690dde0bf60318855c76c70b0493b94a188
parentc572d222daf141656f6fe8119f1bd5bfc5fbe63e (diff)
downloadmeson-6b550ae91f166a5c5161ab23c500760a9a155909.zip
meson-6b550ae91f166a5c5161ab23c500760a9a155909.tar.gz
meson-6b550ae91f166a5c5161ab23c500760a9a155909.tar.bz2
Allow for missing install_dir in install_data()
The documentation doesn't require it and the interpreter code works around the possibility of it being None. The ninja backend code however fails with File "/home/whot/code/meson/mesonbuild/backend/ninjabackend.py", line 796, in generate_data_install dstabs = os.path.join(subdir or None, plain_f) File "/usr/lib64/python3.6/posixpath.py", line 78, in join a = os.fspath(a) TypeError: expected str, bytes or os.PathLike object, not NoneType If install_dir is missing, default to datadir/projectname
-rw-r--r--docs/markdown/Reference-manual.md2
-rw-r--r--docs/markdown/snippets/installdir.md5
-rw-r--r--mesonbuild/backend/ninjabackend.py2
-rw-r--r--test cases/common/12 data/installed_files.txt1
-rw-r--r--test cases/common/12 data/meson.build2
-rw-r--r--test cases/common/12 data/somefile.txt0
6 files changed, 12 insertions, 0 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md
index af01dff..4dc87c9 100644
--- a/docs/markdown/Reference-manual.md
+++ b/docs/markdown/Reference-manual.md
@@ -712,6 +712,8 @@ arguments. The following keyword arguments are supported:
directory. If this is a relative path, it is assumed to be relative
to the prefix.
+ If omitted, the directory defaults to `{datadir}/{projectname}` *(added 0.45.0)*.
+
- `install_mode` specify the file mode in symbolic format and
optionally the owner/uid and group/gid for the installed files. For
example:
diff --git a/docs/markdown/snippets/installdir.md b/docs/markdown/snippets/installdir.md
new file mode 100644
index 0000000..c709ffe
--- /dev/null
+++ b/docs/markdown/snippets/installdir.md
@@ -0,0 +1,5 @@
+## `install_data()` defaults to `{datadir}/{projectname}`
+
+If `install_data()` is not given an `install_dir` keyword argument, the
+target directory defaults to `{datadir}/{projectname}` (e.g.
+`/usr/share/myproj`).
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index b9f614e..59eaf6b 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -839,6 +839,8 @@ int dummy;
for de in data:
assert(isinstance(de, build.Data))
subdir = de.install_dir
+ if not subdir:
+ subdir = os.path.join(self.environment.get_datadir(), self.interpreter.build.project_name)
for f in de.sources:
assert(isinstance(f, mesonlib.File))
plain_f = os.path.basename(f.fname)
diff --git a/test cases/common/12 data/installed_files.txt b/test cases/common/12 data/installed_files.txt
index af1a735..ab1a981 100644
--- a/test cases/common/12 data/installed_files.txt
+++ b/test cases/common/12 data/installed_files.txt
@@ -2,5 +2,6 @@ usr/share/progname/datafile.dat
usr/share/progname/fileobject_datafile.dat
usr/share/progname/vanishing.dat
usr/share/progname/vanishing2.dat
+usr/share/data install test/somefile.txt
etc/etcfile.dat
usr/bin/runscript.sh
diff --git a/test cases/common/12 data/meson.build b/test cases/common/12 data/meson.build
index d3407d1..4528afe 100644
--- a/test cases/common/12 data/meson.build
+++ b/test cases/common/12 data/meson.build
@@ -10,6 +10,8 @@ install_data(files('fileobject_datafile.dat'),
install_dir : 'share/progname',
install_mode : [false, false, 0])
+install_data(files('somefile.txt'))
+
subdir('vanishing')
install_data(sources : 'vanishing/vanishing2.dat', install_dir : 'share/progname')
diff --git a/test cases/common/12 data/somefile.txt b/test cases/common/12 data/somefile.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test cases/common/12 data/somefile.txt