Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Copy dir for build dir
Qt 6.11 is out! See what's new in the release blog

Copy dir for build dir

Scheduled Pinned Locked Moved General and Desktop
15 Posts 3 Posters 10.5k 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.
  • S Offline
    S Offline
    Salvatello
    wrote on last edited by
    #3

    if you want to copy the folder and its contents need to copy file to file.
    You must first create the parent folder ( uitest ) .
    Then the sons of uitest scrolling you have to create the folder by folder and copy the files in order .
    Is that clear?

    1 Reply Last reply
    0
    • E Offline
      E Offline
      Exotic_Devel
      wrote on last edited by
      #4

      SGaist,
      Need for both reasons, yes, is for easier access, but also need to copy another folder where are the ui files for final use.

      Salvatello,
      I found some information on how to copy files but not how to create dirs, you could set an example?

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

        If you generated the test with Qt Creator you should have a line like
        @DEFINES += SRCDIR=\\"$$PWD/\\"@

        So you can use SRCDIR to access the files in your sources from your test

        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
        • S Offline
          S Offline
          Salvatello
          wrote on last edited by
          #6

          @void Main::copyPath(QString src, QString dst)
          {
          QDir dir(src);
          if (! dir.exists())
          return;
          foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
          QString dst_path = dst + QDir::separator() + d;
          dir.mkpath(dst_path);
          copyPath(src+ QDir::separator() + d, dst_path);
          }

          foreach (QString f, dir.entryList(QDir::Files)) {
              QFile::copy(src + QDir::separator() + f, dst + QDir::separator() + f);
          }
          

          }@
          src is directory starting
          dst is directory arrival

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

            @ Salvatello the question is not about doing it from an application, it's about doing in from a post-build step

            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
            • E Offline
              E Offline
              Exotic_Devel
              wrote on last edited by
              #8

              No it does not. And I did not create the tests with QtCreator. Below is the content of tests_pro.

              @QT += testlib sql widgets uitools

              HEADERS +=
              testdataaccess.hpp
              testconnecdialog.hpp
              testdynamicwidgets.hpp

              SOURCES +=
              testdataaccess.cpp
              main.cpp
              testconnecdialog.cpp
              testdynamicwidgets.cpp

              OTHER_FILES += uitests/*

              #lib dataaccess
              win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../dataaccess/release/ -ldataaccess
              else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../dataaccess/debug/ -ldataaccess
              else:unix: LIBS += -L$$OUT_PWD/../dataaccess/ -ldataaccess

              INCLUDEPATH += $$PWD/../dataaccess
              DEPENDPATH += $$PWD/../dataaccess

              win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../dataaccess/release/libdataaccess.a
              else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../dataaccess/debug/libdataaccess.a
              else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../dataaccess/release/dataaccess.lib
              else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../dataaccess/debug/dataaccess.lib
              else:unix: PRE_TARGETDEPS += $$OUT_PWD/../dataaccess/libdataaccess.a

              #lib GUI
              win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../gui/release/ -lgui
              else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../gui/debug/ -lgui
              else:unix: LIBS += -L$$OUT_PWD/../gui/ -lgui

              INCLUDEPATH += $$PWD/../gui
              DEPENDPATH += $$PWD/../gui

              win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../gui/release/libgui.a
              else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../gui/debug/libgui.a
              else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../gui/release/gui.lib
              else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../gui/debug/gui.lib
              else:unix: PRE_TARGETDEPS += $$OUT_PWD/../gui/libgui.a@

              In pure makefile, I do this way:

              @mkdir -p ui
              cp -i uitests/*.ui ui/@

              simple

              I do not know how to do the same thing with qmake script.

              [quote author="SGaist" date="1413316037"]If you generated the test with Qt Creator you should have a line like
              @DEFINES += SRCDIR=\\"$$PWD/\\"@

              So you can use SRCDIR to access the files in your sources from your test[/quote]

              1 Reply Last reply
              0
              • E Offline
                E Offline
                Exotic_Devel
                wrote on last edited by
                #9

                Ok, basing myself by the "solution":http://dragly.org/2013/11/05/copying-data-files-to-the-build-directory-when-working-with-qmake/, I mounted the script of copies that I needed.

                @createdir.commands = $(MKDIR) $$OUT_PWD/uitests
                copyfiles.commands = $(COPY) $$PWD/$$OTHER_FILES $$OUT_PWD/uitests
                first.depends = $(first) createdir copyfiles
                export(first.depends)
                export(createdir.commands)
                export(copyfiles.commands)
                QMAKE_EXTRA_TARGETS += first createdir copyfiles
                @

                However, the solution does not explain a few things:

                'depends' and 'commands' are required? Are they for?

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

                  IIRC, something like

                  @
                  QMAKE_POST_LINK += $$quote($(COPY_DIR) $$PWD/uitests PATH_TO_BUILDIR/ui)
                  @

                  should do the job

                  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
                  • E Offline
                    E Offline
                    Exotic_Devel
                    wrote on last edited by
                    #11

                    Perfect SGaist! More compact

                    [quote author="SGaist" date="1413498710"]IIRC, something like

                    @
                    QMAKE_POST_LINK += $$quote($(COPY_DIR) $$PWD/uitests PATH_TO_BUILDIR/ui)
                    @

                    should do the job[/quote]

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

                      And should also be cross-platform :)

                      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
                      • E Offline
                        E Offline
                        Exotic_Devel
                        wrote on last edited by
                        #13

                        My dear fellow, sorry to raise this topic, but how do I copy two different folders?
                        I tried this:

                        @QMAKE_POST_LINK += $$quote($(COPY_DIR) $$PWD/uis $$OUT_PWD/../tests/uis)
                        $$quote($(COPY_DIR) $$PWD/translations $$OUT_PWD/../tests/translations)@

                        unsuccessfully

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

                          You need to add $$escape_expand(\n\t) after each line except the last one

                          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
                          1
                          • E Offline
                            E Offline
                            Exotic_Devel
                            wrote on last edited by
                            #15

                            Thanks boy!

                            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