blob: c18fcac43c91ccffb608e1cb72ca8435c48229c4 (
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
|
import qbs.FileInfo
import qbs.Host
import qbs.TextFile
Project {
CppApplication {
name: "cat-response-file"
files: ["cat-response-file.cpp"]
cpp.enableExceptions: true
}
Product {
condition: {
var result = qbs.targetPlatform === Host.platform();
if (!result)
console.info("targetPlatform differs from hostPlatform");
return result;
}
name: "response-file-text"
type: ["text"]
Depends { name: "cpp" }
Depends { name: "cat-response-file" }
qbs.installPrefix: ""
Group {
fileTagsFilter: ["text"]
qbs.install: true
}
Rule {
inputsFromDependencies: ["application"]
Artifact {
filePath: "response-file-content.txt"
fileTags: ["text"]
}
prepare: {
var filePath = inputs["application"][0].filePath;
var args = [output.filePath, "foo", "with space", "bar"];
var cmd = new Command(filePath, args);
cmd.responseFileThreshold = 1;
cmd.responseFileArgumentIndex = 1;
cmd.responseFileUsagePrefix = '@';
cmd.silent = true;
return cmd;
}
}
}
Product {
name: "lotsofobjects"
type: ["dynamiclibrary"]
// clang-cl does not use response file internally, thus linker complains that command is
// too long. This can be worked around by calling the linker directly
cpp.linkerMode: qbs.toolchain.includes("clang-cl") ? "manual" : original
Depends { name: "cpp" }
Rule {
multiplex: true
outputFileTags: ["cpp"]
outputArtifacts: {
var artifacts = [];
for (var i = 0; i < 1000; ++i)
artifacts.push({filePath: "source-" + i + ".cpp", fileTags: ["cpp"]});
return artifacts;
}
prepare: {
var cmd = new JavaScriptCommand();
cmd.description = "generating " + outputs["cpp"].length + " dummy source files";
cmd.outputFilePaths = outputs["cpp"].map(function (a) {
return a.filePath;
});
cmd.sourceCode = function () {
var index = 0;
outputFilePaths.map(function (fp) {
var tf = new TextFile(fp, TextFile.WriteOnly);
try {
tf.writeLine("extern int foo" + index + "() { return 0; }");
++index;
} finally {
tf.close();
}
});
};
return [cmd];
}
}
}
}
|