diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2021-02-14 21:28:44 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2021-02-14 21:28:44 +0200 |
commit | 5d651e76b5b6dba5dd03ffec609719b02d703bb7 (patch) | |
tree | a2796da9b60e919af3fd08c4a206d29e61e6de5c /docs/markdown/snippets/fs_read.md | |
parent | c0b448d3ca98cea2c6a55609772baa7954702fd8 (diff) | |
download | meson-5d651e76b5b6dba5dd03ffec609719b02d703bb7.zip meson-5d651e76b5b6dba5dd03ffec609719b02d703bb7.tar.gz meson-5d651e76b5b6dba5dd03ffec609719b02d703bb7.tar.bz2 |
Set up release 0.57.0.57.0
Diffstat (limited to 'docs/markdown/snippets/fs_read.md')
-rw-r--r-- | docs/markdown/snippets/fs_read.md | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/docs/markdown/snippets/fs_read.md b/docs/markdown/snippets/fs_read.md deleted file mode 100644 index 05c215a..0000000 --- a/docs/markdown/snippets/fs_read.md +++ /dev/null @@ -1,40 +0,0 @@ -## Support for reading files at configuration time with the `fs` module - -Reading text files during configuration is now supported. This can be done at -any time after `project` has been called - -```meson -project(myproject', 'c') -license_text = run_command( - find_program('python3'), '-c', 'print(open("COPYING").read())' -).stdout().strip() -about_header = configuration_data() -about_header.add('COPYRIGHT', license_text) -about_header.add('ABOUT_STRING', meson.project_name()) -... -``` - -There are several problems with the above approach: -1. It's ugly and confusing -2. If `COPYING` changes after configuration, Meson won't correctly rebuild when - configuration data is based on the data in COPYING -3. It has extra overhead - -`fs.read` replaces the above idiom thus: -```meson -project(myproject', 'c') -fs = import('fs') -license_text = fs.read('COPYING').strip() -about_header = configuration_data() -about_header.add('COPYRIGHT', license_text) -about_header.add('ABOUT_STRING', meson.project_name()) -... -``` - -They are not equivalent, though. Files read with `fs.read` create a -configuration dependency on the file, and so if the `COPYING` file is modified, -Meson will automatically reconfigure, guaranteeing the build is consistent. It -can be used for any properly encoded text files. It supports specification of -non utf-8 encodings too, so if you're stuck with text files in a different -encoding, it can be passed as an argument. See the [`meson` -object](Reference-manual.md#meson-object) documentation for details. |