Commit Graph

23 Commits

Author SHA1 Message Date
46e3480f7c 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.
2021-02-04 17:34:11 +00:00
39ede12aa5 Fix misspells
Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2021-01-13 12:53:10 -05:00
f6672c7a19 use real pathlib module
We added the _pathlib module to work around defeciencies in python 3.5's
implementation, since we now rely on 3.6 lets drop this
2020-11-20 15:08:40 -08:00
1dfaccfd91 pathlib: Fix resolve() by overriding it in Python 3.5 2020-10-04 10:45:48 +02:00
6b1b995b32 typing: fully annotate fs module 2020-09-08 20:15:57 +02:00
2bbd57092f add FeatureNew 2020-02-06 12:54:38 -05:00
5bbeab8ed4 add fs.stem() 2020-02-06 12:54:38 -05:00
dcb7043403 fs: add expanduser method
this should help users specify leading `~` in various Meson options and variables
without refactoring lots of places inside Meson itself.
2020-02-06 12:54:38 -05:00
4556343d95 fs: add methods as_posix, is_absolute
fs: make exception specify method name

fs: actually raise exceptions

fs: resolve path e.g.  /opt/foo/.. => /opt/foo

fs: correct behavior of is_symlink
2020-02-06 12:54:38 -05:00
09b53c534f types: import typing as T (fixes #6333) 2020-01-08 15:28:17 +01:00
fb121f6254 fs: rename samefile => is_samepath
is_samepath better reflects the nature of this function--that files
and directories can be compared.

Also, instead of raising exceptions, simply return False when one
or both .is_samepath(path1, path1) don't exist. This is more
intuitive behavior and avoids having an extra if fs.exist() to go
with every fs.is_samepath()
2019-12-19 08:51:31 -05:00
7d162487e3 Add raise at the start of MesonException 2019-12-04 10:54:24 +02:00
a6f7a1d8c4 fs: Add parent() and name() methods 2019-11-25 14:55:19 -05:00
0cb48cdc79 fs: make replace_suffix not expand file to absolute path, just manipulate the string 2019-11-17 00:22:53 -05:00
2ae96f8595 fs: replace_suffix 2019-11-17 00:17:06 -05:00
a320274179 fs: get file size
fs: add samefile
2019-11-17 00:17:04 -05:00
67651271f6 fs: add hash compute method 2019-11-17 00:17:04 -05:00
052d918908 add fs.with_suffix 2019-11-17 00:17:02 -05:00
dc8e8f0644 fs: improve exception feedback 2019-11-17 00:17:02 -05:00
4adfd921ae fs: use expanduser 2019-11-17 00:17:01 -05:00
9fc76b0323 fs: deduplicate functions 2019-11-17 00:17:01 -05:00
3bbd065576 fs: use pathlib.Path, add type hint check 2019-11-17 00:17:00 -05:00
46788d1b5b Created the filesystem module. 2019-11-08 00:44:45 +02:00