[Qbs] Build and run a AuxiliaryApplication before build a MainApplication
Карелин Павел
hkarel at yandex.ru
Thu Feb 11 08:58:07 CET 2021
Hi, Alberto, colleagues
At first, your recipe with
type: ["application", "trigrams-generator"]
and
Depends { productTypes: ["trigrams-generator"] }
helped me, the project was built.
But then I found out that the assembly of the project depends on the
order of declaring sections 'Depends'
This is how the project is build:
Depends { name: "cpp" }
Depends { productTypes: ["trigrams-generator"] }
Depends { name: "SharedLib" }
Depends { name: "Yaml" }
Depends { name: "Qt"; submodules: ["core", "widgets"] }
But this is no longer:
Depends { name: "cpp" }
Depends { name: "SharedLib" }
Depends { name: "Yaml" }
Depends { productTypes: ["trigrams-generator"] }
Depends { name: "Qt"; submodules: ["core", "widgets"] }
The presence of the 'explicitlyDependsOnFromDependencies' directive does
not solve the problem.
I am attaching qbs-files of the project, so that can more accurately
evaluate them.
The project itself is located here: https://github.com/hkarel/qgit.git
Branch: 3x-spellcheck
Commit: 50285c7aea2c8546cf95a531e645c18dd1e1ab8e
Remark: the utility for generating the trigram-file has been slightly
redesigned.
Now instead of one map-file, a file is generated for each language.
Accordingly, the QBS-rule has changed slightly.
--
Pavel
10.02.2021 17:54, Alberto Mardegan пишет:
> Just got some more thoughts:
>
> On 10/02/21 11:48, Карелин Павел wrote:
>> --- parsetrigrams.qbs ---
>> import qbs
>> import qbs.FileInfo
>>
>> Product {
>> name: "SonnetParseTrigrams"
>> targetName: "sonnet_parsetrigrams"
>> condition: true
>>
>> type: "application"
> You can add an additional type here, like
>
> type: ["application", "trigram-generator"]
>
> And then:
>
>> --- qgit.qbs ---
>> import qbs
>> import qbs.FileInfo
>>
>> Product {
>> name: "QGit"
>> targetName: "qgit"
>>
>> type: "application"
>> destinationDirectory: "./bin"
>>
>> Depends { name: "cpp" }
>> Depends { name: "SonnetParseTrigrams" }
>> Depends { name: "Qt"; submodules: ["core", "widgets"] }
> Here add
>
> Depends { productTypes: ["trigram-generator"] }
>
> and in your Rule add
>
> explicitlyDependsOnFromDependencies: ["trigram-generator"]
>
> I'm not 100% sure that the last one is needed, but it seems to make
> sense :-)
>
> Ciao,
> Alberto
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20210211/f19e6611/attachment-0001.html>
-------------- next part --------------
import qbs
import "qbs/imports/QbsUtl/qbsutl.js" as QbsUtl
Project {
name: "QGit (Project)"
minimumQbsVersion: "1.18.0"
qbsSearchPaths: ["qbs"]
readonly property string minimumQtVersion: "5.12.6"
readonly property bool conversionWarnEnabled: true
readonly property var projectVersion: projectProbe.projectVersion
readonly property string projectGitRevision: projectProbe.projectGitRevision
Probe {
id: projectProbe
property var projectVersion;
property string projectGitRevision;
readonly property string projectBuildDirectory: buildDirectory
readonly property string projectSourceDirectory: sourceDirectory
configure: {
projectVersion = QbsUtl.getVersions(projectSourceDirectory + "/VERSION");
projectGitRevision = QbsUtl.gitRevision(projectSourceDirectory);
//if (File.exists(projectBuildDirectory + "/package_build_info"))
// File.remove(projectBuildDirectory + "/package_build_info")
}
}
property var cppDefines: {
var def = [
"VERSION_PROJECT=\"" + projectVersion[0] + "\"",
"VERSION_PROJECT_MAJOR=" + projectVersion[1],
"VERSION_PROJECT_MINOR=" + projectVersion[2],
"VERSION_PROJECT_PATCH=" + projectVersion[3],
"GIT_REVISION=\"" + projectGitRevision + "\"",
"LOGGER_LESS_SNPRINTF",
];
if (qbs.buildVariant === "release")
def.push("NDEBUG");
if (qbs.targetOS.contains("windows")
&& qbs.toolchain && qbs.toolchain.contains("mingw"))
{
def.push("CONFIG_DIR=\"ProgramData/qgit/config\"");
}
else
def.push("CONFIG_DIR=\"~/.config/qgit\"");
return def;
}
property var cxxFlags: [
"-ggdb3",
//"-Winline",
"-Wall",
"-Wextra",
"-Wno-unused-parameter",
"-Wno-variadic-macros",
]
property string cxxLanguageVersion: "c++17"
references: [
"src/qgit.qbs",
"src/shared/shared.qbs",
"src/spellcheck/sonnet/parsetrigrams.qbs",
"src/yaml/yaml.qbs",
]
}
-------------- next part --------------
import qbs
import qbs.File
import qbs.FileInfo
Product {
name: "QGit"
targetName: "qgit"
type: "application"
destinationDirectory: "./bin"
Depends { name: "cpp" }
Depends { name: "SharedLib" }
Depends { name: "Yaml" }
Depends { productTypes: ["trigrams-generator"] }
Depends { name: "Qt"; submodules: ["core", "widgets"] }
cpp.defines: project.cppDefines
cpp.cxxFlags: {
var cxx = project.cxxFlags.concat([
"-Wno-non-virtual-dtor",
"-Wno-long-long",
"-pedantic",
]);
if (qbs.buildVariant !== "debug")
cxx.push("-s");
if (project.conversionWarnEnabled)
cxx.push("-Wconversion");
return cxx;
}
cpp.cxxLanguageVersion: project.cxxLanguageVersion
cpp.includePaths: [
"./",
]
// Suppression a Qt warnings
cpp.systemIncludePaths: Qt.core.cpp.includePaths
cpp.dynamicLibraries: [
"pthread",
"hunspell",
]
Group {
name: "resources"
files: {
var files = [
"icons.qrc"
];
if (qbs.targetOS.contains('windows')
&& qbs.toolchain && qbs.toolchain.contains('msvc'))
files.push("app_icon.rc");
if (qbs.targetOS.contains('macos') &&
qbs.toolchain && qbs.toolchain.contains('gcc'))
files.push("resources/app_icon.rc");
return files;
}
}
Group {
name: "windows"
files: [
"commitimpl.cpp",
"commitimpl.h",
"commit.ui",
"consoleimpl.cpp",
"consoleimpl.h",
"console.ui",
"customaction.ui",
"customactionimpl.cpp",
"customactionimpl.h",
"fileview.cpp",
"fileview.h",
"fileview.ui",
"help.h",
"help.ui",
"mainimpl.cpp",
"mainimpl.h",
"mainwindow.ui",
"patchview.cpp",
"patchview.h",
"patchview.ui",
"rangeselectimpl.cpp",
"rangeselectimpl.h",
"rangeselect.ui",
"revsview.cpp",
"revsview.h",
"revsview.ui",
"settingsimpl.cpp",
"settingsimpl.h",
"settings.ui",
"tabwidget.h",
]
}
Group {
name: "others"
files: [
"../exception_manager.txt",
"../README.md",
"../README_WIN.txt",
"../qgit_inno_setup.iss",
"helpgen.sh",
"todo.txt",
]
}
Group {
name: "spellcheck"
files: [
"spellcheck/guesslanguage.cpp",
"spellcheck/guesslanguage.h",
"spellcheck/highlighter.cpp",
"spellcheck/highlighter.h",
"spellcheck/languagefilter.cpp",
"spellcheck/languagefilter.h",
"spellcheck/spellcheck.cpp",
"spellcheck/spellcheck.h",
"spellcheck/textbreaks.cpp",
"spellcheck/textbreaks.h",
"spellcheck/tokenizer.cpp",
"spellcheck/tokenizer.h",
]
}
Group {
fileTags: "trigrams"
files: FileInfo.joinPaths(product.sourceDirectory, "spellcheck/sonnet/trigrams/*")
}
Group {
fileTagsFilter: ["trigrams-map"]
fileTags: ["qt.core.resource_data"]
}
Qt.core.resourceFileBaseName: "trigrams"
Qt.core.resourcePrefix: "trigrams"
Rule {
id: idtrigrams
inputs: ["trigrams"]
explicitlyDependsOnFromDependencies: ["trigrams-generator"]
Artifact {
fileTags: ["trigrams-map"]
filePath: FileInfo.joinPaths(project.buildDirectory, "trigrams", input.baseName + ".tmap")
}
prepare: {
var runUtl = FileInfo.joinPaths(project.buildDirectory, "bin/sonnet_parsetrigrams");
var outputFile = FileInfo.joinPaths(project.buildDirectory, "trigrams", input.baseName + ".tmap");
File.makePath(FileInfo.joinPaths(project.buildDirectory, "trigrams"));
// console.info("=== runUtl ===");
// console.info(input);
// console.info(inputs);
// console.info(runUtl);
// console.info(input.filePath);
// console.info(outputFile);
var cmd = new Command(runUtl, [input.filePath, outputFile]);
cmd.description = "sonnet parse trigrams";
cmd.highlight = "filegen";
return cmd;
}
}
files: [
"annotate.cpp",
"annotate.h",
"cache.cpp",
"cache.h",
"common.cpp",
"common.h",
"common_types.h",
"config.h",
"dataloader.cpp",
"dataloader.h",
"domain.cpp",
"domain.h",
"exceptionmanager.cpp",
"exceptionmanager.h",
"filecontent.cpp",
"filecontent.h",
"filelist.cpp",
"filelist.h",
"git.cpp",
"git.h",
"inputdialog.cpp",
"inputdialog.h",
"lanes.cpp",
"lanes.h",
"listview.cpp",
"listview.h",
"myprocess.cpp",
"myprocess.h",
"patchcontent.cpp",
"patchcontent.h",
"revdesc.cpp",
"revdesc.h",
"smartbrowse.cpp",
"smartbrowse.h",
"treeview.cpp",
"treeview.h",
"FileHistory.cc",
"FileHistory.h",
"qgit.cpp",
]
// property var test: {
// console.info("=== Qt.core.version ===");
// console.info(Qt.core.version);
// console.info("=== VERSION_PROJECT ===");
// console.info(project.projectVersion[0]);
// }
}
-------------- next part --------------
import qbs
import qbs.FileInfo
Product {
name: "SonnetParseTrigrams"
targetName: "sonnet_parsetrigrams"
condition: true
//type: "application"
type: ["application", "trigrams-generator"]
destinationDirectory: "./bin"
Depends { name: "cpp" }
Depends { name: "Qt"; submodules: ["core"] }
cpp.defines: project.cppDefines
cpp.cxxFlags: project.cxxFlags
cpp.cxxLanguageVersion: project.cxxLanguageVersion
// This declaration is needed to suppress Qt warnings
cpp.systemIncludePaths: Qt.core.cpp.includePaths
files: [
"parsetrigrams.cpp"
]
}
More information about the Qbs
mailing list