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. Impossible to add custom build step in Qt Creator?
Forum Updated to NodeBB v4.3 + New Features

Impossible to add custom build step in Qt Creator?

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 6.4k Views 2 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.
  • GmemberG Offline
    GmemberG Offline
    Gmember
    wrote on last edited by
    #1

    Hello,

    I want to add a custom build step: before running qmake, I expect Qt Creator to delete the old build directory.

    I tried adding a custom build step at the first build step, with the following settings:

    command: rmdir
    arguments: /s /q "C:\Users\Valerio G\Documents\Tests\Test_Nano\build-Test_Nano-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug"
    working directory: c:\

    but I get the error:
    Could not start process "rmdir" /s /q "C:\Users\Valerio G\Documents\Tests\Test_Nano\build-Test_Nano-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug"
    Error while building/deploying project Test_Nano (kit: Desktop Qt 5.8.0 MSVC2015_64bit)
    When executing step "Custom Process Step"

    I tried all sorts of combinations: with/without quotes, moving the arguments to the command field, changing the working directory, ... i just won't work.

    When I use the Windows command prompt, I can successfully execute:
    C:> rmdir /s /q "C:\Users\Valerio G\Documents\Tests\Test_Nano\build-Test_Nano-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug"

    so I expect to parse this by putting c:\ as working directory, rmdir as command and the rest as arguments. Why am I wrong?

    E 1 Reply Last reply
    0
    • GmemberG Gmember

      Hello,

      I want to add a custom build step: before running qmake, I expect Qt Creator to delete the old build directory.

      I tried adding a custom build step at the first build step, with the following settings:

      command: rmdir
      arguments: /s /q "C:\Users\Valerio G\Documents\Tests\Test_Nano\build-Test_Nano-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug"
      working directory: c:\

      but I get the error:
      Could not start process "rmdir" /s /q "C:\Users\Valerio G\Documents\Tests\Test_Nano\build-Test_Nano-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug"
      Error while building/deploying project Test_Nano (kit: Desktop Qt 5.8.0 MSVC2015_64bit)
      When executing step "Custom Process Step"

      I tried all sorts of combinations: with/without quotes, moving the arguments to the command field, changing the working directory, ... i just won't work.

      When I use the Windows command prompt, I can successfully execute:
      C:> rmdir /s /q "C:\Users\Valerio G\Documents\Tests\Test_Nano\build-Test_Nano-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug"

      so I expect to parse this by putting c:\ as working directory, rmdir as command and the rest as arguments. Why am I wrong?

      E Offline
      E Offline
      Eeli K
      wrote on last edited by
      #2

      @Gmember Maybe rmdir can't be found outside the command prompt? Is it an internal shell command or a standalone program? If it's a shell command you may have to for example create a .bat file and execute that.

      1 Reply Last reply
      1
      • GmemberG Offline
        GmemberG Offline
        Gmember
        wrote on last edited by
        #3

        Hi, thank you for your reply. I think you are right, I created a batch with the code:

        if exist "C:\Users\Valerio G\Documents\Tests\Test_Nano\build-Test_Nano-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug" ^
        rmdir /s /q "C:\Users\Valerio G\Documents\Tests\Test_Nano\build-Test_Nano-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug"
        

        and it works almost fine: if the build folder doesn't exist, it creates it and it builds the project. However, if the folder does exist, the script deletes it but the compilation fails:

        14:08:07: Running steps for project Test_Nano...
        14:08:07: Starting: "C:\Users\Valerio G\Documents\Tests\Test_Nano\scripts\clean_Qt_5_8_0_MSVC2015_64bit-Debug.bat"
        C:\Users\Valerio G\Documents\Tests\Test_Nano\scripts>if exist "C:\Users\Valerio G\Documents\Tests\Test_Nano\build-Test_Nano-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug" rmdir /s /q "C:\Users\Valerio G\Documents\Tests\Test_Nano\build-Test_Nano-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug"
        14:08:07: The process "C:\Users\Valerio G\Documents\Tests\Test_Nano\scripts\clean_Qt_5_8_0_MSVC2015_64bit-Debug.bat" exited normally.
        14:08:07: Configuration unchanged, skipping qmake step.
        14:08:07: Cannot find Makefile. Check your build settings.
        Error while building/deploying project Test_Nano (kit: Desktop Qt 5.8.0 MSVC2015_64bit)
        When executing step "Make"
        14:08:07: Elapsed time: 00:01.

        For some reason it skips the qmake step, so it won't find the makefile. How can I skip the check that returns "Configuration unchanged" and force it to run qmake every time?

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

          Hi
          the generated make file also lives in build folder so i think that is why it fails.

          Can I ask why u cannot just use clean from the menu?

          Also , why you want to clean it each time you build ( if i may ask)?

          Update:
          Maybe you can fix it with change folder for the files and kill that instead so makefile survives
          http://stackoverflow.com/questions/2580934/how-to-specify-different-debug-release-output-directories-in-qmake-pro-file

          1 Reply Last reply
          0
          • GmemberG Offline
            GmemberG Offline
            Gmember
            wrote on last edited by
            #5

            @mrjj Of course you can ask :) The reason is that sometimes, ater adding or removing library header files from my C++ sources I get link errors. This is due to leftovers in the build folder from the previous build, since if I delete the build directory and execute the build command again, then the project is built correctly.

            Using the clean command from the Build menu doesn't help, I guess that I have to modify the cleaning steps to make that work. But then, I would have to do both clean and build each time. I think it's better to just remove the whole build directory as a preliminary build step. My project is not very big, it builds in less than 30 seconds so I can live with that.

            Of course, I welcome suggestions from people that are more experienced than me :)

            mrjjM 1 Reply Last reply
            0
            • GmemberG Gmember

              @mrjj Of course you can ask :) The reason is that sometimes, ater adding or removing library header files from my C++ sources I get link errors. This is due to leftovers in the build folder from the previous build, since if I delete the build directory and execute the build command again, then the project is built correctly.

              Using the clean command from the Build menu doesn't help, I guess that I have to modify the cleaning steps to make that work. But then, I would have to do both clean and build each time. I think it's better to just remove the whole build directory as a preliminary build step. My project is not very big, it builds in less than 30 seconds so I can live with that.

              Of course, I welcome suggestions from people that are more experienced than me :)

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @Gmember
              Hi
              super :)
              Well i like your idea but sadly i think it will kill the
              MakeFile also and then it cannot build.
              Also, the pro file is not always parsed ( again) when u press build so its not
              enough to try to clean from there.

              So you must make it create the makefile in another place so u can just nuke folder
              or simply make a bat file that kills what u want and just call that. and leave the makefile.
              The pro file becomes a make file in same folder and then you kill it :) so
              just wiping the whole folder might not work.

              1 Reply Last reply
              0
              • GmemberG Offline
                GmemberG Offline
                Gmember
                wrote on last edited by Gmember
                #7

                @mrjj
                I found a solution by following your advice! Now my bat script spares the makefile by only deleting the contents of the debug subdirectory:

                if exist "C:\Users\Valerio G\Documents\Tests\Test_Nano\build-Test_Nano-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug\debug" ^
                erase /s /q "C:\Users\Valerio G\Documents\Tests\Test_Nano\build-Test_Nano-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug\debug\*.*"
                

                I will make a similar script for the release build. It is sad to be forced to do this, but sometimes I found myself searching for a non existent bug in my code, all because of leftovers from previous builds, so I started using Clean all the times before building. Check my old question about this behaviour, that arose when I was trying to configure OpenCV:

                https://forum.qt.io/topic/68329/solved-impossible-to-include-opencv-path

                Then I discovered that in a few cases even that wasn't enough, so I started deleting the build folder every time I included a new header. This is frustrating, I want to be sure that when I get compile errors, it is because I made a mistake somewhere, not because something in the toolchain failed to detect that the build structure of the program has changed.

                Thank you very much to you and to @Eeli-K for your help :D

                mrjjM 1 Reply Last reply
                1
                • GmemberG Gmember

                  @mrjj
                  I found a solution by following your advice! Now my bat script spares the makefile by only deleting the contents of the debug subdirectory:

                  if exist "C:\Users\Valerio G\Documents\Tests\Test_Nano\build-Test_Nano-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug\debug" ^
                  erase /s /q "C:\Users\Valerio G\Documents\Tests\Test_Nano\build-Test_Nano-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug\debug\*.*"
                  

                  I will make a similar script for the release build. It is sad to be forced to do this, but sometimes I found myself searching for a non existent bug in my code, all because of leftovers from previous builds, so I started using Clean all the times before building. Check my old question about this behaviour, that arose when I was trying to configure OpenCV:

                  https://forum.qt.io/topic/68329/solved-impossible-to-include-opencv-path

                  Then I discovered that in a few cases even that wasn't enough, so I started deleting the build folder every time I included a new header. This is frustrating, I want to be sure that when I get compile errors, it is because I made a mistake somewhere, not because something in the toolchain failed to detect that the build structure of the program has changed.

                  Thank you very much to you and to @Eeli-K for your help :D

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Gmember
                  Super.
                  When inside the pro file, you can ask about build mode but not sure for build steps

                  (in pro)
                  CONFIG(release, debug|release): DESTDIR = $$OUT_PWD/release
                  CONFIG(debug, debug|release): DESTDIR = $$OUT_PWD/debug

                  $$DESTDIR
                  contains path to the build folder

                  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