lbkit 0.5.21__tar.gz → 0.6.0__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.5.21/lbkit.egg-info → lbkit-0.6.0}/PKG-INFO +2 -2
- lbkit-0.6.0/lbkit/__init__.py +2 -0
- lbkit-0.6.0/lbkit/build_conan_parallel.py +197 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/cli.py +4 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/codegen/codegen.py +3 -3
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/codegen/ctype_defination.py +52 -52
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/codegen/idf_interface.py +7 -7
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/codegen/template/client.c.mako +24 -24
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/codegen/template/client.h.mako +2 -2
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/codegen/template/public.c.mako +21 -21
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/codegen/template/public.h.mako +15 -15
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/codegen/template/server.c.mako +29 -29
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/codegen/template/server.h.mako +2 -2
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/component/build.py +27 -57
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/component/template/conanbase.mako +4 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/component/template/deploy.mako +4 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/component/test.py +3 -2
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/integration/build_manifest.py +41 -18
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/integration/build_prepare.py +3 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/integration/build_rootfs.py +27 -9
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/integration/config.py +7 -3
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/integration/task.py +11 -8
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/integration/template/conanfile.py.mako +4 -0
- lbkit-0.6.0/lbkit/log.py +84 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/tools.py +31 -16
- {lbkit-0.5.21 → lbkit-0.6.0/lbkit.egg-info}/PKG-INFO +2 -2
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit.egg-info/SOURCES.txt +1 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit.egg-info/requires.txt +1 -1
- {lbkit-0.5.21 → lbkit-0.6.0}/setup.py +1 -1
- {lbkit-0.5.21 → lbkit-0.6.0}/test/test_codegen.py +4 -4
- lbkit-0.5.21/lbkit/__init__.py +0 -2
- lbkit-0.5.21/lbkit/log.py +0 -39
- {lbkit-0.5.21 → lbkit-0.6.0}/AUTHORS +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/LICENSE +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/MANIFEST.in +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/README.md +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/ci_robot/__init__.py +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/ci_robot/gitee.py +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/codegen/__init__.py +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/codegen/renderer.py +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/codegen/template/interface.c.mako +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/codegen/template/interface.introspect.xml.mako +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/component/__init__.py +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/component/arg_parser.py +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/errors.py +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/helper.py +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/integration/__init__.py +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/integration/build_image.py +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/lbkit.py +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit/misc.py +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit.egg-info/dependency_links.txt +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit.egg-info/entry_points.txt +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/lbkit.egg-info/top_level.txt +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/setup.cfg +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/test/__init__.py +0 -0
- {lbkit-0.5.21 → lbkit-0.6.0}/test/test_helper.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lbkit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Tools provided by litebmc.com
|
|
5
5
|
Home-page: https://www.litebmc.com
|
|
6
6
|
Author: xuhj@litebmc.com
|
|
@@ -16,7 +16,7 @@ Requires-Dist: colorama
|
|
|
16
16
|
Requires-Dist: mako
|
|
17
17
|
Requires-Dist: node-semver==0.6.1
|
|
18
18
|
Requires-Dist: jsonschema
|
|
19
|
-
Requires-Dist: conan
|
|
19
|
+
Requires-Dist: conan
|
|
20
20
|
Requires-Dist: requests
|
|
21
21
|
Requires-Dist: gitpython
|
|
22
22
|
Requires-Dist: inflection
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"""任务基础类"""
|
|
2
|
+
import os
|
|
3
|
+
import json
|
|
4
|
+
from queue import Queue
|
|
5
|
+
from threading import Thread
|
|
6
|
+
from lbkit.log import Logger
|
|
7
|
+
from lbkit.errors import LiteBmcException
|
|
8
|
+
from lbkit import misc
|
|
9
|
+
from lbkit.tools import Tools
|
|
10
|
+
|
|
11
|
+
tools = Tools("comp_build")
|
|
12
|
+
log = Logger("comp_build")
|
|
13
|
+
|
|
14
|
+
class ConanPackage():
|
|
15
|
+
def __init__(self, node):
|
|
16
|
+
self.node = node
|
|
17
|
+
self.deps: dict[str, ConanPackage] = {}
|
|
18
|
+
self.build_deps: dict[str, ConanPackage] = {}
|
|
19
|
+
self.ref = node.get("ref")
|
|
20
|
+
self.pkg = self.ref.split("#")[0]
|
|
21
|
+
self.name = self.pkg.split("/")[0]
|
|
22
|
+
self.context = node.get("context")
|
|
23
|
+
self.building = False
|
|
24
|
+
self.is_host = self.context == "host"
|
|
25
|
+
binary = node.get("binary")
|
|
26
|
+
self.binary_exist = (binary in ["Cache"])
|
|
27
|
+
|
|
28
|
+
def append_dep(self, dep):
|
|
29
|
+
self.deps[dep.pkg] = dep
|
|
30
|
+
|
|
31
|
+
def append_build_dep(self, dep):
|
|
32
|
+
self.build_deps[dep.pkg] = dep
|
|
33
|
+
|
|
34
|
+
# 间接构建依赖更新为直接依赖
|
|
35
|
+
def update_indirect_build_dep(self):
|
|
36
|
+
deps = {}
|
|
37
|
+
for _, dep in self.build_deps.items():
|
|
38
|
+
sub_deps = dep.update_indirect_build_dep()
|
|
39
|
+
deps.update(sub_deps)
|
|
40
|
+
self.build_deps.update(deps)
|
|
41
|
+
return self.build_deps
|
|
42
|
+
|
|
43
|
+
@property
|
|
44
|
+
def options(self):
|
|
45
|
+
return self.node.get("options", {})
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def settings(self):
|
|
49
|
+
return self.node.get("settings", {})
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def default_options(self):
|
|
53
|
+
return self.node.get("default_options", {})
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class BuildConanParallel(object):
|
|
57
|
+
def __init__(self, graphinfo, lockfile, cmd, force_build):
|
|
58
|
+
self.queue = Queue()
|
|
59
|
+
self.cmd = ""
|
|
60
|
+
chunks = cmd.split()
|
|
61
|
+
skip = False
|
|
62
|
+
for chunk in chunks:
|
|
63
|
+
if skip:
|
|
64
|
+
skip = False
|
|
65
|
+
continue
|
|
66
|
+
if chunk in ["--user", "--channel", "--version", "--name"]:
|
|
67
|
+
skip = True
|
|
68
|
+
continue
|
|
69
|
+
self.cmd += f"{chunk} "
|
|
70
|
+
self.graphinfo = os.path.realpath(graphinfo)
|
|
71
|
+
self.lockfile = os.path.realpath(lockfile)
|
|
72
|
+
if not os.path.isfile(graphinfo):
|
|
73
|
+
raise LiteBmcException(f"graph file {graphinfo} not exist")
|
|
74
|
+
self.exception = None
|
|
75
|
+
self.force_build = force_build
|
|
76
|
+
|
|
77
|
+
def build_dep(self, cp: ConanPackage, options):
|
|
78
|
+
for name, value in cp.settings.items():
|
|
79
|
+
options += f" -s {name}={value}"
|
|
80
|
+
|
|
81
|
+
cmd = f"conan install --requires={cp.ref} {self.cmd} {options}"
|
|
82
|
+
if self.force_build:
|
|
83
|
+
cmd += f" --build=\"{cp.name}/*\""
|
|
84
|
+
cmd += " --build=missing"
|
|
85
|
+
cmd += f" --lockfile={self.lockfile}"
|
|
86
|
+
try:
|
|
87
|
+
log.info(f">>>> build {cp.ref} start")
|
|
88
|
+
log.debug(f">>>> {cmd}")
|
|
89
|
+
tools.exec(cmd, echo_cmd=False, log_name=f"{misc.LOG_DIR}/conan_{cp.name}.log")
|
|
90
|
+
log.success(f"<<<< build {cp.ref} finished")
|
|
91
|
+
except Exception as e:
|
|
92
|
+
self.exception = e
|
|
93
|
+
self.queue.put(cp)
|
|
94
|
+
|
|
95
|
+
def build(self):
|
|
96
|
+
with open(self.graphinfo, "r") as fp:
|
|
97
|
+
grapth = json.load(fp)
|
|
98
|
+
nodes = grapth.get("graph", {}).get("nodes", {})
|
|
99
|
+
packages: dict[str, ConanPackage] = {}
|
|
100
|
+
|
|
101
|
+
build_works = {}
|
|
102
|
+
for id, node in nodes.items():
|
|
103
|
+
if id == "0":
|
|
104
|
+
continue
|
|
105
|
+
cp = ConanPackage(node)
|
|
106
|
+
packages[cp.pkg] = cp
|
|
107
|
+
build_works[cp.name] = False
|
|
108
|
+
for id, node in nodes.items():
|
|
109
|
+
if id == "0":
|
|
110
|
+
continue
|
|
111
|
+
ref = node.get("ref")
|
|
112
|
+
if ref.startswith("litebmc/"):
|
|
113
|
+
continue
|
|
114
|
+
cp = packages[ref.split("#")[0]]
|
|
115
|
+
deps = node.get("dependencies", {})
|
|
116
|
+
for _, dep in deps.items():
|
|
117
|
+
dep_ref = dep.get("ref")
|
|
118
|
+
direct = dep.get("direct")
|
|
119
|
+
if not direct:
|
|
120
|
+
continue
|
|
121
|
+
dep_cp = packages[dep_ref]
|
|
122
|
+
if dep_cp.is_host:
|
|
123
|
+
cp.append_dep(dep_cp)
|
|
124
|
+
else:
|
|
125
|
+
cp.append_build_dep(dep_cp)
|
|
126
|
+
options = ""
|
|
127
|
+
for _, cp in packages.items():
|
|
128
|
+
for name, value in cp.options.items():
|
|
129
|
+
if value is None:
|
|
130
|
+
continue
|
|
131
|
+
def_val = cp.default_options.get(name)
|
|
132
|
+
conan_name = cp.pkg.split("@")[0]
|
|
133
|
+
if isinstance(def_val, bool):
|
|
134
|
+
if (def_val and "False" == value) or (not def_val and "True" == value):
|
|
135
|
+
options += f" -o {conan_name}:{name}={value}"
|
|
136
|
+
elif def_val != value:
|
|
137
|
+
options += f" -o {conan_name}:{name}={value}"
|
|
138
|
+
# 工具间接依赖变更为直接依赖
|
|
139
|
+
for name, pkg in packages.items():
|
|
140
|
+
pkg.update_indirect_build_dep()
|
|
141
|
+
wait_finished = 0
|
|
142
|
+
while True:
|
|
143
|
+
for _, cp in packages.items():
|
|
144
|
+
if wait_finished >= 4:
|
|
145
|
+
continue
|
|
146
|
+
if cp.ref.startswith("litebmc/"):
|
|
147
|
+
continue
|
|
148
|
+
# 如果是构建工具,不参与构建
|
|
149
|
+
if not cp.is_host:
|
|
150
|
+
continue
|
|
151
|
+
# 如果还有依赖未构建完成,不参与构建
|
|
152
|
+
if len(cp.deps) != 0:
|
|
153
|
+
continue
|
|
154
|
+
# 如果正在构建
|
|
155
|
+
if cp.building:
|
|
156
|
+
continue
|
|
157
|
+
# 相同名称的组件正在构建时不启动新的构建
|
|
158
|
+
if build_works[cp.name]:
|
|
159
|
+
continue
|
|
160
|
+
if not cp.binary_exist or self.force_build:
|
|
161
|
+
# 当依赖的构建工具存在正在构建的组件时不能构建
|
|
162
|
+
need_build = True
|
|
163
|
+
for _, dep in cp.build_deps.items():
|
|
164
|
+
# 正在构建且未构建出制品时
|
|
165
|
+
if not dep.binary_exist and dep.building:
|
|
166
|
+
need_build = False
|
|
167
|
+
break
|
|
168
|
+
if not need_build:
|
|
169
|
+
continue
|
|
170
|
+
cp.building = True
|
|
171
|
+
# 启动构建前将其依赖的构建工具置为正在构建
|
|
172
|
+
for _, dep in cp.build_deps.items():
|
|
173
|
+
dep.building = True
|
|
174
|
+
build_works[cp.name] = True
|
|
175
|
+
wait_finished += 1
|
|
176
|
+
thread = Thread(target=self.build_dep, args=(cp, options,))
|
|
177
|
+
thread.start()
|
|
178
|
+
else:
|
|
179
|
+
cp.building = True
|
|
180
|
+
build_works[cp.name] = True
|
|
181
|
+
wait_finished += 1
|
|
182
|
+
self.queue.put(cp)
|
|
183
|
+
if not wait_finished:
|
|
184
|
+
return
|
|
185
|
+
cp = self.queue.get()
|
|
186
|
+
if self.exception:
|
|
187
|
+
raise self.exception
|
|
188
|
+
build_works[cp.name] = False
|
|
189
|
+
wait_finished -= 1
|
|
190
|
+
for _, sub_cp in packages.items():
|
|
191
|
+
if sub_cp.deps.get(cp.pkg):
|
|
192
|
+
sub_cp.deps.pop(cp.pkg)
|
|
193
|
+
# 构建完成后,组件的构建依赖工具一定构建完成且制品存在
|
|
194
|
+
for _, dep in cp.build_deps.items():
|
|
195
|
+
dep.building = False
|
|
196
|
+
dep.binary_exist = True
|
|
197
|
+
|
|
@@ -224,19 +224,23 @@ class Command(object):
|
|
|
224
224
|
|
|
225
225
|
method(args[0][1:])
|
|
226
226
|
except KeyboardInterrupt as exc:
|
|
227
|
+
log.error("lbk exit with exception:")
|
|
227
228
|
log.error(exc)
|
|
228
229
|
ret_code = 0
|
|
229
230
|
except SystemExit as exc:
|
|
231
|
+
log.error("lbk exit with exception:")
|
|
230
232
|
if exc.code != 0:
|
|
231
233
|
log.error("Exiting with code: %d" % exc.code)
|
|
232
234
|
ret_code = exc.code
|
|
233
235
|
except (errors.LiteBmcException, errors.RunCommandException, errors.ArgException, errors.PackageConfigException, Exception, errors.OdfValidateException) as exc:
|
|
236
|
+
log.error("lbk exit with exception:")
|
|
234
237
|
if os.environ.get("LOG"):
|
|
235
238
|
print(traceback.format_exc())
|
|
236
239
|
ret_code = -1
|
|
237
240
|
msg = str(exc)
|
|
238
241
|
log.error(misc.Color.RED + msg + misc.Color.RESET_ALL)
|
|
239
242
|
except errors.TestException:
|
|
243
|
+
log.error("lbk exit with exception:")
|
|
240
244
|
log.error(exc)
|
|
241
245
|
ret_code = -1
|
|
242
246
|
|
|
@@ -67,8 +67,8 @@ class CodeGen(object):
|
|
|
67
67
|
# 默认的自动生成工具版本号为2
|
|
68
68
|
parser.add_argument("-cv", "--codegen_version", help=f'''must less than or equal to {__version__}, default: 2
|
|
69
69
|
description of changes:
|
|
70
|
-
3: compatible with
|
|
71
|
-
2: compatible with
|
|
70
|
+
3: compatible with lb_base/0.7.x
|
|
71
|
+
2: compatible with lb_base/0.6.x
|
|
72
72
|
''',
|
|
73
73
|
type=int, default=2)
|
|
74
74
|
parser.add_argument("-d", "--directory", help='generate code directory', default=".")
|
|
@@ -83,7 +83,7 @@ class CodeGen(object):
|
|
|
83
83
|
if not os.path.isfile(args.cdf_file):
|
|
84
84
|
raise ArgException(f"argument -c/--cdf_file: {args.cdf_file} not exist")
|
|
85
85
|
configs = Helper.read_yaml(args.cdf_file, "codegen", [])
|
|
86
|
-
# 为保障兼容,package.yml未指定版本号的,默认使用2,该版本配套
|
|
86
|
+
# 为保障兼容,package.yml未指定版本号的,默认使用2,该版本配套lb_base/0.6.0版本,其LBProperty无set/get成员
|
|
87
87
|
self.codegen_version = Helper.read_yaml(args.cdf_file, "codegen_version", 2)
|
|
88
88
|
for cfg in configs:
|
|
89
89
|
file = cfg.get("file")
|
|
@@ -544,8 +544,8 @@ CTYPE_OBJS = {
|
|
|
544
544
|
"string": CTypeBase(
|
|
545
545
|
["<const>gchar *<arg_name>"],
|
|
546
546
|
["gchar **<arg_name>"],
|
|
547
|
-
["
|
|
548
|
-
["<arg_out> =
|
|
547
|
+
["lb_free_p((void **)&<arg_name>)"],
|
|
548
|
+
["<arg_out> = lb_string_encode(<arg_name>)"],
|
|
549
549
|
["<arg_in> = g_strdup(g_variant_get_string(<arg_name>, NULL))"],
|
|
550
550
|
StringValidator("^.*$"),
|
|
551
551
|
["const gchar *<arg_name>"],
|
|
@@ -555,8 +555,8 @@ CTYPE_OBJS = {
|
|
|
555
555
|
"object_path": CTypeBase(
|
|
556
556
|
["<const>gchar *<arg_name>"],
|
|
557
557
|
["gchar **<arg_name>"],
|
|
558
|
-
["
|
|
559
|
-
["<arg_out> =
|
|
558
|
+
["lb_free_p((void **)&<arg_name>)"],
|
|
559
|
+
["<arg_out> = lb_object_path_encode(<arg_name>)"],
|
|
560
560
|
["<arg_in> = g_strdup(g_variant_get_string(<arg_name>, NULL))"],
|
|
561
561
|
StringValidator("^(/[A-Z0-9a-z_]+)*$"),
|
|
562
562
|
["const gchar *<arg_name>"],
|
|
@@ -566,8 +566,8 @@ CTYPE_OBJS = {
|
|
|
566
566
|
"signature": CTypeBase(
|
|
567
567
|
["<const>gchar *<arg_name>"],
|
|
568
568
|
["gchar **<arg_name>"],
|
|
569
|
-
["
|
|
570
|
-
["<arg_out> =
|
|
569
|
+
["lb_free_p((void **)&<arg_name>)"],
|
|
570
|
+
["<arg_out> = lb_signature_encode(<arg_name>)"],
|
|
571
571
|
["<arg_in> = g_strdup(g_variant_get_string(<arg_name>, NULL))"],
|
|
572
572
|
StringValidator("^([abynqiuxtdsogv\\\\{\\\\}\\\\(\\\\)])+$"),
|
|
573
573
|
["const gchar *<arg_name>"],
|
|
@@ -577,7 +577,7 @@ CTYPE_OBJS = {
|
|
|
577
577
|
"variant": CTypeBase(
|
|
578
578
|
["GVariant *<arg_name>"],
|
|
579
579
|
["GVariant **<arg_name>"],
|
|
580
|
-
["
|
|
580
|
+
["lb_unref_p((GVariant **)&<arg_name>)"],
|
|
581
581
|
["g_variant_take_ref(<arg_name>)", "<arg_out> = g_variant_new_variant(<arg_name>)"],
|
|
582
582
|
["<arg_in> = g_variant_get_variant(<arg_name>)"],
|
|
583
583
|
IdfValidator()
|
|
@@ -585,121 +585,121 @@ CTYPE_OBJS = {
|
|
|
585
585
|
"array[boolean]": CTypeBase(
|
|
586
586
|
["gsize n_<arg_name>" ,"<const>gboolean *<arg_name>"],
|
|
587
587
|
["gsize *n_<arg_name>" ,"gboolean **<arg_name>"],
|
|
588
|
-
["
|
|
589
|
-
["<arg_out> =
|
|
590
|
-
["<arg_in> =
|
|
588
|
+
["lb_free_p((void **)&<arg_name>)"],
|
|
589
|
+
["<arg_out> = lb_array_boolean_encode(<arg_name>, n_<arg_name>)"],
|
|
590
|
+
["<arg_in> = lb_array_boolean_decode(<arg_name>, &n_<arg_in>)"],
|
|
591
591
|
BoolArrayValidator()
|
|
592
592
|
),
|
|
593
593
|
"array[byte]": CTypeBase(
|
|
594
594
|
["gsize n_<arg_name>" ,"<const>guint8 *<arg_name>"],
|
|
595
595
|
["gsize *n_<arg_name>" ,"guint8 **<arg_name>"],
|
|
596
|
-
["
|
|
597
|
-
["<arg_out> =
|
|
598
|
-
["<arg_in> =
|
|
596
|
+
["lb_free_p((void **)&<arg_name>)"],
|
|
597
|
+
["<arg_out> = lb_array_byte_encode(<arg_name>, n_<arg_name>)"],
|
|
598
|
+
["<arg_in> = lb_array_byte_decode(<arg_name>, &n_<arg_in>)"],
|
|
599
599
|
IntegerArrayValidator(0xff, 0)
|
|
600
600
|
),
|
|
601
601
|
"array[int16]": CTypeBase(
|
|
602
602
|
["gsize n_<arg_name>" ,"<const>gint16 *<arg_name>"],
|
|
603
603
|
["gsize *n_<arg_name>" ,"gint16 **<arg_name>"],
|
|
604
|
-
["
|
|
605
|
-
["<arg_out> =
|
|
606
|
-
["<arg_in> =
|
|
604
|
+
["lb_free_p((void **)&<arg_name>)"],
|
|
605
|
+
["<arg_out> = lb_array_int16_encode(<arg_name>, n_<arg_name>)"],
|
|
606
|
+
["<arg_in> = lb_array_int16_decode(<arg_name>, &n_<arg_in>)"],
|
|
607
607
|
IntegerArrayValidator(0x7fff, -(0x8000), True)
|
|
608
608
|
),
|
|
609
609
|
"array[uint16]": CTypeBase(
|
|
610
610
|
["gsize n_<arg_name>" ,"<const>guint16 *<arg_name>"],
|
|
611
611
|
["gsize *n_<arg_name>" ,"guint16 **<arg_name>"],
|
|
612
|
-
["
|
|
613
|
-
["<arg_out> =
|
|
614
|
-
["<arg_in> =
|
|
612
|
+
["lb_free_p((void **)&<arg_name>)"],
|
|
613
|
+
["<arg_out> = lb_array_uint16_encode(<arg_name>, n_<arg_name>)"],
|
|
614
|
+
["<arg_in> = lb_array_uint16_decode(<arg_name>, &n_<arg_in>)"],
|
|
615
615
|
IntegerArrayValidator(0xffff, 0)
|
|
616
616
|
),
|
|
617
617
|
"array[int32]": CTypeBase(
|
|
618
618
|
["gsize n_<arg_name>" ,"<const>gint32 *<arg_name>"],
|
|
619
619
|
["gsize *n_<arg_name>" ,"gint32 **<arg_name>"],
|
|
620
|
-
["
|
|
621
|
-
["<arg_out> =
|
|
622
|
-
["<arg_in> =
|
|
620
|
+
["lb_free_p((void **)&<arg_name>)"],
|
|
621
|
+
["<arg_out> = lb_array_int32_encode(<arg_name>, n_<arg_name>)"],
|
|
622
|
+
["<arg_in> = lb_array_int32_decode(<arg_name>, &n_<arg_in>)"],
|
|
623
623
|
IntegerArrayValidator(0x7fff_ffff, -(0x80000000), True)
|
|
624
624
|
),
|
|
625
625
|
"array[uint32]": CTypeBase(
|
|
626
626
|
["gsize n_<arg_name>" ,"<const>guint32 *<arg_name>"],
|
|
627
627
|
["gsize *n_<arg_name>" ,"guint32 **<arg_name>"],
|
|
628
|
-
["
|
|
629
|
-
["<arg_out> =
|
|
630
|
-
["<arg_in> =
|
|
628
|
+
["lb_free_p((void **)&<arg_name>)"],
|
|
629
|
+
["<arg_out> = lb_array_uint32_encode(<arg_name>, n_<arg_name>)"],
|
|
630
|
+
["<arg_in> = lb_array_uint32_decode(<arg_name>, &n_<arg_in>)"],
|
|
631
631
|
IntegerArrayValidator(0xffff_ffff, 0)
|
|
632
632
|
),
|
|
633
633
|
"array[int64]": CTypeBase(
|
|
634
634
|
["gsize n_<arg_name>" ,"<const>gint64 *<arg_name>"],
|
|
635
635
|
["gsize *n_<arg_name>" ,"gint64 **<arg_name>"],
|
|
636
|
-
["
|
|
637
|
-
["<arg_out> =
|
|
638
|
-
["<arg_in> =
|
|
636
|
+
["lb_free_p((void **)&<arg_name>)"],
|
|
637
|
+
["<arg_out> = lb_array_int64_encode(<arg_name>, n_<arg_name>)"],
|
|
638
|
+
["<arg_in> = lb_array_int64_decode(<arg_name>, &n_<arg_in>)"],
|
|
639
639
|
IntegerArrayValidator(0x7fff_ffff_ffff_ffff, -(0x8000_0000_0000_0000), True)
|
|
640
640
|
),
|
|
641
641
|
"array[uint64]": CTypeBase(
|
|
642
642
|
["gsize n_<arg_name>" ,"<const>guint64 *<arg_name>"],
|
|
643
643
|
["gsize *n_<arg_name>" ,"guint64 **<arg_name>"],
|
|
644
|
-
["
|
|
645
|
-
["<arg_out> =
|
|
646
|
-
["<arg_in> =
|
|
644
|
+
["lb_free_p((void **)&<arg_name>)"],
|
|
645
|
+
["<arg_out> = lb_array_uint64_encode(<arg_name>, n_<arg_name>)"],
|
|
646
|
+
["<arg_in> = lb_array_uint64_decode(<arg_name>, &n_<arg_in>)"],
|
|
647
647
|
IntegerArrayValidator(0xffff_ffff_ffff_ffff, 0)
|
|
648
648
|
),
|
|
649
649
|
"array[ssize]": CTypeBase(
|
|
650
650
|
["gsize n_<arg_name>" ,"<const>gssize *<arg_name>"],
|
|
651
651
|
["gsize *n_<arg_name>" ,"gssize **<arg_name>"],
|
|
652
|
-
["
|
|
653
|
-
["<arg_out> =
|
|
654
|
-
["<arg_in> =
|
|
652
|
+
["lb_free_p((void **)&<arg_name>)"],
|
|
653
|
+
["<arg_out> = lb_array_int64_encode(<arg_name>, n_<arg_name>)"],
|
|
654
|
+
["<arg_in> = lb_array_int64_decode(<arg_name>, &n_<arg_in>)"],
|
|
655
655
|
IntegerArrayValidator(0x7fff_ffff_ffff_ffff, -(0x8000_0000_0000_0000), True)
|
|
656
656
|
),
|
|
657
657
|
"array[size]": CTypeBase(
|
|
658
658
|
["gsize n_<arg_name>" ,"<const>gsize *<arg_name>"],
|
|
659
659
|
["gsize *n_<arg_name>" ,"gsize **<arg_name>"],
|
|
660
|
-
["
|
|
661
|
-
["<arg_out> =
|
|
662
|
-
["<arg_in> =
|
|
660
|
+
["lb_free_p((void **)&<arg_name>)"],
|
|
661
|
+
["<arg_out> = lb_array_uint64_encode(<arg_name>, n_<arg_name>)"],
|
|
662
|
+
["<arg_in> = lb_array_uint64_decode(<arg_name>, &n_<arg_in>)"],
|
|
663
663
|
IntegerArrayValidator(0xffff_ffff_ffff_ffff, 0)
|
|
664
664
|
),
|
|
665
665
|
"array[double]": CTypeBase(
|
|
666
666
|
["gsize n_<arg_name>" ,"<const>gdouble *<arg_name>"],
|
|
667
667
|
["gsize *n_<arg_name>" ,"gdouble **<arg_name>"],
|
|
668
|
-
["
|
|
669
|
-
["<arg_out> =
|
|
670
|
-
["<arg_in> =
|
|
668
|
+
["lb_free_p((void **)&<arg_name>)"],
|
|
669
|
+
["<arg_out> = lb_array_double_encode(<arg_name>, n_<arg_name>)"],
|
|
670
|
+
["<arg_in> = lb_array_double_decode(<arg_name>, &n_<arg_in>)"],
|
|
671
671
|
FloatArrayValidator()
|
|
672
672
|
),
|
|
673
673
|
"array[unixfd]": CTypeBase(
|
|
674
674
|
["gsize n_<arg_name>" ,"<const>gint32 *<arg_name>"],
|
|
675
675
|
["gsize *n_<arg_name>" ,"gint32 **<arg_name>"],
|
|
676
|
-
["
|
|
677
|
-
["<arg_out> =
|
|
678
|
-
["<arg_in> =
|
|
676
|
+
["lb_free_p((void **)&<arg_name>)"],
|
|
677
|
+
["<arg_out> = lb_array_handle_encode(<arg_name>, n_<arg_name>)"],
|
|
678
|
+
["<arg_in> = lb_array_handle_decode(<arg_name>, &n_<arg_in>)"],
|
|
679
679
|
IntegerArrayValidator(0x7fff_ffff_ffff_ffff, 0, True)
|
|
680
680
|
),
|
|
681
681
|
"array[string]": CTypeBase(
|
|
682
682
|
["gchar *<const>*<arg_name>"],
|
|
683
683
|
["gchar ***<arg_name>"],
|
|
684
|
-
["
|
|
685
|
-
["<arg_out> =
|
|
686
|
-
["<arg_in> =
|
|
684
|
+
["lb_strfreev_p(&<arg_name>)"],
|
|
685
|
+
["<arg_out> = lb_array_string_encode(<arg_name>)"],
|
|
686
|
+
["<arg_in> = lb_array_string_decode(<arg_name>)"],
|
|
687
687
|
StringArrayValidator("^.*$")
|
|
688
688
|
),
|
|
689
689
|
"array[object_path]": CTypeBase(
|
|
690
690
|
["gchar *<const>*<arg_name>"],
|
|
691
691
|
["gchar ***<arg_name>"],
|
|
692
|
-
["
|
|
693
|
-
["<arg_out> =
|
|
694
|
-
["<arg_in> =
|
|
692
|
+
["lb_strfreev_p(&<arg_name>)"],
|
|
693
|
+
["<arg_out> = lb_array_object_path_encode(<arg_name>)"],
|
|
694
|
+
["<arg_in> = lb_array_object_path_decode(<arg_name>)"],
|
|
695
695
|
StringArrayValidator("^(/[A-Z0-9a-z_]+)*$")
|
|
696
696
|
),
|
|
697
697
|
"array[signature]": CTypeBase(
|
|
698
698
|
["gchar *<const>*<arg_name>"],
|
|
699
699
|
["gchar ***<arg_name>"],
|
|
700
|
-
["
|
|
701
|
-
["<arg_out> =
|
|
702
|
-
["<arg_in> =
|
|
700
|
+
["lb_strfreev_p(&<arg_name>)"],
|
|
701
|
+
["<arg_out> = lb_array_signature_encode(<arg_name>)"],
|
|
702
|
+
["<arg_in> = lb_array_signature_decode(<arg_name>)"],
|
|
703
703
|
StringArrayValidator("^([abynqiuxtdsogv\\\\{\\\\}\\\\(\\\\)])+$")
|
|
704
704
|
)
|
|
705
705
|
}
|
|
@@ -366,7 +366,7 @@ class IdfCtypeRender():
|
|
|
366
366
|
_, stru_name = get_intfname_and_ctype(match.group(2))
|
|
367
367
|
if match.group(1) == "enum":
|
|
368
368
|
if is_array:
|
|
369
|
-
return [f"
|
|
369
|
+
return [f"lb_free_p((void **)&<arg_name>)"]
|
|
370
370
|
return []
|
|
371
371
|
else:
|
|
372
372
|
if is_array:
|
|
@@ -587,17 +587,17 @@ class IdfProperty(IdfCtypeRender):
|
|
|
587
587
|
|
|
588
588
|
c_flags = []
|
|
589
589
|
if self.private:
|
|
590
|
-
c_flags.append("
|
|
590
|
+
c_flags.append("LB_FLAGS_PROPERTY_PRIVATE")
|
|
591
591
|
elif "const" in flags:
|
|
592
|
-
c_flags.append("
|
|
592
|
+
c_flags.append("LB_FLAGS_PROPERTY_EMIT_CONST")
|
|
593
593
|
elif "emits_false" in flags:
|
|
594
|
-
c_flags.append("
|
|
594
|
+
c_flags.append("LB_FLAGS_PROPERTY_EMIT_FALSE")
|
|
595
595
|
elif "emits_invalidation" in flags:
|
|
596
|
-
c_flags.append("
|
|
596
|
+
c_flags.append("LB_FLAGS_PROPERTY_EMIT_INVALIDATES")
|
|
597
597
|
else:
|
|
598
|
-
c_flags.append("
|
|
598
|
+
c_flags.append("LB_FLAGS_PROPERTY_EMIT_TRUE")
|
|
599
599
|
if self.deprecated:
|
|
600
|
-
c_flags.append("
|
|
600
|
+
c_flags.append("LB_FLAGS_PROPERTY_DEPRECATED")
|
|
601
601
|
if len(c_flags) == 0:
|
|
602
602
|
self.desc_flags = "0"
|
|
603
603
|
else:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#include "
|
|
1
|
+
#include "lb_base.h"
|
|
2
2
|
#include "${intf.name}.h"
|
|
3
3
|
|
|
4
4
|
<% class_name = intf.alias + "_Cli"
|
|
@@ -25,7 +25,7 @@ gint ${class_name}_set_${prop.name}(const ${class_name} *object,
|
|
|
25
25
|
% for line in prop.encode_func():
|
|
26
26
|
${line.replace("<arg_out>", "tmp").replace("n_<arg_name>", "n_" + prop.name).replace("<arg_name>", prop.name)};
|
|
27
27
|
% endfor
|
|
28
|
-
return
|
|
28
|
+
return lb_impl.write_property((LBO *)object, &${properties}.${prop.name}, tmp, error);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
% endif
|
|
@@ -52,7 +52,7 @@ gint ${class_name}_get_${prop.name}(const ${class_name} *object, ${", ".join(pro
|
|
|
52
52
|
% endfor
|
|
53
53
|
GVariant *out = NULL;
|
|
54
54
|
|
|
55
|
-
gint ret =
|
|
55
|
+
gint ret = lb_impl.read_property((LBO *)object, &${properties}.${prop.name}, &out, error);
|
|
56
56
|
if (ret == 0 && out) {
|
|
57
57
|
% for line in prop.decode_func():
|
|
58
58
|
${line.replace("<arg_in>", "tmp_value").replace("<arg_name>", "out")};
|
|
@@ -98,32 +98,32 @@ int ${class_name}_Call_${method.name}(const ${class_name} *object,
|
|
|
98
98
|
% if len(method.parameters.parameters) == 0:
|
|
99
99
|
void *req = NULL;
|
|
100
100
|
% endif
|
|
101
|
-
return
|
|
101
|
+
return lb_impl.call_method((LBO *)object, (const LBMethod *)&${method_processer}->${method.name},
|
|
102
102
|
(void *)req, (void **)rsp, timeout, error);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
% endfor
|
|
106
|
-
static
|
|
107
|
-
static void _${class_name}_destroy(
|
|
106
|
+
static LBO *_${class_name}_create(const gchar *obj_name, gpointer opaque);
|
|
107
|
+
static void _${class_name}_destroy(LBO *obj);
|
|
108
108
|
|
|
109
|
-
static
|
|
109
|
+
static LBInterface _${class_name}_interface = {
|
|
110
110
|
.create = _${class_name}_create,
|
|
111
111
|
.destroy = _${class_name}_destroy,
|
|
112
112
|
.is_remote = 1,
|
|
113
113
|
.name = "${intf.name}",
|
|
114
|
-
.properties = (
|
|
115
|
-
.interface = NULL, /* load from usr/share/dbus-1/interfaces/${intf.name}.xml by
|
|
114
|
+
.properties = (LBProperty *)&${properties},
|
|
115
|
+
.interface = NULL, /* load from usr/share/dbus-1/interfaces/${intf.name}.xml by lb_init */
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* @brief 销毁对象
|
|
120
120
|
*
|
|
121
|
-
* @param
|
|
121
|
+
* @param lb_obj 待销毁的对象句柄
|
|
122
122
|
*/
|
|
123
|
-
static void _${class_name}_destroy(
|
|
123
|
+
static void _${class_name}_destroy(LBO *lb_obj)
|
|
124
124
|
{
|
|
125
|
-
g_assert(
|
|
126
|
-
${class_name} *obj = (${class_name} *)
|
|
125
|
+
g_assert(lb_obj);
|
|
126
|
+
${class_name} *obj = (${class_name} *)lb_obj;
|
|
127
127
|
g_rec_mutex_clear(obj->_base.lock);
|
|
128
128
|
g_free(obj->_base.lock);
|
|
129
129
|
${intf.alias}_clean(obj);
|
|
@@ -136,16 +136,16 @@ static void _${class_name}_destroy(GclObject *gcl_obj)
|
|
|
136
136
|
* @param obj_name 对象名,需要由调用者分配内存
|
|
137
137
|
* @param opaque 上层应用需要写入对象的用户数据,由上层应用使用
|
|
138
138
|
*/
|
|
139
|
-
static
|
|
139
|
+
static LBO *_${class_name}_create(const gchar *obj_name, gpointer opaque)
|
|
140
140
|
{
|
|
141
141
|
${class_name} *obj = g_new0(${class_name}, 1);
|
|
142
|
-
memcpy(obj->_base.magic,
|
|
142
|
+
memcpy(obj->_base.magic, LB_MAGIC, strlen(LB_MAGIC) + 1);
|
|
143
143
|
obj->_base.lock = g_new0(GRecMutex, 1);
|
|
144
144
|
g_rec_mutex_init(obj->_base.lock);
|
|
145
145
|
obj->_base.name = obj_name;
|
|
146
146
|
obj->_base.intf = &_${class_name}_interface;
|
|
147
147
|
obj->_base.opaque = opaque;
|
|
148
|
-
return (
|
|
148
|
+
return (LBO *)obj;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
% for signal in intf.signals:
|
|
@@ -157,9 +157,9 @@ guint ${class_name}_Subscribe_${signal.name}(${class_name}_${signal.name}_Signal
|
|
|
157
157
|
const gchar *bus_name, const gchar *object_path, const gchar *arg0, gpointer user_data)
|
|
158
158
|
% endif
|
|
159
159
|
{
|
|
160
|
-
return
|
|
161
|
-
(const
|
|
162
|
-
object_path, arg0, (
|
|
160
|
+
return lb_impl.subscribe_signal(&_${class_name}_interface, bus_name,
|
|
161
|
+
(const LBSignal *)&${signal_processer}->${signal.name},
|
|
162
|
+
object_path, arg0, (lbo_signal_handler)handler, user_data);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
% if signal.deprecated:
|
|
@@ -168,11 +168,11 @@ __attribute__((__deprecated__)) void ${class_name}_Unsubscribe_${signal.name}(gu
|
|
|
168
168
|
void ${class_name}_Unsubscribe_${signal.name}(guint *id)
|
|
169
169
|
% endif
|
|
170
170
|
{
|
|
171
|
-
return
|
|
171
|
+
return lb_impl.unsubscribe_signal(id);
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
% endfor
|
|
175
|
-
|
|
175
|
+
LBInterface *${class_name}_interface(void)
|
|
176
176
|
{
|
|
177
177
|
return &_${class_name}_interface;
|
|
178
178
|
}
|
|
@@ -188,13 +188,13 @@ static void __attribute__((constructor(150))) ${class_name}_register(void)
|
|
|
188
188
|
${signal_processer} = ${intf.alias}_signals();
|
|
189
189
|
|
|
190
190
|
// 从公共库中复制方法处理函数
|
|
191
|
-
_${class_name}_interface.methods = (
|
|
192
|
-
_${class_name}_interface.signals = (
|
|
191
|
+
_${class_name}_interface.methods = (LBMethod *)${intf.alias}_methods();
|
|
192
|
+
_${class_name}_interface.signals = (LBSignal *)${intf.alias}_signals();
|
|
193
193
|
${method_processer} = ${intf.alias}_methods();
|
|
194
194
|
|
|
195
195
|
// 从公共库中复制属性信息
|
|
196
196
|
memcpy(&${properties}, ${intf.alias}_properties_const(), sizeof(${properties}));
|
|
197
|
-
|
|
197
|
+
lb_interface_register(&_${class_name}_interface,
|
|
198
198
|
"${intf.introspect_xml_sha256}",
|
|
199
199
|
"/usr/share/dbus-1/interfaces/${intf.name}.xml");
|
|
200
200
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#include <glib-2.0/glib.h>
|
|
5
5
|
#include <glib-2.0/gio/gio.h>
|
|
6
|
-
#include "
|
|
6
|
+
#include "lb_base.h"
|
|
7
7
|
#include "public/${intf.name}.h"
|
|
8
8
|
|
|
9
9
|
#ifdef __cplusplus
|
|
@@ -110,7 +110,7 @@ void ${class_name}_Unsubscribe_${signal.name}(guint *id);
|
|
|
110
110
|
% endfor
|
|
111
111
|
|
|
112
112
|
${class_name}_Properties *${class_name}_properties(void);
|
|
113
|
-
|
|
113
|
+
LBInterface *${class_name}_interface(void);
|
|
114
114
|
#define ${class_name.upper()}_INTERFACE ${class_name}_interface()
|
|
115
115
|
|
|
116
116
|
#ifdef __cplusplus
|