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. How to pass an argument to .pri file?
Forum Updated to NodeBB v4.3 + New Features

How to pass an argument to .pri file?

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 5 Posters 1.9k 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.
  • U user2301

    @raven-worx Okay thanks. If the value of variable is some batch file path or powershelll script path, will the batch file will be executed in .pri file?

    raven-worxR Offline
    raven-worxR Offline
    raven-worx
    Moderators
    wrote on last edited by
    #6

    @user2301
    if you call with with the system command

    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
    If you have a question please use the forum so others can benefit from the solution in the future

    U 1 Reply Last reply
    0
    • raven-worxR raven-worx

      @user2301
      if you call with with the system command

      U Offline
      U Offline
      user2301
      wrote on last edited by user2301
      #7

      @raven-worx I also tried calling directly the script in .pri file. But it did not work and my build got stuck without showing any error.

      $$system($$PWD/env.ps1)
      
      jsulmJ raven-worxR 2 Replies Last reply
      0
      • U user2301

        @raven-worx I also tried calling directly the script in .pri file. But it did not work and my build got stuck without showing any error.

        $$system($$PWD/env.ps1)
        
        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #8

        @user2301 said in How to pass an argument to .pri file?:

        $$system($$PWD/env.ps1)

        Shouldn't it be

        $$system($$(PWD)/env.ps1)
        

        ?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • U user2301

          @raven-worx I also tried calling directly the script in .pri file. But it did not work and my build got stuck without showing any error.

          $$system($$PWD/env.ps1)
          
          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by raven-worx
          #9

          @user2301 said in How to pass an argument to .pri file?:

          $$system($$PWD/env.ps1)

          what is this supposed to do actually?
          It calles the powershell script in the location next to the .pri file.
          Assuming by the name of the script do you expect it to set some env variables which are used in later build steps? That wont work.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

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

            Hi,

            @user2301 said in How to pass an argument to .pri file?:

            CI_COMMIT_TAG

            There might be some over engineering here. Since these are environment variables that you want to use, why not use them as they are meant to in your .pri file ? Basically: Version = $$(CI_COMMIT_TAG) ?

            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
            • raven-worxR raven-worx

              @user2301 said in How to pass an argument to .pri file?:

              $$system($$PWD/env.ps1)

              what is this supposed to do actually?
              It calles the powershell script in the location next to the .pri file.
              Assuming by the name of the script do you expect it to set some env variables which are used in later build steps? That wont work.

              U Offline
              U Offline
              user2301
              wrote on last edited by
              #11

              @raven-worx Yes. This script sets the environment variable to be used later in the build step. The script sets the version of the build to be used in Qt application, which is obtained from the gitlab CI/CD environment variable.
              This is the script.

              if (!$env:CI_COMMIT_TAG) {$env:CI_TAG=$env:CI_COMMIT_SHORT_SHA} else {$env:CI_TAG=$env:CI_COMMIT_TAG}
              

              So is it possible to use such if else statements in the .pri?

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

                @user2301 you are invoking qmake within your .gitlab-ci.yml file, correct ?

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

                U 1 Reply Last reply
                0
                • SGaistS SGaist

                  @user2301 you are invoking qmake within your .gitlab-ci.yml file, correct ?

                  U Offline
                  U Offline
                  user2301
                  wrote on last edited by
                  #13

                  @SGaist Yes. I am invoking qmake from gitlab-ci.yml

                  - qmake app.pro -spec win32-msvc "CONFIG+=release" "CONFIG+=qml_release" "CONFIG+=dsp"
                  - jom qmake_all
                  - jom
                  - jom install
                  
                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #14

                    And you would like to use that CI_TAG environment variable in your .pri file, correct ?

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

                    U 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      And you would like to use that CI_TAG environment variable in your .pri file, correct ?

                      U Offline
                      U Offline
                      user2301
                      wrote on last edited by
                      #15

                      @SGaist Yes. Since I am using docker container, I do not have git installed inside the container, I have two use cases.

                      1. to use git describe --tags for only local build.
                      2. to use CI_COMMIT_TAG for gitlab CI build.

                      These two checks I need to do in .pri file, By either calling a script or writing conditional statements.
                      So something like this:

                      if $$(CI_Build)==true 
                      GIT_VERSION = $$(CI_TAG)
                      else 
                      GIT_VERSION = $$system(git describe --tags)
                      
                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #16

                        Try something like:

                        GIT_VERSION = $$(CI_TAG)
                        isEmpty(GIT_VERSION){
                            GIT_VERSION = $$system(git describe --tags)
                        }
                        ``

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

                        U 1 Reply Last reply
                        1
                        • SGaistS SGaist

                          Try something like:

                          GIT_VERSION = $$(CI_TAG)
                          isEmpty(GIT_VERSION){
                              GIT_VERSION = $$system(git describe --tags)
                          }
                          ``
                          U Offline
                          U Offline
                          user2301
                          wrote on last edited by
                          #17

                          @SGaist Okay Thanks a lot. It works.

                          aha_1980A 1 Reply Last reply
                          1
                          • U user2301

                            @SGaist Okay Thanks a lot. It works.

                            aha_1980A Offline
                            aha_1980A Offline
                            aha_1980
                            Lifetime Qt Champion
                            wrote on last edited by
                            #18

                            @user2301 Then please mark this topic as SOLVED too. Thanks!

                            Qt has to stay free or it will die.

                            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