[Qbs] Problem getting build order right when I use a header generator
Kai Dohmen
psykai1993 at googlemail.com
Thu Jul 14 07:40:13 CEST 2022
Hello,
did you try to append "hpp" to the static libraries type property?
Maybe this would force Qbs to generate the headers before consuming the
library.
Regards, Kai
Am Mi., 13. Juli 2022 um 22:50 Uhr schrieb Jochen Becher <
jochen_becher at gmx.de>:
> Another observation:
>
> After I built the project once with one job at a time and it succeeded,
> it also succeeds after "Clean" and building with 12 parallel jobs. So,
> once the dependency between the source file and the header file is
> established, it gets not lost until you delete the .bg file.
>
> As it works within the static library but just not when an external
> source file depends on that generated header file, I assume it is an
> issue in qbs.
>
> Any comments?
>
>
> Am Dienstag, dem 12.07.2022 um 22:08 +0200 schrieb Jochen Becher:
> > One more information:
> >
> > If I set the number of parallel jobs to 1 then it works fine. The
> > order
> > of the build tasks seems to be correct. Just the compilation of
> > source
> > files outside of the library but depending on a header file created
> > from the library seems not to wait until the header files are done.
> > Of
> > course, this obviously works with linking of object files and static
> > libraries. It looks like an issue in qbs to me.
> >
> > Can someone please comment on this before I create a minimal example
> > and issue?
> >
> > Regards, Jochen
> >
> >
> > Am Samstag, dem 09.07.2022 um 22:56 +0200 schrieb Jochen Becher:
> > > Hi,
> > >
> > > I have the following problem where I could not find a solution
> > > myself:
> > >
> > > I created a new module which uses a code generator "compiler-
> > > generator"
> > > that I wrote to create header and source files from input files. I
> > > used
> > > the lexyacc module as a template. (see end of mail for module
> > > source)
> > >
> > > I use that module in a product that creates a static library, like
> > > that:
> > >
> > > StaticLibrary {
> > > name: "corelib"
> > >
> > > Export {
> > > Depends { name: "cpp" }
> > > cpp.includePaths: ["src",
> > > exportingProduct.buildDirectory]
> > > }
> > >
> > > Depends { name: "compgen" }
> > > Depends { name: "compiler-generator" }
> > >
> > > cpp.includePaths: [ "src", product.buildDirectory ]
> > >
> > > Group {
> > > name: "frontend-header-generator"
> > > fileTags: "compgen.input"
> > > compgen.outputTag: "hpp"
> > > files: [
> > > "src/frontend/tokens.h.in",
> > > ]
> > > }
> > >
> > > Group {
> > > name: "frontend-source-generator"
> > > fileTags: "compgen.input"
> > > compgen.outputTag: "c"
> > > files: [
> > > "src/frontend/lexer.c.in",
> > > ]
> > > }
> > >
> > > Group {
> > > name: "frontend"
> > > files: [
> > > "src/frontend/lexer.h",
> > > "src/frontend/parser.c",
> > > "src/frontend/parser.h",
> > > ]
> > > }
> > >
> > > Building that library works fine.
> > >
> > > But some other tools also want to use the created header file
> > > "tokens.h". These applications (e.g., "compiler") depends on
> > > "corelib".
> > >
> > > But the application source is compiled before the header file
> > > "tokens.h" is generated from "tokens.h.in" and so it is missing.
> > >
> > > What is the best way to enforce that the dependency on corelib from
> > > an
> > > application first builds the library corelib with the generated
> > > header
> > > and source files and THEN builds the dependend source files?
> > >
> > > Regards, Jochen
> > >
> > >
> > > --- the generator module "compgen.qbs" ---
> > >
> > > import qbs
> > > import qbs.FileInfo
> > >
> > > Module {
> > >
> > > Depends { name: "cpp" }
> > >
> > > property string outputTag: "c"
> > > readonly property string outputDir: product.buildDirectory
> > >
> > > Rule {
> > > inputs: [ "compgen.input" ]
> > > outputFileTags: [ product.compgen.outputTag ]
> > > explicitlyDependsOnFromDependencies: [ "compiler-generator"
> > > ]
> > >
> > > Artifact {
> > > filePath: input.completeBaseName
> > > fileTags: [ product.compgen.outputTag ]
> > > cpp.includePaths: [].concat(input.cpp.includePaths,
> > > FileInfo.path(input.filePath), input.compgen.outputDir)
> > > }
> > >
> > > prepare: {
> > > var command = explicitlyDependsOn["compiler-
> > > generator"][0].filePath
> > > var arguments = [
> > > "-o", output.filePath,
> > > input.filePath
> > > ]
> > > var cmd = new Command(command, arguments)
> > > cmd.description = "generating " + output.filePath + "
> > > from
> > > " + input.filePath
> > > cmd.highlight = "codegen"
> > > return [ cmd ]
> > > }
> > > }
> > > }
> > >
> > > _______________________________________________
> > > Qbs mailing list
> > > Qbs at qt-project.org
> > > https://lists.qt-project.org/listinfo/qbs
> >
> > _______________________________________________
> > Qbs mailing list
> > Qbs at qt-project.org
> > https://lists.qt-project.org/listinfo/qbs
>
> _______________________________________________
> 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/20220714/129cee59/attachment.htm>
More information about the Qbs
mailing list