Solved How to pass an argument to .pri file?
-
@user2301 said in How to pass an argument to .pri file?:
Or what is the syntax to access system environment variable?
$$(VARNAME)
-
@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?
-
@user2301
if you call with with the system command -
@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)
-
@user2301 said in How to pass an argument to .pri file?:
$$system($$PWD/env.ps1)
Shouldn't it be
$$system($$(PWD)/env.ps1)
?
-
@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. -
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)
? -
@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?
-
@user2301 you are invoking qmake within your .gitlab-ci.yml file, correct ?
-
@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
-
And you would like to use that
CI_TAG
environment variable in your .pri file, correct ? -
@SGaist Yes. Since I am using docker container, I do not have git installed inside the container, I have two use cases.
- to use git describe --tags for only local build.
- 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)
-
Try something like:
GIT_VERSION = $$(CI_TAG) isEmpty(GIT_VERSION){ GIT_VERSION = $$system(git describe --tags) } ``
-
@SGaist Okay Thanks a lot. It works.
-
@user2301 Then please mark this topic as SOLVED too. Thanks!