Re: [Qbs] Rule.Return dynamic list for outputArtifacts

2020-07-21 Thread Christian Kandeler
On Tue, 21 Jul 2020 18:32:10 +0300
Карелин Павел  wrote:

> How can I execute Command from outputArtifacts?

You can't, you need to use a JavaScript command and qbs.Process.


Christian
___
Qbs mailing list
Qbs@qt-project.org
https://lists.qt-project.org/listinfo/qbs


Re: [Qbs] Rule.Return dynamic list for outputArtifacts

2020-07-21 Thread Карелин Павел



21.07.2020 16:45, Christian Kandeler пишет:

On Tue, 21 Jul 2020 15:10:38 +0300
Карелин Павел  wrote:


I recently needed to develop a rule for a sip generator (see below).
Basically, the rule works well, but yesterday it failed. At the output,
sip-generator create 6 cpp-files of the following format:
sip_corepartX.cpp (this is justified from the point of view of parallel
compilation, cpp-file sizes can be tens of megabytes). These 6 cpp-files
are reflected in the outputArtifacts parameter. However, yesterday I
came across a small sip-file, and the generated cpp-files turned out to
be not 6, but only 5. Naturally, my rule failed.

Question: how can I resolve my situation?

Do I understand you correctly that you don't really know in advance how many 
files will be generated, i.e. the -j parameter just specifies a maximum?

Yes, exactly

Then you either need to find a way to find out the value beforehand (by 
analyzing the input in some way), or, if that is not possible, you cheat and 
call the tool already in the outputArtifactsScript; the prepare script then 
just sets up a dummy command.

How can I execute Command from outputArtifacts?


Note that this loses concurrency, as rule execution happens in the main thread. 
But this might be acceptable for short-running tools.


Christian
___
Qbs mailing list
Qbs@qt-project.org
https://lists.qt-project.org/listinfo/qbs


--
Pavel
___
Qbs mailing list
Qbs@qt-project.org
https://lists.qt-project.org/listinfo/qbs


Re: [Qbs] Rule.Return dynamic list for outputArtifacts

2020-07-21 Thread Christian Kandeler
On Tue, 21 Jul 2020 15:10:38 +0300
Карелин Павел  wrote:

> I recently needed to develop a rule for a sip generator (see below). 
> Basically, the rule works well, but yesterday it failed. At the output, 
> sip-generator create 6 cpp-files of the following format: 
> sip_corepartX.cpp (this is justified from the point of view of parallel 
> compilation, cpp-file sizes can be tens of megabytes). These 6 cpp-files 
> are reflected in the outputArtifacts parameter. However, yesterday I 
> came across a small sip-file, and the generated cpp-files turned out to 
> be not 6, but only 5. Naturally, my rule failed.
> 
> Question: how can I resolve my situation?

Do I understand you correctly that you don't really know in advance how many 
files will be generated, i.e. the -j parameter just specifies a maximum?
Then you either need to find a way to find out the value beforehand (by 
analyzing the input in some way), or, if that is not possible, you cheat and 
call the tool already in the outputArtifactsScript; the prepare script then 
just sets up a dummy command. 
Note that this loses concurrency, as rule execution happens in the main thread. 
But this might be acceptable for short-running tools.


Christian
___
Qbs mailing list
Qbs@qt-project.org
https://lists.qt-project.org/listinfo/qbs


Re: [Qbs] Rule.Return dynamic list for outputArtifacts

2020-07-21 Thread Richard Weickelt
> However, yesterday I came across a small
> sip-file, and the generated cpp-files turned out to be not 6, but only 5.
> Naturally, my rule failed.
> 
> Question: how can I resolve my situation?
> Of course, I can tell the sip-generator to create fewer cpp-files (parameter
> -j), but I would like to understand - are there other ways?
> For example, to ignore section
> {
>    filePath: generatedFilesDir + "/sip" + moduleSipName + "part5.cpp",
>    fileTags: ["cpp"],
>    cpp: {
>  cxxFlags: sipCxxFlags
>    }
> }
> if the file ("sip" + moduleSipName + "part5.cpp") does not exist

The number of output files depends on the input file content and cannot be
known in advance? Then maybe this thread gives you some ideas:
https://www.mail-archive.com/qbs@qt-project.org/msg01022.html

The situation hasn't changed since then.
___
Qbs mailing list
Qbs@qt-project.org
https://lists.qt-project.org/listinfo/qbs


[Qbs] Rule.Return dynamic list for outputArtifacts

2020-07-21 Thread Карелин Павел

Hello.

I recently needed to develop a rule for a sip generator (see below). 
Basically, the rule works well, but yesterday it failed. At the output, 
sip-generator create 6 cpp-files of the following format: 
sip_corepartX.cpp (this is justified from the point of view of parallel 
compilation, cpp-file sizes can be tens of megabytes). These 6 cpp-files 
are reflected in the outputArtifacts parameter. However, yesterday I 
came across a small sip-file, and the generated cpp-files turned out to 
be not 6, but only 5. Naturally, my rule failed.


Question: how can I resolve my situation?
Of course, I can tell the sip-generator to create fewer cpp-files 
(parameter -j), but I would like to understand - are there other ways?

For example, to ignore section
{
filePath: generatedFilesDir + "/sip" + moduleSipName + "part5.cpp",
   fileTags: ["cpp"],
   cpp: {
 cxxFlags: sipCxxFlags
   }
}
if the file ("sip" + moduleSipName + "part5.cpp") does not exist

--
BR, Pavel Karelin

    Rule {
    multiplex: true
    inputs: ["sip"]
    outputFileTags: ["cpp", "hpp", "pyi"]
    outputArtifacts: {
    var baseSipFile = product.sip.baseSipFile;
    var moduleSipName = product.sip.moduleSipName
    var generatedFilesDir = product.sip.generatedFilesDir

    var baseSipName = FileInfo.baseName(baseSipFile);

    //console.info("sip_corepart: " + generatedFilesDir + 
"/sip" + moduleSipName + "part0.cpp")

    //console.info("sip 1 :")

    var sipCxxFlags = [
    "-Wno-deprecated-declarations",
    "-Wno-deprecated",
    "-Wno-unused-variable",
    "-Wno-switch",
    //"-Wno-unused-function",
    //"-Wno-unused-but-set-variable",
    //"-Wno-unused-parameter",
    ]

    return [{ // sip_corepart0.cpp
    filePath: generatedFilesDir + "/sip" + moduleSipName + 
"part0.cpp",

    fileTags: ["cpp"],
    cpp: {
    cxxFlags: sipCxxFlags
    }
    },{
    filePath: generatedFilesDir + "/sip" + moduleSipName + 
"part1.cpp",

    fileTags: ["cpp"],
    cpp: {
    cxxFlags: sipCxxFlags
    }
    },{
    filePath: generatedFilesDir + "/sip" + moduleSipName + 
"part2.cpp",

    fileTags: ["cpp"],
    cpp: {
    cxxFlags: sipCxxFlags
    }
    },{
    filePath: generatedFilesDir + "/sip" + moduleSipName + 
"part3.cpp",

    fileTags: ["cpp"],
    cpp: {
    cxxFlags: sipCxxFlags
    }
    },{
    filePath: generatedFilesDir + "/sip" + moduleSipName + 
"part4.cpp",

    fileTags: ["cpp"],
    cpp: {
    cxxFlags: sipCxxFlags
    }
    },{
    filePath: generatedFilesDir + "/sip" + moduleSipName + 
"part5.cpp",

    fileTags: ["cpp"],
    cpp: {
    cxxFlags: sipCxxFlags
    }
    },{ // sipAPI_core.h
    filePath: generatedFilesDir + "/sipAPI" + moduleSipName 
+ ".h",

    fileTags: ["hpp"],
    cpp: {
    cxxFlags: sipCxxFlags
    }
    },{ // core.pyi
    filePath: project.buildDirectory + "/python/" + 
baseSipName + ".pyi",

    fileTags: ["pyi"],
    }];
    }

    prepare: {
    var baseSipFile = product.sip.baseSipFile;
    var moduleSipName = product.sip.moduleSipName;
    var generatedFilesDir = product.sip.generatedFilesDir;

    var baseSipName = FileInfo.baseName(baseSipFile);

    // usr/bin/sip -w -e -x ANDROID -x ARM -x MOBILITY_LOCATION 
-n sip -t WS_X11 -t Qt_5_12_4 -g -o

    // -a /home/hkarel/CProjects/QGIS/build2/python/qgis.core.api
    // -n sip
    // -y 
/home/hkarel/CProjects/QGIS/build2/output/python/qgis/core.pyi

    // -j 6
    // -c /home/hkarel/CProjects/QGIS/build2/python/core
    // -I /home/hkarel/CProjects/QGIS/build2/python/core
    // -I /usr/share/sip/PyQt5
    // /home/hkarel/CProjects/QGIS/build2/python/core/core.sip

    var args = ["-w", "-e", "-g", "-o", "-j", "6", "-n", "sip"];
    args = args.concat(["-x", "ANDROID", "-x", "ARM", "-x", 
"MOBILITY_LOCATION"]);

    args = args.concat(["-t", "WS_X11", "-t", "Qt_5_12_4"])

    args.push("-c");
    args.push(generatedFilesDir);

    args.push("-I");
    args.push(generatedFilesDir);

    args.push("-I");
    args.push(project.buildDirectory + "/python");

    args.push("-I");
    args.push("/usr/share/sip/PyQt5");

    args.push("-y");