[Qbs] dependency tracking

Dan Pat dannix84 at gmail.com
Tue Oct 27 11:22:05 CET 2020


>As Christian said: The problem is that the cpp scanner is triggered by the
>generated cpp file, but there is no connection to the testinput.h because
>your cpp files is not including it.

Sorry for getting back to this so late. I have missed a very important
detail - the generated cpp files do include the headers from which they are
generated. To illustrate, I followed Richard's advice and prepended the cpp
file with the line " #include "testinput.h" ". The modified Module
definition (never mind the hardcoded string - it's just a test):

Module {

    id: testgen


    Rule {

        inputs: ["genxx"]

        Artifact {

            id: artifact

            filePath: FileInfo.path(input.filePath)  + "/" +
FileInfo.baseName(input.filePath) + "-gen.cpp"

            fileTags: ["cpp"]

        }

        prepare: {


            var cmd = new JavaScriptCommand();

            cmd.description =  'Running test generator';

            cmd.sourceCode = function(){

                var file = new TextFile(output.filePath, TextFile.WriteOnly);

                file.write("#include \"testinput.h\"\r\n const int c = 5;");

                file.close();


            }


            return cmd;


        }

    }

}


But the observed behavior is still the same.


чт, 17 сент. 2020 г. в 04:25, Richard Weickelt <richard at weickelt.de>:

> >> "testinput.h" file contains "#include "a.h" directive. Changing
> >> testinput.h results in a generator run followed by a C++ compiler run.
> >> Changing a.h results in no action, although in this case the generator
> >> is intended to reprocess its input.
> >
> > It's expected that the generator won't re-run, because the dependency
> > parsing happens when building a cpp file, i.e. all the headers are
> > dependencies of the object file, and the header files themselves are only
> > "passed through" by the scanning process. Though you might be able to
> > cheat by setting up a dummy cpp file that includes the top-level header
> > and making that an input to the generator rule.
>
> As Christian said: The problem is that the cpp scanner is triggered by the
> generated cpp file, but there is no connection to the testinput.h because
> your cpp files is not including it.
>
> If you could add the following lines to your generated cpp file:
>
>     #ifdef IGNORED
>     #include "testinput.h"
>     #endif
>
> then this should be enough to make the cpp scanner think that you are
> actually including testinput.h and hence, it will see and track a.h as
> well.
>
> Richard
> _______________________________________________
> Qbs mailing list
> Qbs at qt-project.org
> https://lists.qt-project.org/listinfo/qbs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20201027/5bf890cd/attachment.html>


More information about the Qbs mailing list