Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Could Qt resource compiler (RCC) generate dependencies?
Forum Updated to NodeBB v4.3 + New Features

Could Qt resource compiler (RCC) generate dependencies?

Scheduled Pinned Locked Moved Qt Creator and other tools
14 Posts 7 Posters 6.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Adam Badura
    wrote on last edited by
    #1

    It seems there is no way to call Qt resource compiler (RCC) so that it only generates a list of resource files the .qrc file depends on. While such a feature is useful for creating efficient build scripts.

    I know that .qrc file format is simple and you could just extract the resource file with an XPath expression. But still it would be simpler and more elegant for the tool itself to offer such functionality. Especially that it seems that .qrc file format is not “official” - you can have a look and see what it is but there is no guarantee it will not change later. (And also this is a double edged sword: if generating the list is simple then adding such switch to RCC should be easy as well!)

    What do you think about it?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Can you elaborate on your use of such information ? And on the build scripts part ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Adam Badura
        wrote on last edited by
        #3

        If I know to which resource files a .qrc file refers to (lets call them “additional dependencies”) then I can make a better build script so that RCC is called for a .qrc file if either the .qrc file changed (obvious!) or any of its additional dependencies changed.

        I think it would be done mostly useful if RCC accepted an additional file path argument that if present would point to a file to which additional dependencies (paths to resource files) should be output. That way when first compiling .qrc file we would do “full run” and get resulting .cpp file and those additional dependencies. When building later we will read the additional dependencies file (the clue is that it stores less information for internal use only so it could be much simpler) and then see if the .qrc or any of those additional dependencies files are newer than resulting .cpp file and if so build again. Otherwise skip.

        The issue to decide are for example: (1) should RCC allow either dependencies generation or normal work or maybe both at once? (I would go for both at once if such are the arguments), (2) what should be format of the generated additional dependencies? (I would go for simple text file containing a single file path in every line).

        I’m working on better support for Qt in MSBuild (projects generated by Qt Plugin have some issues). And no I have to read those dependencies by my own using XPaths expressions. But that doubles the work (as compared to RCC doing that in single run) and makes me depend on .qrc file format which is nowhere specified or official (as it seems to me).

        (Yeah, the same request could probably be made on UIC and MOC. But lets start with simpler things.)

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          I must say I don't see your point in having additional dependencies for the resources since adding a new dependency is essentially updating the qrc file.

          Why not help improve the plugin rather than reinvent the wheel ? The goal of this plugin is to allow a comfortable MSVC Qt experience, if you have found issues with the MSVC plugin you should report them or discuss them on the mailing list so everybody would benefit

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Adam Badura
            wrote on last edited by
            #5

            I don't understand your reply... Maybe referring to some other example could make me more clear.

            For a given source (.cpp) file to make an efficient build script you have to know which header files (.h[pp]) does it include (directly or indirectly). If you don't know that then modifying even a single header file requires you to rebuild everything (rather than just those source files that were actually affected). In large projects the difference in building time is huge.

            With the .qrc file it is just the same. The scale of the issue is not as big since .qrc files are just a few at most and their resources change rarely. (And also extracting those dependencies is much easier for .qrc.) But still it is the same issue.

            Qt Plugin could be easily made much better by using more MSBuild and thus make resulting projects smaller, more maintainable and easier to use and adjust. But I'm not sure if this could be done easily from a plugin "point of view".

            And anyway I think that Qt Plugin authorities do know what they do and why they do it. MSBuild (in Visual 2010) is not that new anymore...

            Finally after all I do write in a public forum so where else should I write?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              I think I'm starting to better understand your ideas.

              What I was saying is that If you have new ideas/solutions to better integrate Qt in MSVC, you should bring them to the development mailing list. You could then discuss them with the guys behind the plugin. That might benefit all Visual Studio Qt users.

              This forum is more user oriented so you might not get the feedback you are searching

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andrep
                wrote on last edited by
                #7

                You can use rcc itself to 'extract' the list of files in the .qrc by running rcc -list foo.qrc. However, this should not be needed, as qmake takes care of those dependencies when generating the Makefiles. So it should "just work". So what kind of build system exactly are you trying to set up, what did you try, and how did that fail?

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  jnorby
                  wrote on last edited by
                  #8

                  Right now Qmake doesn't generate these dependencies and this is very inconvenient if you are using QML in QRC files. I am working with xCode and have yet to to figure out a decent way besides rebuilding the Xcode project from scratch to get QML file changes to be picked up. Very inefficent.

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andrep
                    wrote on last edited by
                    #9

                    Is 'rcc -list some.qrc' what you are looking for?

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      toralf
                      wrote on last edited by
                      #10

                      I've been trying to do exactly the same thing. I didn't know about rcc -list, so in the past I've used a "sed" hack extracting the files directly from the .qrc. Now I've rewritten this as:

                      %.d: %.qrc
                      $(RCC) -list $< | sed -n 's%([^[:space:]].)%qrc_$.cpp: $(dir $<)\1%p' > $@

                      That's a GNU make rule to create a file <resources>.d containing all dependencies - which accompanies

                      qrc_%.cpp: %.qrc
                      $(RCC) $< -o $@

                      for the actual resources compilation. (No I'm not using qmake, for reasons I won't go into here.)

                      It would be better still if rcc itself could add the dependency stuff, though, i.e. prepend "qrc_resources.cpp: " or whatever to each file listed.

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        toralf
                        wrote on last edited by
                        #11

                        Note that the "$(dir $<) " shouldn't be there. The point was to prepend the .qrc path to file names, in case it's located on another directory - as paths within the file will be relative to that directory. However, 'rcc -list' will in fact itself add input file directory component as necessary.

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          Adam Badura
                          wrote on last edited by
                          #12

                          The --list option does exactly what I asked for.

                          Yet I think it was added after I asked the question (or possibly in sources directly as I could have used a distributed version at that time).

                          I need this option to generate dependencies for MSBuild. I'm not using qmake.

                          P 1 Reply Last reply
                          0
                          • J Offline
                            J Offline
                            JDługosz
                            wrote on last edited by
                            #13

                            I get a bad feeling when I see replies that keep asserting “you don't need that because qmake…” or “just use the VS plug-in”.

                            VS plug-in’s don't work on the Express edition and are not useful for bare MSBuild uses. Some of us need to integrate Qt stuff with existing complex builds, not redo a complex build system with Qt as the boss.

                            Seeing as I can't make notes to doc pages, could someone please update the page http://qt-project.org/doc/qt-5/rcc.html to show all the options?

                            1 Reply Last reply
                            0
                            • A Adam Badura

                              The --list option does exactly what I asked for.

                              Yet I think it was added after I asked the question (or possibly in sources directly as I could have used a distributed version at that time).

                              I need this option to generate dependencies for MSBuild. I'm not using qmake.

                              P Offline
                              P Offline
                              patrickkidd
                              wrote on last edited by
                              #14

                              @Adam-Badura Though this thread is very old, I actually ran across it when trying to define a custom qmake rcc compiler for pyrcc5 which compiles resources to python byte code in PyQt5. The problem is that I wanted to use the target.depend_command to list out the resource files needed for the resource compiler. This is crucial for editing qml files and having the change picked up in a call to make. rcc -list works perfectly for this.

                              For the record, here is my custom compiler:

                              pyrcc5.input = RESOURCES
                              pyrcc5.output = qrc_${QMAKE_FILE_BASE}.py
                              pyrcc5.dependency_type = TYPE_RCC
                              pyrcc5.depend_command = rcc -list ${QMAKE_FILE_NAME}
                              pyrcc5.CONFIG = no_link target_predeps dep_lines add_inputs_as_makefile_deps
                              pyrcc5.commands = pyrcc5 ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT}
                              QMAKE_EXTRA_COMPILERS += pyrcc5
                              

                              (And here is my custom pyuic5 compiler:)

                              pyuic5.input = FORMS
                              pyuic5.output = ${QMAKE_FILE_BASE}_form.py
                              pyuic5.dependency_type = TYPE_UI
                              pyuic5.CONFIG = no_link target_predeps dep_lines
                              pyuic5.commands = pyuic5 ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT}
                              pyuic5.variable_out = GENERATED_FILES
                              pyuic5.name = PyUIC5 ${QMAKE_FILE_IN}
                              QMAKE_EXTRA_COMPILERS += pyuic5
                              

                              https://alaskafamilysystems.com/

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved