meson icon indicating copy to clipboard operation
meson copied to clipboard

Compiler `preprocess()` function doesn't write output anywhere

Open bgilbert opened this issue 2 years ago • 3 comments

Describe the bug The compiler preprocess() function takes an output argument, but doesn't seem to write the preprocessor output anywhere.

To Reproduce

$ cat > meson.build <<EOF
project('test', 'c')
meson.get_compiler('c').preprocess('file.in', output : '@BASENAME@')
EOF
$ echo hello > file.in
$ meson setup build
The Meson build system
Version: 1.2.1
Source dir: /home/bgilbert/tmp/t
Build dir: /home/bgilbert/tmp/t/build
Build type: native build
Project name: test
Project version: undefined
C compiler for the host machine: cc (gcc 13.2.1 "cc (GCC) 13.2.1 20230728 (Red Hat 13.2.1-1)")
C linker for the host machine: cc ld.bfd 2.39-9
Host machine cpu family: x86_64
Host machine cpu: x86_64
Build targets in project: 1

Found ninja-1.11.1 at /usr/bin/ninja
$ cd build; ninja
ninja: no work to do.
$ ls preprocessor_0.p/
$ find . -name file\*
$ 

Expected behavior file is written somewhere in the build directory.

system parameters

  • Is this a cross build or just a plain native build (for the same computer)? native
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.) Fedora 38
  • what Python version are you using e.g. 3.8.0 3.11.5
  • what meson --version 1.2.1
  • what ninja --version if it's a Ninja build 1.11.1

bgilbert avatar Sep 21 '23 06:09 bgilbert

The output of preprocess needs to be used in order for it to produce the files I believe.

jeandudey avatar Sep 21 '23 09:09 jeandudey

They are indeed not built by default, unless some other target depends on it, the idea was that preprocessed files were not useful in themself, they are usually then passed to a compiler. For that reason preprocess() also miss install and install_dir arguments. But thinking about it, there might be cases you actually want that... I guess we should add build_by_default, install and install_dir.

xclaesse avatar Sep 21 '23 12:09 xclaesse

I... actually have a usecase for all of those things. Some xorg projects use the C preprocessor for generating documentation.

dcbaker avatar Sep 21 '23 23:09 dcbaker