lbkit 0.6.6__tar.gz → 0.6.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lbkit-0.6.6/lbkit.egg-info → lbkit-0.6.8}/PKG-INFO +10 -2
- lbkit-0.6.8/lbkit/__init__.py +2 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/codegen/idf_interface.py +76 -6
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/codegen/template/client.h.mako +2 -5
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/codegen/template/public.c.mako +58 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/codegen/template/public.h.mako +41 -14
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/codegen/template/server.h.mako +3 -6
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/component/template/conanbase.mako +13 -2
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/tools.py +9 -1
- {lbkit-0.6.6 → lbkit-0.6.8/lbkit.egg-info}/PKG-INFO +10 -2
- lbkit-0.6.6/lbkit/__init__.py +0 -2
- {lbkit-0.6.6 → lbkit-0.6.8}/AUTHORS +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/LICENSE +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/MANIFEST.in +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/README.md +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/build_conan_parallel.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/ci_robot/__init__.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/ci_robot/gitee.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/cli.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/codegen/__init__.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/codegen/codegen.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/codegen/ctype_defination.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/codegen/renderer.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/codegen/template/client.c.mako +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/codegen/template/interface.c.mako +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/codegen/template/interface.introspect.xml.mako +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/codegen/template/server.c.mako +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/component/__init__.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/component/arg_parser.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/component/build.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/component/template/deploy.mako +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/component/test.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/errors.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/helper.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/integration/__init__.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/integration/build_image.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/integration/build_manifest.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/integration/build_prepare.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/integration/build_rootfs.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/integration/config.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/integration/task.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/integration/template/conanfile.py.mako +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/integration/template/rootfs.py.mako +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/lbkit.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/log.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/misc.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/utils/__init__.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/utils/images/__init__.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit/utils/images/emmc.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit.egg-info/SOURCES.txt +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit.egg-info/dependency_links.txt +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit.egg-info/entry_points.txt +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit.egg-info/requires.txt +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/lbkit.egg-info/top_level.txt +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/setup.cfg +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/setup.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/test/__init__.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/test/test_codegen.py +0 -0
- {lbkit-0.6.6 → lbkit-0.6.8}/test/test_helper.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: lbkit
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.8
|
|
4
4
|
Summary: Tools provided by litebmc.com
|
|
5
5
|
Home-page: https://www.litebmc.com
|
|
6
6
|
Author: xuhj@litebmc.com
|
|
@@ -21,5 +21,13 @@ Requires-Dist: requests
|
|
|
21
21
|
Requires-Dist: gitpython
|
|
22
22
|
Requires-Dist: inflection
|
|
23
23
|
Requires-Dist: meson>=1.4.0
|
|
24
|
+
Dynamic: author
|
|
25
|
+
Dynamic: author-email
|
|
26
|
+
Dynamic: classifier
|
|
27
|
+
Dynamic: description
|
|
28
|
+
Dynamic: description-content-type
|
|
29
|
+
Dynamic: home-page
|
|
30
|
+
Dynamic: requires-dist
|
|
31
|
+
Dynamic: summary
|
|
24
32
|
|
|
25
33
|
build and code generate tools
|
|
@@ -7,7 +7,7 @@ from lbkit.log import Logger
|
|
|
7
7
|
from lbkit.codegen.renderer import Renderer
|
|
8
8
|
from lbkit.codegen.ctype_defination import CTYPE_OBJS, RefObjArrayValidator, RefObjValidator
|
|
9
9
|
from lbkit.misc import load_yml_with_json_schema_validate
|
|
10
|
-
from lbkit.errors import OdfValidateException
|
|
10
|
+
from lbkit.errors import OdfValidateException, LiteBmcException
|
|
11
11
|
from lbkit.helper import SigInvalidException, validate_glib_signature
|
|
12
12
|
|
|
13
13
|
log = Logger("gen_interface")
|
|
@@ -16,7 +16,9 @@ class IDFException(Exception):
|
|
|
16
16
|
pass
|
|
17
17
|
|
|
18
18
|
class IdfInterfacePlugin(Renderer):
|
|
19
|
-
|
|
19
|
+
def __init__(self):
|
|
20
|
+
super().__init__()
|
|
21
|
+
self.actions = []
|
|
20
22
|
|
|
21
23
|
class IdfInterfaceBase(Renderer):
|
|
22
24
|
def __init__(self) -> None:
|
|
@@ -65,6 +67,24 @@ ACCESS_FLAG_MAP = {
|
|
|
65
67
|
"readwrite": "G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE | G_DBUS_PROPERTY_INFO_FLAGS_READABLE"
|
|
66
68
|
}
|
|
67
69
|
|
|
70
|
+
# 简单类型的格式化符号
|
|
71
|
+
PRINT_FORMATTER_MAP = {
|
|
72
|
+
"byte": "%u",
|
|
73
|
+
"uint16": "G_GUINT16_FORMAT",
|
|
74
|
+
"uint32": "G_GUINT32_FORMAT",
|
|
75
|
+
"uint64": "G_GUINT64_FORMAT",
|
|
76
|
+
"int16": "G_GINT16_FORMAT",
|
|
77
|
+
"int32": "G_GINT32_FORMAT",
|
|
78
|
+
"int64": "G_GINT64_FORMAT",
|
|
79
|
+
"size": "G_GSIZE_FORMAT",
|
|
80
|
+
"ssize": "G_GSSIZE_FORMAT",
|
|
81
|
+
"double": "%d",
|
|
82
|
+
"boolean": "%i",
|
|
83
|
+
"string": "%s",
|
|
84
|
+
"object_path": "%s",
|
|
85
|
+
"signature": "%s"
|
|
86
|
+
}
|
|
87
|
+
|
|
68
88
|
# ^(byte|uint16|uint32|uint64|int16|int32|int64|double|boolean|string|object_path|signature|unixfd|(array\\[(byte|uint16|uint32|uint64|int16|int32|int64|double|boolean|string|object_path|signature|unixfd)\\])|((struct|enum|dict)\\[[a-zA-Z][A-Za-z0-9.]*\\])|(array\\[(struct|enum|dict)\\[[a-zA-Z][A-Za-z0-9.]*\\]\\]))$"
|
|
69
89
|
|
|
70
90
|
METHOD_NAME_REGEX = "[A-Z][a-zA-Z0-9_]*"
|
|
@@ -816,11 +836,12 @@ class IdfBase():
|
|
|
816
836
|
|
|
817
837
|
|
|
818
838
|
class IdfMethod(IdfBase):
|
|
819
|
-
is_plugin = False
|
|
820
839
|
def __init__(self, intf: IdfInterfaceBase, method_data):
|
|
840
|
+
self.is_plugin = False
|
|
821
841
|
super().__init__(intf, method_data)
|
|
822
842
|
self.parameters: IdfParameters = IdfParameters(intf, method_data.get("parameters", []))
|
|
823
843
|
self.returns: IdfParameters = IdfParameters(intf, method_data.get("returns", []))
|
|
844
|
+
self.errors: list[str] = method_data.get("errors", [])
|
|
824
845
|
|
|
825
846
|
@property
|
|
826
847
|
def in_signature(self):
|
|
@@ -835,8 +856,17 @@ class IdfMethod(IdfBase):
|
|
|
835
856
|
deps = []
|
|
836
857
|
deps.extend(self.parameters.dependency_interface)
|
|
837
858
|
deps.extend(self.returns.dependency_interface)
|
|
859
|
+
deps.extend(self.errors_dependency())
|
|
838
860
|
return list(set(deps))
|
|
839
861
|
|
|
862
|
+
def errors_dependency(self):
|
|
863
|
+
deps = []
|
|
864
|
+
for error in self.errors:
|
|
865
|
+
pos = error.rfind(".Error.")
|
|
866
|
+
if pos > 0:
|
|
867
|
+
deps.append(error[0:pos])
|
|
868
|
+
return deps
|
|
869
|
+
|
|
840
870
|
class IdfSignal(IdfBase):
|
|
841
871
|
def __init__(self, intf: IdfInterfaceBase, signal_data):
|
|
842
872
|
super().__init__(intf, signal_data)
|
|
@@ -881,9 +911,8 @@ class IdfStructure(IdfBase):
|
|
|
881
911
|
|
|
882
912
|
|
|
883
913
|
class IdfPluginAction(IdfMethod):
|
|
884
|
-
is_plugin = True
|
|
885
|
-
|
|
886
914
|
def __init__(self, intf: IdfInterfaceBase, method_data):
|
|
915
|
+
self.is_plugin = True
|
|
887
916
|
self.policy = method_data.get("policy", "continue_always")
|
|
888
917
|
super().__init__(intf, method_data)
|
|
889
918
|
|
|
@@ -1012,10 +1041,11 @@ class IdfInterface(IdfInterfaceBase):
|
|
|
1012
1041
|
self.methods: list[IdfMethod] = []
|
|
1013
1042
|
self.signals: list[IdfSignal] = []
|
|
1014
1043
|
self.structures: dict[str, IdfStructure] = {}
|
|
1044
|
+
self.errors: dict[str, IdfStructure] = {}
|
|
1015
1045
|
self.dictionaries: dict[str, IdfDictionary] = {}
|
|
1016
1046
|
self.enumerations: dict[str, IdfEnumeration] = {}
|
|
1017
1047
|
self.annotations: list[IdfAnnotation] = []
|
|
1018
|
-
self.plugin: IdfInterfacePlugin =
|
|
1048
|
+
self.plugin: IdfInterfacePlugin = None
|
|
1019
1049
|
self.description = None
|
|
1020
1050
|
self.version = None
|
|
1021
1051
|
self.alias = None
|
|
@@ -1064,6 +1094,8 @@ class IdfInterface(IdfInterfaceBase):
|
|
|
1064
1094
|
deps.extend(signal.dependency_interface)
|
|
1065
1095
|
for method in self.methods:
|
|
1066
1096
|
deps.extend(method.dependency_interface)
|
|
1097
|
+
for _, error in self.errors.items():
|
|
1098
|
+
deps.extend(error.dependency_interface)
|
|
1067
1099
|
return list(set(deps))
|
|
1068
1100
|
|
|
1069
1101
|
@property
|
|
@@ -1159,12 +1191,18 @@ class IdfInterface(IdfInterfaceBase):
|
|
|
1159
1191
|
for item in items:
|
|
1160
1192
|
self.signals.append(IdfSignal(self, item))
|
|
1161
1193
|
items = idf.get("methods", [])
|
|
1194
|
+
self.methods = []
|
|
1162
1195
|
for item in items:
|
|
1163
1196
|
self.methods.append(IdfMethod(self, item))
|
|
1164
1197
|
items = idf.get("structures", [])
|
|
1165
1198
|
for item in items:
|
|
1166
1199
|
obj = IdfStructure(self, item)
|
|
1167
1200
|
self.structures[obj.name] = obj
|
|
1201
|
+
items = idf.get("errors", [])
|
|
1202
|
+
for item in items:
|
|
1203
|
+
obj = IdfStructure(self, item, "parameters")
|
|
1204
|
+
self.errors[obj.name] = obj
|
|
1205
|
+
self._check_errors_format()
|
|
1168
1206
|
items = idf.get("dictionaries", [])
|
|
1169
1207
|
for item in items:
|
|
1170
1208
|
obj = IdfDictionary(self, item)
|
|
@@ -1174,6 +1212,7 @@ class IdfInterface(IdfInterfaceBase):
|
|
|
1174
1212
|
obj = IdfEnumeration(self, item)
|
|
1175
1213
|
self.enumerations[obj.name] = obj
|
|
1176
1214
|
plugin = idf.get("plugin", None)
|
|
1215
|
+
self.plugin = IdfInterfacePlugin()
|
|
1177
1216
|
if plugin is not None:
|
|
1178
1217
|
items = plugin.get("actions", [])
|
|
1179
1218
|
for item in items:
|
|
@@ -1208,3 +1247,34 @@ class IdfInterface(IdfInterfaceBase):
|
|
|
1208
1247
|
out = self.render(self.lookup, template, intf=self, codegen_version=codegen_version)
|
|
1209
1248
|
with open(out_file, "w") as fd:
|
|
1210
1249
|
fd.write(out)
|
|
1250
|
+
|
|
1251
|
+
def _check_errors_format(self):
|
|
1252
|
+
for name, error in self.errors.items():
|
|
1253
|
+
desc = error.description
|
|
1254
|
+
chunks = []
|
|
1255
|
+
prev_line = ""
|
|
1256
|
+
for chunk in desc.split("$?"):
|
|
1257
|
+
if prev_line:
|
|
1258
|
+
chunks.append(prev_line + chunk)
|
|
1259
|
+
prev_line = ""
|
|
1260
|
+
elif chunk[-1:] == "\\":
|
|
1261
|
+
prev_line = chunk[:-1] + "$?"
|
|
1262
|
+
else:
|
|
1263
|
+
chunks.append(chunk)
|
|
1264
|
+
# 如果剩余prev_line示处理,表示纯粹剩余一个\
|
|
1265
|
+
if prev_line:
|
|
1266
|
+
chunks.append(prev_line[:-2] + "\\")
|
|
1267
|
+
# 参数个数检验
|
|
1268
|
+
if len(chunks) != len(error.values.parameters) + 1:
|
|
1269
|
+
raise LiteBmcException(f"The number({len(chunks) - 1}) of $? in the description string(Error: ${name}) does not match the number({len(error.values.parameters)}) of parameters")
|
|
1270
|
+
new_desc = chunks[0]
|
|
1271
|
+
id = 1
|
|
1272
|
+
for param in error.values.parameters:
|
|
1273
|
+
formatter = PRINT_FORMATTER_MAP[param.ctype]
|
|
1274
|
+
if formatter.startswith("%"):
|
|
1275
|
+
new_desc += formatter
|
|
1276
|
+
else:
|
|
1277
|
+
new_desc += f"%\"{formatter}\""
|
|
1278
|
+
new_desc += chunks[id]
|
|
1279
|
+
id += 1
|
|
1280
|
+
error.description = new_desc
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<% from lbkit.tools import hump2underline %>\
|
|
1
2
|
#ifndef __${"_".join(intf.name.upper().split(".", -1))}_CLI_H__
|
|
2
3
|
#define __${"_".join(intf.name.upper().split(".", -1))}_CLI_H__
|
|
3
4
|
|
|
@@ -104,14 +105,10 @@ void ${class_name}_Unsubscribe_${signal.name}(guint *id);
|
|
|
104
105
|
% endif
|
|
105
106
|
|
|
106
107
|
% endfor
|
|
107
|
-
#define ${class_name.upper()}_NAME "${intf.name}"
|
|
108
|
-
% for prop in intf.properties:
|
|
109
|
-
#define ${class_name.upper()}_${prop.name}_NAME "${prop.name}"
|
|
110
|
-
% endfor
|
|
111
108
|
|
|
112
109
|
${class_name}_Properties *${class_name}_properties(void);
|
|
113
110
|
LBInterface *${class_name}_interface(void);
|
|
114
|
-
#define ${class_name.upper()}
|
|
111
|
+
#define ${hump2underline(class_name).upper()} ${class_name}_interface()
|
|
115
112
|
|
|
116
113
|
#ifdef __cplusplus
|
|
117
114
|
}
|
|
@@ -2,6 +2,64 @@
|
|
|
2
2
|
#include "${intf.name}.h"
|
|
3
3
|
|
|
4
4
|
<% class_name = intf.alias %>\
|
|
5
|
+
### 生成Errors错误 START
|
|
6
|
+
% if len(intf.errors):
|
|
7
|
+
### 定义错误码表
|
|
8
|
+
static const GDBusErrorEntry _dbus_error_entries[] =
|
|
9
|
+
{
|
|
10
|
+
% for name, stru in intf.errors.items():
|
|
11
|
+
{
|
|
12
|
+
.error_code = ${class_name}_Error_${name},
|
|
13
|
+
.dbus_error_name = "${intf.name}.Error.${name}"
|
|
14
|
+
},
|
|
15
|
+
% endfor
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
### 初始化quark表
|
|
19
|
+
static GQuark _dbus_error_quark(void)
|
|
20
|
+
{
|
|
21
|
+
static gsize quark = 0;
|
|
22
|
+
g_dbus_error_register_error_domain("${intf.name.replace(".", "-")}-quark",
|
|
23
|
+
&quark,
|
|
24
|
+
_dbus_error_entries,
|
|
25
|
+
G_N_ELEMENTS (_dbus_error_entries));
|
|
26
|
+
return (GQuark) quark;
|
|
27
|
+
}
|
|
28
|
+
### 构建参数原型和参数列表
|
|
29
|
+
% for name, stru in intf.errors.items():
|
|
30
|
+
|
|
31
|
+
<% proto_str="" %>\
|
|
32
|
+
<% param_str="" %>\
|
|
33
|
+
% for prop in stru.values.parameters:
|
|
34
|
+
% for dec in prop.declare():
|
|
35
|
+
<% proto_str += dec.replace("<arg_name>", prop.name).replace("<const>", "const ") + ", " %>\
|
|
36
|
+
% endfor
|
|
37
|
+
<% param_str += prop.name + ", " %>\
|
|
38
|
+
% endfor
|
|
39
|
+
% if stru.description:
|
|
40
|
+
/*
|
|
41
|
+
* Error: ${stru.description.strip()}
|
|
42
|
+
*/
|
|
43
|
+
% endif
|
|
44
|
+
### 生成错误消息
|
|
45
|
+
% if len(proto_str):
|
|
46
|
+
GError *${intf.alias}_Error_${name}_new(${proto_str[:-2]})
|
|
47
|
+
{
|
|
48
|
+
return g_error_new(_dbus_error_quark(), ${class_name}_Error_${name},
|
|
49
|
+
"${stru.description.strip()}",
|
|
50
|
+
${param_str[:-2]});
|
|
51
|
+
}
|
|
52
|
+
% else:
|
|
53
|
+
GError *${intf.alias}_Error_${name}_new(void)
|
|
54
|
+
{
|
|
55
|
+
return g_error_new(_dbus_error_quark(), ${class_name}_Error_${name},
|
|
56
|
+
"${stru.description.strip()}");
|
|
57
|
+
}
|
|
58
|
+
%endif
|
|
59
|
+
%endfor
|
|
60
|
+
|
|
61
|
+
%endif
|
|
62
|
+
### 生成Errors错误 END
|
|
5
63
|
## 定义结构体ODF加载函数
|
|
6
64
|
% for name, stru in intf.structures.items():
|
|
7
65
|
/* ${name} structure object */
|
|
@@ -15,6 +15,17 @@ extern "C" {
|
|
|
15
15
|
/* Interface ${intf.alias} codegen start */
|
|
16
16
|
|
|
17
17
|
<% class_name = intf.alias %>\
|
|
18
|
+
### 生成Errors错误 START >>>>>
|
|
19
|
+
% if len(intf.errors):
|
|
20
|
+
### 定义枚举类型
|
|
21
|
+
typedef enum {
|
|
22
|
+
% for name, stru in intf.errors.items():
|
|
23
|
+
${class_name}_Error_${name},
|
|
24
|
+
% endfor
|
|
25
|
+
} ${class_name}_Error;
|
|
26
|
+
|
|
27
|
+
%endif
|
|
28
|
+
### 生成Errors错误 END <<<<<
|
|
18
29
|
% for name, stru in intf.structures.items():
|
|
19
30
|
/*
|
|
20
31
|
* structure: ${name}
|
|
@@ -41,8 +52,36 @@ typedef struct _${name} ${name};
|
|
|
41
52
|
% endfor
|
|
42
53
|
% endif
|
|
43
54
|
*/
|
|
44
|
-
typedef enum
|
|
55
|
+
typedef enum {
|
|
56
|
+
% for value in enum.values.parameters:
|
|
57
|
+
${name}_${value.name},
|
|
58
|
+
% endfor
|
|
59
|
+
_${name}Invalid,
|
|
60
|
+
} ${name};
|
|
61
|
+
const gchar *${name}_as_string(${name} value);
|
|
62
|
+
|
|
45
63
|
% endfor
|
|
64
|
+
### 生成Errors错误 START
|
|
65
|
+
% if len(intf.errors):
|
|
66
|
+
% for name, stru in intf.errors.items():
|
|
67
|
+
<% proto_str="" %>\
|
|
68
|
+
% for prop in stru.values.parameters:
|
|
69
|
+
% for dec in prop.declare():
|
|
70
|
+
<% proto_str += dec.replace("<arg_name>", prop.name).replace("<const>", "const ") + ", " %>\
|
|
71
|
+
% endfor
|
|
72
|
+
% endfor
|
|
73
|
+
/*
|
|
74
|
+
* Error: ${stru.description.strip()}
|
|
75
|
+
*/
|
|
76
|
+
% if len(proto_str):
|
|
77
|
+
GError *${intf.alias}_Error_${name}_new(${proto_str[:-2]});
|
|
78
|
+
% else:
|
|
79
|
+
GError *${intf.alias}_Error_${name}_new(void);
|
|
80
|
+
%endif
|
|
81
|
+
%endfor
|
|
82
|
+
|
|
83
|
+
%endif
|
|
84
|
+
### 生成Errors错误 END
|
|
46
85
|
% for name, dictionary in intf.dictionaries.items():
|
|
47
86
|
/*
|
|
48
87
|
* dictionary: ${name}
|
|
@@ -57,8 +96,8 @@ typedef enum _${name} ${name};
|
|
|
57
96
|
*/
|
|
58
97
|
typedef struct _${name}${dictionary.key} ${name}${dictionary.key};
|
|
59
98
|
typedef struct _${name} ${name};
|
|
60
|
-
% endfor
|
|
61
99
|
|
|
100
|
+
% endfor
|
|
62
101
|
% for name, stru in intf.structures.items():
|
|
63
102
|
% if name != class_name:
|
|
64
103
|
/*
|
|
@@ -82,18 +121,6 @@ struct _${name} {
|
|
|
82
121
|
|
|
83
122
|
% endif
|
|
84
123
|
%endfor
|
|
85
|
-
% for name, enum in intf.enumerations.items():
|
|
86
|
-
## 枚举定义
|
|
87
|
-
enum _${name} {
|
|
88
|
-
% for value in enum.values.parameters:
|
|
89
|
-
${name}_${value.name},
|
|
90
|
-
% endfor
|
|
91
|
-
_${name}Invalid,
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const gchar *${name}_as_string(${name} value);
|
|
95
|
-
|
|
96
|
-
% endfor
|
|
97
124
|
% for name, dictionary in intf.dictionaries.items():
|
|
98
125
|
struct _${name}${dictionary.key} {
|
|
99
126
|
% for value in dictionary.values.parameters:
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<% from lbkit.tools import hump2underline %>\
|
|
1
2
|
#ifndef __${"_".join(intf.name.upper().split(".", -1))}_SRV_H__
|
|
2
3
|
#define __${"_".join(intf.name.upper().split(".", -1))}_SRV_H__
|
|
3
4
|
|
|
@@ -50,15 +51,11 @@ gboolean ${class_name}_${signal.name}_Signal(const ${class_name} *object, const
|
|
|
50
51
|
% endif
|
|
51
52
|
% endfor
|
|
52
53
|
|
|
53
|
-
#define ${class_name.upper()}_NAME "${intf.name}"
|
|
54
|
-
% for prop in intf.properties:
|
|
55
|
-
#define ${class_name.upper()}_${prop.name}_NAME "${prop.name}"
|
|
56
|
-
% endfor
|
|
57
|
-
|
|
58
54
|
LBInterface *${class_name}_interface(void);
|
|
59
|
-
#define ${class_name.upper()}_INTERFACE ${class_name}_interface()
|
|
60
55
|
${class_name}_Properties *${class_name}_properties(void);
|
|
61
56
|
|
|
57
|
+
#define ${hump2underline(class_name).upper()} ${class_name}_interface()
|
|
58
|
+
|
|
62
59
|
#ifdef __cplusplus
|
|
63
60
|
}
|
|
64
61
|
#endif
|
|
@@ -199,8 +199,19 @@ class LiteBmcConan(ConanFile):
|
|
|
199
199
|
tc.variables["BUILD_TEST"] = False
|
|
200
200
|
|
|
201
201
|
% if len(pkg.get("options", [])) > 0:
|
|
202
|
-
% for op,
|
|
203
|
-
|
|
202
|
+
% for op, value in pkg["options"].items():
|
|
203
|
+
% if type(value["default"]) == type(False):
|
|
204
|
+
if self.options.${op}:
|
|
205
|
+
tc.variables["BUILD_${op.upper()}"] = True
|
|
206
|
+
tc.preprocessor_definitions["BUILD_${op.upper()}"] = True
|
|
207
|
+
% elif type(value["default"]) == type(""):
|
|
208
|
+
tc.variables["BUILD_${op.upper()}"] = str(self.options.${op})
|
|
209
|
+
tc.preprocessor_definitions["BUILD_${op.upper()}"] = str(self.options.${op}.value)
|
|
210
|
+
% elif type(value["default"]) == type(123):
|
|
211
|
+
tc.preprocessor_definitions["BUILD_${op.upper()}"] = int(self.options.${op}.value)
|
|
212
|
+
% elif type(value["default"]) == type(123.22):
|
|
213
|
+
tc.preprocessor_definitions["BUILD_${op.upper()}"] = float(self.options.${op}.value)
|
|
214
|
+
% endif
|
|
204
215
|
% endfor
|
|
205
216
|
% endif
|
|
206
217
|
tc.extra_cflags = self._append_default_flags()
|
|
@@ -8,6 +8,7 @@ import tempfile
|
|
|
8
8
|
import requests
|
|
9
9
|
import shlex
|
|
10
10
|
import hashlib
|
|
11
|
+
import re
|
|
11
12
|
from lbkit.log import Logger
|
|
12
13
|
from lbkit import errors
|
|
13
14
|
from lbkit import misc
|
|
@@ -170,4 +171,11 @@ class Tools(object):
|
|
|
170
171
|
if sha256sum is None or digest == sha256sum:
|
|
171
172
|
self.log.info("Download %s successfully", url, uptrace=2)
|
|
172
173
|
return
|
|
173
|
-
raise errors.DigestNotMatchError(f"File {dst_file} with sha256 error, need: {sha256sum}, get: {digest}")
|
|
174
|
+
raise errors.DigestNotMatchError(f"File {dst_file} with sha256 error, need: {sha256sum}, get: {digest}")
|
|
175
|
+
|
|
176
|
+
def hump2underline(hunp_str):
|
|
177
|
+
# 匹配正则,匹配小写字母和大写字母的分界位置
|
|
178
|
+
p = re.compile(r'([a-z]|\d)([A-Z])')
|
|
179
|
+
# 这里第二个参数使用了正则分组的后向引用
|
|
180
|
+
sub = re.sub(p, r'\1_\2', hunp_str).lower()
|
|
181
|
+
return sub
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: lbkit
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.8
|
|
4
4
|
Summary: Tools provided by litebmc.com
|
|
5
5
|
Home-page: https://www.litebmc.com
|
|
6
6
|
Author: xuhj@litebmc.com
|
|
@@ -21,5 +21,13 @@ Requires-Dist: requests
|
|
|
21
21
|
Requires-Dist: gitpython
|
|
22
22
|
Requires-Dist: inflection
|
|
23
23
|
Requires-Dist: meson>=1.4.0
|
|
24
|
+
Dynamic: author
|
|
25
|
+
Dynamic: author-email
|
|
26
|
+
Dynamic: classifier
|
|
27
|
+
Dynamic: description
|
|
28
|
+
Dynamic: description-content-type
|
|
29
|
+
Dynamic: home-page
|
|
30
|
+
Dynamic: requires-dist
|
|
31
|
+
Dynamic: summary
|
|
24
32
|
|
|
25
33
|
build and code generate tools
|
lbkit-0.6.6/lbkit/__init__.py
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|