[QBS] Platform probe procedure

BogDan bog_dan_ro at yahoo.com
Tue Mar 6 10:50:41 CET 2012


Hello,

  I've check current "platform probe" procedure and I don't find it very flexible, IMHO creating an application to probe a platform is too complicated, as long as you have a very powerful scripting language.  So, my proposal is to use QML to probe the platforms also.
Because to probe for a platform you need some extra informations (e.g where is the toolchain, etc.),  I tried to make it IDE friendly, meaning that the IDE can create dynamic forms to collect all the informations needed to probe for that platform. 


Here is a proof of concept android platform probe (I didn't check if the syntax if is correct or not):

//////////


import qbs.base 1.0

Platform {
    name: "android" // Name of the platform
    description: "Android O.S. support" // Description, used by the IDE to show some info about the probe

    property var ndkPath
    PropertyOptions {
        name: "ndkPath" // Name of the property
        description: "Android NDK path" // The IDE will use this information to fill a lable before the control
        type: "path" // the type is very important for IDE, in this case the IDE will create a control which accepts only a path
        isValid: { // is this property valid ?  This info will be used by the IDE to enable/disable any control which depends by this one (e.g. the toolchain version should be disabled till this values will become true)
            if (!File.exists(ndkPath+'/toolchains') || !File.exists(ndkPath+'/platforms'))
                throw "Selected path doesn't seems to contains an Android NDK"
            return true
        }
    }

    property var toolchainVersion
    PropertyOptions {
        Depends { name: "ndkPath" } // The IDE will use this info to enable/dissble the control if the ndkPath is valid or not
        name: "toolchainVersion" // Name of the property
        description: "Please select the toolchain version" // The IDE will use this information to fill the label before the control
        type: "combobox" // the IDE will create a combobox control
        value: { // the IDE will fill the control (combobox) with these values and it will use only one to set the property
            if (!ndkPath.isValid) // check if the ndkPath property is set correctly
                throw "Please select Android NDK path first"
            var versions
            var versionFiles = File.ls(ndkPath+'/toolchains/*') // dir all the files from toolchains folder
            for (var ver in versionFiles)
            {
                var match = /.*-(\d+.\d+.\d+)/(ver) // get the version number, the files will have the following patter platform-abi-x.y.z where x.y.z is the gcc version.
                if (!versions.contains(match[1]))
                    versions.push(match[1])
            }
            return versions
        }

        isValid: { // check if the version is valid
            return ndkPath.isValid && toolchainVersion.value.contains(toolchainVersion)
        }
    }

    property bool isValid : false

    probe: {
        isValid = ndkPath.isValid && toolchainVersion.isValid
        return isValid
    }
}


//////////

Cheers,
BogDan.



More information about the Qbs mailing list