From .pro file how to access a variable from another file?



  • I don't understand much of qmake and haven't find on documentation anything about this topic.

    What i'm looking to do is, i want to access a variable that can be define inside a .js or .py file and use it on a QT .pro file.

    Something like this:

    VAR_VERSION = getVariableValue($$PWD/file.js,"var_version")
    

    where getVariableValue would be a way (parser or similar) to get the variable var_version value that is inside the file.js file.

    This can be impossible to do, or there may be some way to get a variable value, or the content of a file somehow.

    Anyone knows a way of doing it?


  • Qt Champions 2018

    @Nmaster88 I don't understand the use case: why do you want to parse a file to get value of a variable? Can you explain what you want to achieve? Also, variables are often initialised at runtime - you would not get any meaningful value for such a variable if your would parse the source code.
    Usually one executes such a script which then returns a value.



  • we would like to install different builds on the same machine and the place were would do that distinction would be on the .pro file, to then generate different values for the "version" value of "info.plist" file.

    We already have a portion of code that we can probably use to do something similar:

    codegen.commands = python "\"$${PATH}/Dir1/test.py\""
    !isEmpty(VARNAME) {
        message($$VARNAME)
        codegen.commands += VarName=$$CONFNAME
    }
    

    I think we are getting there


Log in to reply