[Qbs] Running a helper application right after it is build
Карелин Павел
hkarel at yandex.ru
Tue Aug 14 14:34:20 CEST 2018
Christian, thanks for the explanations
--
BR, Pavel Karelin
14.08.2018 14:53, Christian Kandeler пишет:
> On Tue, 14 Aug 2018 14:27:35 +0300
> Карелин Павел <hkarel at yandex.ru> wrote:
>
>> 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 ...)
> 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.
>
>> 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.
> 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.
>
>> 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 пишет:
>>> On Tue, 14 Aug 2018 02:03:28 +0300
>>> Карелин Павел <hkarel at yandex.ru> wrote:
>>>
>>>> I found a solution, but I would like to know how it is optimal:
>>> Yes, that looks about right.
>>>
>>>> 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, Карелин Павел пишет:
>>>>> 13.08.2018 11:31, Christian Kandeler пишет:
>>>>>> On Sun, 12 Aug 2018 22:56:31 +0300
>>>>>> Карелин Павел<hkarel at yandex.ru> wrote:
>>>>>>
>>>>>>> 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?
>>>>>> 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).
>>>>> 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
>>>>>>> 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'
>>>>>> You rule has to take care of that when creating the Command.
>>>>>>
>>>>>>
>>>>>> Christian
>>>>>> _______________________________________________
>>>>>> Qbs mailing list
>>>>>> Qbs at qt-project.org
>>>>>> http://lists.qt-project.org/mailman/listinfo/qbs
>>>>>
>>>>> _______________________________________________
>>>>> Qbs mailing list
>>>>> Qbs at qt-project.org
>>>>> http://lists.qt-project.org/mailman/listinfo/qbs
>>> _______________________________________________
>>> Qbs mailing list
>>> Qbs at qt-project.org
>>> http://lists.qt-project.org/mailman/listinfo/qbs
> _______________________________________________
> Qbs mailing list
> Qbs at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20180814/5df8a9f1/attachment.html>
More information about the Qbs
mailing list