aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/blackbox/find/find-xcode.qbs
blob: 15c2aa17eab723cfdd8f69f3f935f045f5a430ef (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
import qbs.TextFile

Product {
    Depends { name: "xcode"; required: false }
    type: ["json"]
    Rule {
        multiplex: true
        Artifact {
            filePath: ["xcode.json"]
            fileTags: ["json"]
        }
        prepare: {
            var cmd = new JavaScriptCommand();
            cmd.description = output.filePath;
            cmd.sourceCode = function() {
                var tools = {};
                var present = product.moduleProperty("xcode", "present");
                tools["present"] = !!present;
                if (present) {
                    var keys = [
                        "developerPath",
                        "version"
                    ];
                    for (var i = 0; i < keys.length; ++i) {
                        var key = keys[i];
                        tools[key] = product.xcode[key];
                    }
                }

                var tf;
                try {
                    tf = new TextFile(output.filePath, TextFile.WriteOnly);
                    tf.writeLine(JSON.stringify(tools, undefined, 4));
                } finally {
                    if (tf)
                        tf.close();
                }
            };
            return cmd;
        }
    }
}