summaryrefslogtreecommitdiffstats
path: root/mkspecs/features/exclusive_builds.prf
blob: 8898c96a437693a13c3420f378785c11d398f1fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# fixExclusiveOutputDirs(1config, 2config)
# Change all output paths that references 2config to have the string 1config in them
defineTest(fixExclusiveOutputDirs) {
    unset(firstBuild)
    unset(secondBuild)
    unset(appendFirstBuild)
    firstBuild = $$1
    secondBuild = $$2
    count(ARGS, 2, greaterThan):isEqual($$list($$lower($$3)), false):appendFirstBuild = false
    else:appendFirstBuild = true

    isEmpty(QMAKE_DIR_REPLACE):QMAKE_DIR_REPLACE += OBJECTS_DIR MOC_DIR RCC_DIR
    lessThan(firstBuild, $$secondBuild):eval($${firstBuild}_and_$${secondBuild}_target:QMAKE_DIR_REPLACE += DESTDIR)
    else:eval($${secondBuild}_and_$${firstBuild}_target:QMAKE_DIR_REPLACE += DESTDIR)
    for(fix, QMAKE_DIR_REPLACE) {
        isEmpty($$fix)|isEqual($$fix, .) {
            eval($$fix = $${firstBuild})
        } else:contains($$list($$first($$fix)), .*$${secondBuild}.*) {
            eval($$fix ~= s/$${secondBuild}/$${firstBuild}/gi)
        } else:isEqual(appendFirstBuild, true):!contains($$list($$first($$fix)), .*$${firstBuild}.*) {
            contains($$list($${first($$fix)}), .*/$):eval($$fix = $${first($$fix)}$${firstBuild})
	    else:eval($$fix = $${first($$fix)}-$${firstBuild})
        }
        export($$fix)
    }
    return(true)
}

# addExclusiveBuilds(1config, 1name, 2config, 2name)
# Adds two BUILDS which are exclusive to each other.
defineTest(addExclusiveBuilds) {
    unset(firstBuild)
    unset(firstBuildName)
    unset(secondBuild)
    unset(secondBuildName)

    firstBuild = $$1
    firstBuildName = $$2
    secondBuild = $$3
    secondBuildName = $$4

    contains(TEMPLATE, subdirs) {
        eval(sub_$${firstBuildName}.target = $$firstBuild)
	export(sub_$${firstBuildName}.target)
        eval(sub_$${firstBuildName}.CONFIG = recursive)
	export(sub_$${firstBuildName}.CONFIG)
        eval(sub_$${secondBuildName}.target = $$secondBuild)
	export(sub_$${secondBuildName}.target)
        eval(sub_$${secondBuildName}.CONFIG = recursive)
	export(sub_$${secondBuildName}.CONFIG)
	QMAKE_EXTRA_TARGETS += sub_$${firstBuildName} sub_$${secondBuildName}
	export(QMAKE_EXTRA_TARGETS)
    } else:!build_pass {
        first_BUILDS  =
        second_BUILDS =
        suffix_BUILDS = Build

        isEmpty(BUILDS): BUILDPERMUTATIONS = $$suffix_BUILDS
        else: BUILDPERMUTATIONS = $$BUILDS

        for(permutation, BUILDPERMUTATIONS) {
            permutation ~= s/$${suffix_BUILDS}$//
            isEmpty(permutation): permutationName =
            else: permutationName = -$$permutation
            # Makefile target rule
            eval($${firstBuildName}$${permutation}.target  = $${firstBuild}$$lower($${permutationName}))
	    export($${firstBuildName}$${permutation}.target)
            # IDE name
            eval($${firstBuildName}$${permutation}.name    = $${firstBuildName}$${permutationName})
	    export($${firstBuildName}$${permutation}.name)
	    # prl import CONFIG option
            eval($${firstBuildName}$${permutation}.PRL_CONFIG  = $${firstBuild}$${permutation})
            export($${firstBuildName}$${permutation}.PRL_CONFIG)
            # Individual CONFIG option
            eval($${firstBuildName}$${permutation}.CONFIG  = $${firstBuild} $${firstBuildName}Build $$eval($${permutation}.CONFIG))
	    export($${firstBuildName}$${permutation}.CONFIG)

            eval($${secondBuildName}$${permutation}.target = $${secondBuild}$$lower($${permutationName}))
	    export($${secondBuildName}$${permutation}.target)
            eval($${secondBuildName}$${permutation}.name   = $${secondBuildName}$${permutationName})
	    export($${secondBuildName}$${permutation}.name)
	    eval($${secondBuildName}$${permutation}.PRL_CONFIG  = $${secondBuild}$${permutation})
	    export($${secondBuildName}$${permutation}.PRL_CONFIG)
            eval($${secondBuildName}$${permutation}.CONFIG = $${secondBuild} $${secondBuildName}Build $$eval($${permutation}.CONFIG))
	    export($${secondBuildName}$${permutation}.CONFIG)
 
            first_BUILDS += $${firstBuildName}$${permutation}
            second_BUILDS += $${secondBuildName}$${permutation}
        }
 
        # A mutual exclusive block.
        CONFIG($${firstBuild}, $${firstBuild}|$${secondBuild}): BUILDS = $$first_BUILDS  $$second_BUILDS 
        else: BUILDS = $$second_BUILDS $$first_BUILDS
        export(BUILDS)
    } else {
        eval($${firstBuildName}Build:fixExclusiveOutputDirs($$firstBuild, $$secondBuild, false))
        eval($${secondBuildName}Build:fixExclusiveOutputDirs($$secondBuild, $$firstBuild, false))
    }
    return(true)
}