A command is writing to files that you didn't specify in the Tupfile...

90 views
Skip to first unread message

Laurence McGlashan

unread,
Sep 25, 2014, 6:21:39 AM9/25/14
to tup-...@googlegroups.com
Hi,

If I have a standard Tupfile which calls clang on a bunch of .cpp files:

: foreach *.cpp |> clang++ -g -O0 -Wall -std=c++11 -c %f -o %o |> %B.o
: *.o |> clang++ %f -o %o |> main

Now I want to call 'bear' on it, which creates a file based on the output of clang called "compile_commands.json". To use it you just prepend your clang call with 'bear --':

: foreach *.cpp |> bear -- clang++ -g -O0 -Wall -std=c++11 -c %f -o %o |> %B.o
: *.o |> clang++ %f -o %o |> main

However I now get the error:

* 1) bear -- clang++ -g -O0 -Wall -std=c++11 -c main.cpp -o main.o                                                                                     
 *** tup errors ***
tup error: File 'compile_commands.json' was written to, but is not in .tup/db. You probably should specify it as an output
 *** Command ID=47 ran successfully, but tup failed to save the dependencies.

How do I get tup to recognise this file as an output?

Thanks,

Laurence

Freddie Chopin

unread,
Sep 25, 2014, 9:40:29 AM9/25/14
to tup-...@googlegroups.com

On 09/25/2014 12:21 PM, Laurence McGlashan wrote:
> How do I get tup to recognise this file as an output?

If in your case this line:

: foreach *.cpp |> bear -- clang++ -g -O0 -Wall -std=c++11 -c %f -o %o
|> %B.o

produces two outputs - main.o and your_another_file.json, then you need
to rework it like this:

: foreach *.cpp |> bear -- clang++ -g -O0 -Wall -std=c++11 -c %f -o %o
|> %B.o | your_another_file.json

If this created file's name has any relationship to the input or output
file name, you could use some of %-flags.

If your command creates only ONE output file - compile_commands.json -
then you just need to state that instead of your current %B.o.

If you have multiple sources and each call to 'bear' appends to your
compile_commands.json file, then this will not work in tup - each tup's
command must create a new, unique file, so your only option in that case
would be to create unique %B.json files, and finally concatenate them in
a single one.

Regards,
FCh
Reply all
Reply to author
Forward
0 new messages