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
|
import qbs
import qbs.File
import qbs.FileInfo
import qbs.Probes
import qbs.ModUtils
import "../protobufbase.qbs" as ProtobufBase
import "../protobuf.js" as HelperFunctions
ProtobufBase {
property string includePath: includeProbe.path
property string libraryPath: libraryProbe.path
property string pluginPath: pluginProbe.filePath
property string pluginName: "protoc-gen-nanopb"
readonly property string _plugin: "protoc-gen-nanopb=" + pluginPath
readonly property string _libraryName: {
var libraryName = FileInfo.baseName(libraryProbe.fileName);
if (libraryName.startsWith("lib"))
libraryName = libraryName.substring(3);
return libraryName;
}
Depends { name: "cpp" }
cpp.libraryPaths: {
var result = [];
if (libraryPath)
result.push(libraryPath);
return result;
}
cpp.dynamicLibraries: {
var result = [];
if (_libraryName)
result.push(_libraryName);
return result;
}
cpp.includePaths: {
var result = [outputDir];
if (includePath)
result.push(includePath);
return result;
}
Rule {
inputs: ["protobuf.input"]
outputFileTags: ["hpp", "protobuf.hpp", "cpp"]
outputArtifacts: {
var outputDir = HelperFunctions.getOutputDir(input.protobuf.nanopb, input);
var result = [
HelperFunctions.cppArtifact(outputDir, input, ["hpp", "protobuf.hpp"],
".pb.h"),
HelperFunctions.cppArtifact(outputDir, input, ["cpp"], ".pb.c")
];
return result;
}
prepare: {
var options = input.protobuf.nanopb.importPaths.map(function (path) {
return "-I" + path;
})
var result = HelperFunctions.doPrepare(
input.protobuf.nanopb, product, input, outputs, "nanopb",
input.protobuf.nanopb._plugin, options);
return result;
}
}
Probes.IncludeProbe {
id: includeProbe
names: ["pb.h", "pb_encode.h", "pb_decode.h", "pb_common.h"]
}
Probes.LibraryProbe {
id: libraryProbe
names: [
"protobuf-nanopb",
"protobuf-nanopbd",
]
}
Probes.BinaryProbe {
id: pluginProbe
names: pluginName
}
validate: {
HelperFunctions.validateCompiler(compilerName, compilerPath);
if (!HelperFunctions.checkPath(includePath))
throw "Can't find nanopb protobuf include files. Please set the includePath property.";
if (!HelperFunctions.checkPath(libraryPath))
throw "Can't find nanopb protobuf library. Please set the libraryPath property.";
if (!HelperFunctions.checkPath(pluginPath))
throw "Can't find nanopb protobuf plugin. Please set the pluginPath property.";
}
}
|