[Qbs] Using Parameter

Björn Schäpers qt-maillist at hazardy.de
Tue Dec 1 08:48:50 CET 2020


Hi,

I've tried to create a product which sets compiler warnings (because 
cpp.warningLevel: "all" is not enough), and I want to be able to opt in some 
more warnings. I found "Parameter" but I have no idea how to use it.

My product:

Product {
	name: "All Warnings"

	property stringList option1Warnings
	property stringList option2Warnings
	property stringList cxxWarnings
	property stringList warnings

	Properties {
		condition: qbs.toolchainType === "gcc"

		warnings: [...]
		cxxWarnings: warnings.concat([...])
		option1Warnings: [...]
		option2Warnings: [...]
	}

	Export {
		Depends { name: "cpp" }

		Parameter { property bool option1 }
		Parameter { property bool option2 }
		
		Properties {
			condition: option1 && option2
			
			cpp.cFlags: product.warnings.concat(option1Warnings).concat(option2Warnings)
			cpp.cxxFlags: product.cxxWarnings.concat(option1Warnings).concat(option2Warnings)
		}
		Properties {
			condition: option1
			
			cpp.cFlags: product.warnings.concat(option1Warnings)
			cpp.cxxFlags: product.cxxWarnings.concat(option1Warnings)
		}
		Properties {
			condition: option2
			
			cpp.cFlags: product.warnings.concat(option2Warnings)
			cpp.cxxFlags: product.cxxWarnings.concat(option2Warnings)
		}

		cpp.cFlags: product.warnings
		cpp.cxxFlags: product.cxxWarnings
	}
}

I want to use it as followed:
Depends { name: "All Warnings" }
Depends { name: "All Warnings"; option1: true }

My questions:
1. How to access the paramter?
2. It seems the Flags are not exported in that way, is it incorrect?

King regards,
Björn.


More information about the Qbs mailing list