Can Meson read the contents of a file

Viewed 1219

Is it possible for Meson to read the contents of a file into an array or a string? From here a string can be split into an array, and an array can be looped over with foreach, but I haven't been able to find a way to get the data from the file to start with.

3 Answers

Update

Since Meson 0.57.0, you can use the read function of the Filesystem module:

fs = import('fs') 
...

my_list = fs.read('list.txt').strip().split('\n')

foreach item : my_list
  # Do something
endforeach

Not directly no, you can use run_command() to get it from another tool/script though.

Related