[QBS] Some questions about modules creating

Alexei Shashev ashashev at gmail.com
Mon May 9 14:36:18 CEST 2016


Am I right in understanding that using QBS for getting external
libraries is a bad idea?

For example I used Makefile for getting library like this:

$(target): lazy $(objects)
	$(CXX) $(objects) -o $(target)

lazy:
	git clone https://hokum@bitbucket.org/hokum/lazy_list.git
$(parentdir)/lazy

(full MMakefile file:
https://bitbucket.org/hokum/waterpouringcpp/src/131aa00a46bc7b41e05aca3e9bebc4e1608b8834/Makefile?fileviewer=file-view-default )

Or may be any right way exists? I mean I'm writing somewhere which
libraries product needs. And if anybody wanted to build it he could
pull down source code and just run "qbs". If product needed SomeLib
v.1.0.1, it would be downloaded.


> > > But I had tried to do it and I got error "Module mymodule could not be loaded".
> > 
> > You'll need to provide a specific (minimal but complete) example for me 
> > to give a useful comment.

I read up on item inheritance in Qml and found my mistake. I had
base_module.qbs:
Module {
    condition: false
    //...
}

and module.qbs:
base_module {
    condition: true
    //...
}

When I replaced base_module on Base_module:

Base_module.qbs:
Module {
    condition: false
    //...
}

and module.qbs:
Base_module {
    condition: true
    //...
}

It started to work. I should start name of items from upper-case letter.

Thank you for your answers.

В Пн, 09/05/2016 в 09:28 +0200, Christian Kandeler пишет:
> On 05/07/2016 04:14 PM, Алексей Шашев wrote:
> > Hi, there. I need help with modules creating.
> >
> > 1) I'm trying to make the rule independent of configure, I mean "debug"
> > or "release". For example I have archives containing *.h and *.cpp
> > files. I wrote:
> >
> > Module
> > {
> >      property string outputPath: product.sourceDirectory + "/generated"
> 
> You should never generate any files in the source directory. Of course, 
> if you plan to use your module in your own personal project only, you 
> can do whatever you want, but in general this is a no-go.
> 
> >      FileTagger {
> >          patterns: "*.7z"
> >          fileTags: ["unpack7z"]
> >      }
> >
> >      Rule {
> >          id: extractor7z
> >          inputs: ["unpack7z"]
> >
> >          Artifact {
> >              filePath: product.moduleProperty("extractor7z","outputPath")  +
> >                        "/" + input.baseDir
> 
> No, artifacts cannot be directories. You need to use the outputArtifacts 
> property; see doc.qt.io/qbs/rule-item.html. In the code there, you call 
> 7z, listing all the files in the package, and create a list of artifacts 
> from that information.
> 
> >              fileTags: "unpacked"
> >          }
> >
> >          condition: {
> >              return true;
> 
> This is the default.
> 
> >          }
> >
> >          prepare: {
> >              var cmdFunc = function() {
> >                  if ( !File.exists(output.filePath) ||
> >                      File.lastModified(output.filePath) <
> > File.lastModified(input.filePath))
> 
> 
> No, no, no. The build system does this for you! The code in the next 
> block is all you need.
> 
> >                  {
> >                      var args = [];
> >                      args.push("x");
> >                      args.push("-y");
> >                      args.push("-o" + output.filePath);
> >                      args.push(input.filePath);
> >                      var cmd = new Command("7z", args);
> >
> >                      return cmd;
> >                  }
> >                  else
> >                  {
> >                      var cmd = new JavaScriptCommand();
> >                      cmd.sourceCode = function() {
> >                          print("Do nothing...");
> >                      }
> >                      return cmd;
> >                  }
> >              }
> >
> >              var cmd = cmdFunc();
> >              cmd.description = "extracting " + input.fileName;
> >              cmd.highlight = "extractor 7z";
> >
> >              return cmd;
> >          }
> >
> >      }
> > }
> >
> > It works but I'm not sure that it's good idea. Does right way to do it
> > exist?
> >
> > And if I update archive I get warning "WARNING: Cannot remove
> > '/home/hokum/progs/qbs-test/hello_world_project/test_unpack/generated/archives'."
> > What does it mean?
> 
> This is because qbs does not expect this file to be a directory; see above.
> 
> > May be archive is not good example, but in reality I want to get
> > external dependencies from another source control systems and network
> > shares. Product will have special files with path to external dependencies.
> >
> > 2) What does "id" property of Rule Item mean?
> 
> Ids are a QML concept. You can refer to the instances of an item via 
> this property. It is not technically needed for rules, but you can use 
> it as a sort of documentation.
> 
> > 3) I can't understand how module "cpp" works. Only CppModule.qbs
> > contains Module Item, other qbs files contain UnixGCC Item, CppModule
> > Item.
> 
> All of these items are Modules. You might want to read up on item 
> inheritance in Qml.
> 
> > I guess Module Item from CppModule.qbs describes general
> > properties of module "cpp" and the condition property of Item defines
> > which Item will work.
> 
> Yes.
> 
> > But I had tried to do it and I got error "Module mymodule could not be loaded".
> 
> You'll need to provide a specific (minimal but complete) example for me 
> to give a useful comment.
> 
> 
> Christian
> _______________________________________________
> QBS mailing list
> QBS at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qbs





More information about the Qbs mailing list