summaryrefslogtreecommitdiff
path: root/docs/markdown/Fs-module.md
diff options
context:
space:
mode:
authorLuke Drummond <ldrumm@rtps.co>2020-11-03 20:28:04 +0000
committerJussi Pakkanen <jpakkane@gmail.com>2021-02-04 17:34:11 +0000
commit46e3480f7c675b140ca4496c658069696daa176d (patch)
tree7968ab2078864ecf71212cf291abb462d081596f /docs/markdown/Fs-module.md
parent95c079071118abc9078b0931ee86f51b1b4f8e05 (diff)
downloadmeson-46e3480f7c675b140ca4496c658069696daa176d.tar.gz
Introduce `fs.read` to read a file as a string
Following #7890, this patch introduces the ability to read the contents of a file to the fs module. This patch introduces the ability to read files at configure time, but has some restrictions: - binary files are not supported (I don't think this will prove a problem, and if people are wanting to do something with binary files, they should probably be shelling out to their own script). - Only files outside the build directory allowed. This limitation should prevent build loops. Given that reading an arbitrary file at configure time can affect the configuration in almost arbitrary ways, meson should force a reconfigure when the given file changes. This is non-configurable, but this can easily be changed with a future keyword argument.
Diffstat (limited to 'docs/markdown/Fs-module.md')
-rw-r--r--docs/markdown/Fs-module.md11
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/markdown/Fs-module.md b/docs/markdown/Fs-module.md
index d4945e909..df9f305b4 100644
--- a/docs/markdown/Fs-module.md
+++ b/docs/markdown/Fs-module.md
@@ -199,3 +199,14 @@ suffix
fs.stem('foo/bar/baz.dll') # baz
fs.stem('foo/bar/baz.dll.a') # baz.dll
```
+
+### read
+- `read(path, encoding: 'utf-8')` *(since 0.57.0)*:
+ return a [string](Syntax.md#strings) with the contents of the given `path`.
+ If the `encoding` keyword argument is not specified, the file specified by
+ `path` is assumed to be utf-8 encoded. Binary files are not supported. The
+ provided paths should be relative to the current `meson.current_source_dir()`
+ or an absolute path outside the build directory is accepted. If the file
+ specified by `path` changes, this will trigger Meson to reconfigure the
+ project. If the file specified by `path` is a `files()` object it
+ cannot refer to a built file.