1

In my project, I have several plugins depending on a single module, containing a Group item similar to:

Group {
    name: "group"
    qbs.install: true
    qbs.installDir: "../"
    files: <filename>
}

But compilation fails with "error: Cannot install files 'filename' and 'filename' to the same location 'location'". Basically, qbs cannot copy same file to same location twice (seems illogical to me)

How can this bug be resolved or is there any elegant workaround?

Jake Petroules
  • 23,472
  • 35
  • 144
  • 225
Andrei R.
  • 2,374
  • 1
  • 13
  • 27

2 Answers2

1

This is a job for the qbs.installSourceBase property. Basically, you set this to the base directory containing the files in your Group, and Qbs will install the listed files into qbs.installDir hierarchically based on their paths relative to the aforementioned base directory.

For example, given the following Group:

// defined in /source/myproject/myproject.qbs
Group {
    qbs.install: true
    qbs.installDir: "share/stuff"
    qbs.installSourceBase: "." // relative to /source/myproject
    files: [
        "fileA.txt",
        "fileB.txt",
        "subdir/fileB.txt",
    ]
}

and the following command line invocation:

$ qbs [...] --install-root /sample/some-root

the following filesystem hierarchy will result:

/sample/some-root/share/stuff/fileA.txt
/sample/some-root/share/stuff/fileB.txt
/sample/some-root/share/stuff/subdir/fileB.txt

See the Qbs Installation Properties documentation for more info.

Jake Petroules
  • 23,472
  • 35
  • 144
  • 225
  • it doesn't resolve issue with inability to install same file to same location from two subprojects... – Andrei R. Aug 17 '16 at 03:36
  • That's a logical paradox - you cannot install two different files to the same path. What are you actually trying to accomplish? – Jake Petroules Aug 17 '16 at 07:50
  • I am trying to copy one file to one location, but from two subprojects. – Andrei R. Aug 17 '16 at 07:55
  • So you have several products which depend on a Module that contains a Group? That doesn't sound right; generally you should not have a Group in a Module. Perhaps you could use a product instead? Additional context about your project structure would be helpful. – Jake Petroules Aug 17 '16 at 08:13
0

There is a workaround, which may require some restructuring of a project:

instead of:

Module {
    name: "somemodule"

    // module properties set to dependant products

    Group {
        // files to install
        qbs.install: true
    }
}

we can use:

Product {
    name: "somemodule"

    Group {
        // files to install
        qbs.install: true
    }

    Export { 
        // module properties set to dependant products
    }
}

This way, files are only installed once when steps for mymodule are run, thus eliminating the conflict. Module properties, exported via Export Item, work just as ones exported via Module.

Limitations:

  1. Product has to be added to references of the Project Item
  2. Modules cannot depend on Product Items, which may require to restructure all dependant modules into Project/Export pairs too
Andrei R.
  • 2,374
  • 1
  • 13
  • 27