<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <font face="Arial">Christian, thanks for the explanations<br>
      <br>
      --<br>
      BR, Pavel Karelin<br>
      <br>
    </font><br>
    <div class="moz-cite-prefix">14.08.2018 14:53, Christian Kandeler
      пишет:<br>
    </div>
    <blockquote type="cite"
      cite="mid:20180814135346.13eac2f6@ckandeler-archlinux">
      <pre wrap="">On Tue, 14 Aug 2018 14:27:35 +0300
Карелин Павел <a class="moz-txt-link-rfc2396E" href="mailto:hkarel@yandex.ru"><hkarel@yandex.ru></a> wrote:

</pre>
      <blockquote type="cite">
        <pre wrap="">Today, with a fresh head, I decided to shorten the script a little (see 
below). At me all has turned out - the project was builded. But last 
night at me this version of the scenario hasn't earned, the problem was 
that the rule for "sonnet-parse-trigrams-run" was executed earlier than 
the utility sonnet_parsetrigrams was created (maybe I made a mistake 
somewhere else ...)
</pre>
      </blockquote>
      <pre wrap="">
That's not possible with the code you have pasted here. If the tool's tag is an input to a rule, then that rule will always wait for the rule which produces the tool.

</pre>
      <blockquote type="cite">
        <pre wrap="">I had a question: the rules for the "type" property are executed in the 
same order as they are declared or they can be executed in parallel.
</pre>
      </blockquote>
      <pre wrap="">
Everything is potentially run in parallel unless an ordering is introduced by a rule. You have such an ordering, because you tell qbs that "sonnet-parse-trigrams" is an input to your rule. Therefore, the application will be built before your rule runs.

</pre>
      <blockquote type="cite">
        <pre wrap="">
     Product {
         id: sonnetParseTrigrams
         //type: "application"
         type: ["application", "sonnet-parse-trigrams-run"]
         consoleApplication: true
         destinationDirectory: "./bin"

         name: "SonnetParseTrigrams"
         targetName: "sonnet_parsetrigrams"

         Depends { name: "cpp" }
         Depends { name: "SonnetCore" }
         Depends { name: "Qt"; submodules: ["core"] }

         cpp.defines: sonnet.cppDefines

         cpp.cxxLanguageVersion: "c++14"
         cpp.cxxFlags: sonnet.cxxFlags

         files: [
             "data/parsetrigrams.cpp"
         ]

         Group {
             fileTagsFilter: "application"
             fileTags: "sonnet-parse-trigrams"
         }

         Rule {
             inputs: ["sonnet-parse-trigrams"]

             // no inputs -> just a generator
             //multiplex: true

             Artifact {
                 fileTags: ["sonnet-parse-trigrams-run"]
                 filePath: 
FileInfo.joinPaths(product.destinationDirectory, "trigrams.map")
             }
             prepare: {
                 var runUtl = input.filePath;
                 var sourceDir = 
FileInfo.joinPaths(product.sourceDirectory, "data/trigrams");
                 var outputFile = 
FileInfo.joinPaths(product.destinationDirectory, "trigrams.map");

                 console.info("=== runUtl ===");
                 console.info(runUtl);
                 console.info(sourceDir);
                 console.info(outputFile);

                 var cmd = new Command(runUtl, [sourceDir,
outputFile]); cmd.description = "sonnet parse trigrams";
                 cmd.highlight = "filegen";
                 return cmd;
             }
         }
     }


14.08.2018 12:23, Christian Kandeler пишет:
</pre>
        <blockquote type="cite">
          <pre wrap="">On Tue, 14 Aug 2018 02:03:28 +0300
Карелин Павел <a class="moz-txt-link-rfc2396E" href="mailto:hkarel@yandex.ru"><hkarel@yandex.ru></a> wrote:
 
</pre>
          <blockquote type="cite">
            <pre wrap="">I found a solution, but I would like to know how it is optimal:  
</pre>
          </blockquote>
          <pre wrap="">Yes, that looks about right.
 
</pre>
          <blockquote type="cite">
            <pre wrap="">      Product {
          id: sonnetParseTrigrams
          //type: "application"
          type: ["application", "sonnet-parse-trigrams-run"]
          consoleApplication: true
          destinationDirectory: "./bin"

          name: "SonnetParseTrigrams"
          targetName: "sonnet_parsetrigrams"

          Depends { name: "cpp" }
          Depends { name: "SonnetCore" }
          Depends { name: "Qt"; submodules: ["core"] }

          cpp.defines: sonnet.cppDefines

          cpp.cxxLanguageVersion: "c++14"
          cpp.cxxFlags: sonnet.cxxFlags

          files: [
              "data/parsetrigrams.cpp"
          ]

          Group {
              fileTagsFilter: "application"
              fileTags: "sonnet-parse-trigrams"
          }
      }

      Product {
          type: "sonnet-parse-trigrams-run"
          name: "SonnetParseTrigramsRun"
          Depends { name: "SonnetParseTrigrams" }
      }

      Rule {
          inputs: ["sonnet-parse-trigrams"]

          // no inputs -> just a generator
          //multiplex: true

          Artifact {
              fileTags: ["sonnet-parse-trigrams-run"]
              filePath:
FileInfo.joinPaths(product.destinationDirectory, "trigrams.map")
          }
          prepare: {
              var runUtl = input.filePath;
              var sourceDir =
FileInfo.joinPaths(product.sourceDirectory, "data/trigrams");
              var outputFile =
FileInfo.joinPaths(product.destinationDirectory, "trigrams.map");

              console.info("=== runUtl ===");
              console.info(runUtl);
              console.info(sourceDir);
              console.info(outputFile);

              var cmd = new Command(runUtl, [sourceDir,
outputFile]); cmd.description = 'sonnet parse trigrams ';
              cmd.highlight = "filegen";
              return cmd;

          }
      }


13.08.2018 18:47, Карелин Павел пишет:  
</pre>
            <blockquote type="cite">
              <pre wrap="">
13.08.2018 11:31, Christian Kandeler пишет:  
</pre>
              <blockquote type="cite">
                <pre wrap="">On Sun, 12 Aug 2018 22:56:31 +0300
Карелин Павел<a class="moz-txt-link-rfc2396E" href="mailto:hkarel@yandex.ru"><hkarel@yandex.ru></a>  wrote:
    
</pre>
                <blockquote type="cite">
                  <pre wrap="">I have a project in which, in addition to the main application,
auxiliary utilities are builded. In this regard, I have two
questions:

1) How do I run an auxiliary utility right after his built, so
that it could generate necessary data?  
</pre>
                </blockquote>
                <pre wrap="">It works the same way as always: You trigger creation of the
data by giving it some tag, and the tool's tag appears as some
sort of input in the respective rule (which has the data as
outputs).  
</pre>
              </blockquote>
              <pre wrap="">That's the problem, that I do not have clear how to do it.
Not so long ago I made a rule for compiling cuda-files. Here is a
shortened version:

Module {
     id: cuda
     Depends { name: "cpp" }

     FileTagger {
         patterns: "*.cu"
         fileTags: ["cuda"]
     }

     Rule {
         id: cudaCompiler
         inputs: ["cuda"]
         auxiliaryInputs: ["hpp"]

         Artifact {
             fileTags: ["obj"]
             filePath: FileInfo.joinPaths(".obj",
Utilities.getHash(input.baseDir), input.fileName + ".o")
         }

         prepare: {
             var args = [];
             args.push(...);

             var cmd = new Command("/usr/bin/nvcuda", args);
             cmd.description = 'cuda compiling ' + input.fileName;
             cmd.highlight = "compiler";
             return cmd;
         }
     }
}

Everything is clear: there are files with the extension 'cu', the
files are connected to the project. And there is a cuda compiler:
/usr/bin/nvcuda.

In the current project, instead of /usr/bin/nvcuda, the
newly-built utility should be used (call it
sonnet_parsetrigrams). I do not understand how to write it down.
Also what should I write in the FileTagger section? Files do not
have an extension, these files are not connected to the project.
All that is - the name of the directory in which these files are
located.  The call of the utility is as follows:
sonnet_parsetrigrams MyProjectDir/trigramsDir > trigrams.map 
</pre>
              <blockquote type="cite">
                <blockquote type="cite">
                  <pre wrap="">2) How to pass parameters to the auxiliary utility? The matter
is that the utility has one parameter - a directory name. It
directory contains text files without expansion, the utility
has to process these files. The output should be one file with
the extension 'map'  
</pre>
                </blockquote>
                <pre wrap="">You rule has to take care of that when creating the Command.


Christian
_______________________________________________
Qbs mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qbs@qt-project.org">Qbs@qt-project.org</a>
<a class="moz-txt-link-freetext" href="http://lists.qt-project.org/mailman/listinfo/qbs">http://lists.qt-project.org/mailman/listinfo/qbs</a>  
</pre>
              </blockquote>
              <pre wrap="">

_______________________________________________
Qbs mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qbs@qt-project.org">Qbs@qt-project.org</a>
<a class="moz-txt-link-freetext" href="http://lists.qt-project.org/mailman/listinfo/qbs">http://lists.qt-project.org/mailman/listinfo/qbs</a>  
</pre>
            </blockquote>
          </blockquote>
          <pre wrap="">_______________________________________________
Qbs mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qbs@qt-project.org">Qbs@qt-project.org</a>
<a class="moz-txt-link-freetext" href="http://lists.qt-project.org/mailman/listinfo/qbs">http://lists.qt-project.org/mailman/listinfo/qbs</a>  
</pre>
        </blockquote>
        <pre wrap="">
</pre>
      </blockquote>
      <pre wrap="">_______________________________________________
Qbs mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qbs@qt-project.org">Qbs@qt-project.org</a>
<a class="moz-txt-link-freetext" href="http://lists.qt-project.org/mailman/listinfo/qbs">http://lists.qt-project.org/mailman/listinfo/qbs</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>