# Arg1: List of conditions to generate block for
# Arg2: List of variables containing rules to add
defineTest(addMMPRules) {
    unset(myConditions)
    unset(myVariables)
    unset(myIfDef)

    myConditions = $$eval($$1) default
    myVariables = $$eval($$2)
    myIfDef = if

    for(condition, $$list($$myConditions)) {
        contains(condition, default) {
            libBlock = "$${LITERAL_HASH}else"
        } else {
            libBlock = "$${LITERAL_HASH}$${myIfDef} defined($${condition})"
            myIfDef = elif
        }

        for(var, $$list($$myVariables)) {
            varVal = $$eval($${var}.$${condition})
            isEmpty(varVal) {
                # No value defined for current condition, so use default
                varVal = $$eval($${var}.default)
            }
            !isEmpty(varVal): libBlock += "$$join(varVal,$$escape_expand(\\n))"
        }

        MMP_RULES += $$libBlock
    }
    MMP_RULES += "$${LITERAL_HASH}endif"
    export(MMP_RULES)
}
