1 |
commit: 164bf869e338666239e7c1b9cdd6c399acaa9c7c |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Jan 2 00:05:22 2022 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Jan 2 00:28:06 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=164bf869 |
7 |
|
8 |
dev-lang/jerryscript: 2.4.0-r4 using python-single-r1 |
9 |
|
10 |
Closes: https://bugs.gentoo.org/830388 |
11 |
Package-Manager: Portage-3.0.30, Repoman-3.0.3 |
12 |
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> |
13 |
|
14 |
.../files/jerryscript-2.4.0-python3-r4.patch | 236 +++++++++++++++++++++ |
15 |
dev-lang/jerryscript/jerryscript-2.4.0-r4.ebuild | 74 +++++++ |
16 |
2 files changed, 310 insertions(+) |
17 |
|
18 |
diff --git a/dev-lang/jerryscript/files/jerryscript-2.4.0-python3-r4.patch b/dev-lang/jerryscript/files/jerryscript-2.4.0-python3-r4.patch |
19 |
new file mode 100644 |
20 |
index 000000000000..92198f3901d4 |
21 |
--- /dev/null |
22 |
+++ b/dev-lang/jerryscript/files/jerryscript-2.4.0-python3-r4.patch |
23 |
@@ -0,0 +1,236 @@ |
24 |
+From 22d8b904d85e548aa06d2d665aeaaee510a2435a Mon Sep 17 00:00:00 2001 |
25 |
+From: Zac Medico <zmedico@×××××.com> |
26 |
+Date: Sun, 23 May 2021 13:46:30 -0700 |
27 |
+Subject: [PATCH] Python debugger support for Python 3 (in addition to Python |
28 |
+ 2) |
29 |
+ |
30 |
+- Added safe_ord compatibility to pass through int arguments |
31 |
+- Fixed JerryDebugger to decode bytes as utf8 strings when necessary |
32 |
+- Fixed WebSocket send_message method to use packed_data[0:1] bytes slice |
33 |
+ |
34 |
+JerryScript-DCO-1.0-Signed-off-by: Zac Medico <zmedico@×××××.com> |
35 |
+--- |
36 |
+ jerry-debugger/jerry_client_main.py | 82 ++++++++++++++---------- |
37 |
+ jerry-debugger/jerry_client_rawpacket.py | 13 +++- |
38 |
+ jerry-debugger/jerry_client_websocket.py | 15 ++++- |
39 |
+ 3 files changed, 74 insertions(+), 36 deletions(-) |
40 |
+ |
41 |
+diff --git a/jerry-debugger/jerry_client_main.py b/jerry-debugger/jerry_client_main.py |
42 |
+index e65d0e14..ee3ffd26 100644 |
43 |
+--- a/jerry-debugger/jerry_client_main.py |
44 |
++++ b/jerry-debugger/jerry_client_main.py |
45 |
+@@ -151,2 +151,11 @@ def arguments_parse(): |
46 |
+ |
47 |
++if sys.version_info.major >= 3: |
48 |
++ def safe_ord(c): |
49 |
++ if isinstance(c, int): |
50 |
++ return c |
51 |
++ return ord(c) |
52 |
++else: |
53 |
++ safe_ord = ord |
54 |
++ |
55 |
++ |
56 |
+ class JerryBreakpoint(object): |
57 |
+@@ -309,8 +318,8 @@ class JerryDebugger(object): |
58 |
+ |
59 |
+- if len(result) != config_size or ord(result[0]) != JERRY_DEBUGGER_CONFIGURATION: |
60 |
++ if len(result) != config_size or safe_ord(result[0]) != JERRY_DEBUGGER_CONFIGURATION: |
61 |
+ raise Exception("Unexpected configuration") |
62 |
+ |
63 |
+- self.little_endian = ord(result[1]) & JERRY_DEBUGGER_LITTLE_ENDIAN |
64 |
+- self.max_message_size = ord(result[6]) |
65 |
+- self.cp_size = ord(result[7]) |
66 |
++ self.little_endian = safe_ord(result[1]) & JERRY_DEBUGGER_LITTLE_ENDIAN |
67 |
++ self.max_message_size = safe_ord(result[6]) |
68 |
++ self.cp_size = safe_ord(result[7]) |
69 |
+ |
70 |
+@@ -402,3 +411,3 @@ class JerryDebugger(object): |
71 |
+ if args != "pending": |
72 |
+- for i in self.active_breakpoint_list.values(): |
73 |
++ for i in list(self.active_breakpoint_list.values()): |
74 |
+ breakpoint = self.active_breakpoint_list[i.active_index] |
75 |
+@@ -563,2 +572,3 @@ class JerryDebugger(object): |
76 |
+ def _send_string(self, args, message_type, index=0): |
77 |
++ args = args.encode("utf8") |
78 |
+ |
79 |
+@@ -686,3 +696,3 @@ class JerryDebugger(object): |
80 |
+ |
81 |
+- buffer_type = ord(data[0]) |
82 |
++ buffer_type = safe_ord(data[0]) |
83 |
+ buffer_size = len(data) -1 |
84 |
+@@ -740,6 +750,6 @@ class JerryDebugger(object): |
85 |
+ elif buffer_type == JERRY_DEBUGGER_EXCEPTION_STR: |
86 |
+- self.exception_string += data[1:] |
87 |
++ self.exception_string += data[1:].decode("utf8") |
88 |
+ |
89 |
+ elif buffer_type == JERRY_DEBUGGER_EXCEPTION_STR_END: |
90 |
+- self.exception_string += data[1:] |
91 |
++ self.exception_string += data[1:].decode("utf8") |
92 |
+ |
93 |
+@@ -810,3 +820,3 @@ class JerryDebugger(object): |
94 |
+ elif buffer_type in [JERRY_DEBUGGER_SCOPE_VARIABLES, JERRY_DEBUGGER_SCOPE_VARIABLES_END]: |
95 |
+- self.scope_vars += "".join(data[1:]) |
96 |
++ self.scope_vars += "".join(data[1:].decode("utf8")) |
97 |
+ |
98 |
+@@ -866,5 +876,5 @@ class JerryDebugger(object): |
99 |
+ def _parse_source(self, data): |
100 |
+- source_code = "" |
101 |
+- source_code_name = "" |
102 |
+- function_name = "" |
103 |
++ source_code = b"" |
104 |
++ source_code_name = b"" |
105 |
++ function_name = b"" |
106 |
+ stack = [{"line": 1, |
107 |
+@@ -881,3 +891,3 @@ class JerryDebugger(object): |
108 |
+ |
109 |
+- buffer_type = ord(data[0]) |
110 |
++ buffer_type = safe_ord(data[0]) |
111 |
+ buffer_size = len(data) - 1 |
112 |
+@@ -905,10 +915,10 @@ class JerryDebugger(object): |
113 |
+ |
114 |
+- stack.append({"source": source_code, |
115 |
+- "source_name": source_code_name, |
116 |
++ stack.append({"source": source_code.decode("utf8"), |
117 |
++ "source_name": source_code_name.decode("utf8"), |
118 |
+ "line": position[0], |
119 |
+ "column": position[1], |
120 |
+- "name": function_name, |
121 |
++ "name": function_name.decode("utf8"), |
122 |
+ "lines": [], |
123 |
+ "offsets": []}) |
124 |
+- function_name = "" |
125 |
++ function_name = b"" |
126 |
+ |
127 |
+@@ -939,4 +949,4 @@ class JerryDebugger(object): |
128 |
+ if not stack: |
129 |
+- func_desc["source"] = source_code |
130 |
+- func_desc["source_name"] = source_code_name |
131 |
++ func_desc["source"] = source_code.decode("utf8") |
132 |
++ func_desc["source_name"] = source_code_name.decode("utf8") |
133 |
+ |
134 |
+@@ -991,3 +1001,3 @@ class JerryDebugger(object): |
135 |
+ |
136 |
+- for breakpoint_index, breakpoint in bp_list.items(): |
137 |
++ for breakpoint_index, breakpoint in list(bp_list.items()): |
138 |
+ source_lines = 0 |
139 |
+@@ -1134,3 +1144,3 @@ class JerryDebugger(object): |
140 |
+ JERRY_DEBUGGER_OUTPUT_RESULT_END]: |
141 |
+- subtype = ord(data[-1]) |
142 |
++ subtype = safe_ord(data[-1]) |
143 |
+ message += data[1:-1] |
144 |
+@@ -1141,3 +1151,3 @@ class JerryDebugger(object): |
145 |
+ data = self.channel.get_message(True) |
146 |
+- buffer_type = ord(data[0]) |
147 |
++ buffer_type = safe_ord(data[0]) |
148 |
+ # Checks if the next frame would be an invalid data frame. |
149 |
+@@ -1153,4 +1163,4 @@ class JerryDebugger(object): |
150 |
+ message = self.current_out + message |
151 |
+- lines = message.split("\n") |
152 |
+- self.current_out = lines.pop() |
153 |
++ lines = message.decode("utf8").split("\n") |
154 |
++ self.current_out = lines.pop().encode("utf8") |
155 |
+ |
156 |
+@@ -1162,4 +1172,4 @@ class JerryDebugger(object): |
157 |
+ message = self.current_log + message |
158 |
+- lines = message.split("\n") |
159 |
+- self.current_log = lines.pop() |
160 |
++ lines = message.decode("utf8").split("\n") |
161 |
++ self.current_log = lines.pop().encode("utf8") |
162 |
+ |
163 |
+@@ -1167,2 +1177,3 @@ class JerryDebugger(object): |
164 |
+ |
165 |
++ message = message.decode("utf8") |
166 |
+ if not message.endswith("\n"): |
167 |
+@@ -1176,2 +1187,5 @@ class JerryDebugger(object): |
168 |
+ return "%strace: %s%s" % (self.blue, self.nocolor, message) |
169 |
++ else: |
170 |
++ message = message.decode("utf8") |
171 |
++ |
172 |
+ |
173 |
+@@ -1195,3 +1209,3 @@ class JerryDebugger(object): |
174 |
+ # Process name |
175 |
+- name_length = ord(self.scope_vars[buff_pos:buff_pos + 1]) |
176 |
++ name_length = safe_ord(self.scope_vars[buff_pos:buff_pos + 1]) |
177 |
+ buff_pos += 1 |
178 |
+@@ -1201,3 +1215,3 @@ class JerryDebugger(object): |
179 |
+ # Process type |
180 |
+- value_type = ord(self.scope_vars[buff_pos:buff_pos + 1]) |
181 |
++ value_type = safe_ord(self.scope_vars[buff_pos:buff_pos + 1]) |
182 |
+ |
183 |
+@@ -1205,3 +1219,3 @@ class JerryDebugger(object): |
184 |
+ |
185 |
+- value_length = ord(self.scope_vars[buff_pos:buff_pos + 1]) |
186 |
++ value_length = safe_ord(self.scope_vars[buff_pos:buff_pos + 1]) |
187 |
+ buff_pos += 1 |
188 |
+@@ -1236,12 +1250,12 @@ class JerryDebugger(object): |
189 |
+ for i, level in enumerate(self.scope_data): |
190 |
+- if ord(level) == JERRY_DEBUGGER_SCOPE_WITH: |
191 |
++ if safe_ord(level) == JERRY_DEBUGGER_SCOPE_WITH: |
192 |
+ table.append([str(i), 'with']) |
193 |
+- elif ord(level) == JERRY_DEBUGGER_SCOPE_GLOBAL: |
194 |
++ elif safe_ord(level) == JERRY_DEBUGGER_SCOPE_GLOBAL: |
195 |
+ table.append([str(i), 'global']) |
196 |
+- elif ord(level) == JERRY_DEBUGGER_SCOPE_NON_CLOSURE: |
197 |
++ elif safe_ord(level) == JERRY_DEBUGGER_SCOPE_NON_CLOSURE: |
198 |
+ # Currently it is only marks the catch closure. |
199 |
+ table.append([str(i), 'catch']) |
200 |
+- elif ord(level) == JERRY_DEBUGGER_SCOPE_LOCAL: |
201 |
++ elif safe_ord(level) == JERRY_DEBUGGER_SCOPE_LOCAL: |
202 |
+ table.append([str(i), 'local']) |
203 |
+- elif ord(level) == JERRY_DEBUGGER_SCOPE_CLOSURE: |
204 |
++ elif safe_ord(level) == JERRY_DEBUGGER_SCOPE_CLOSURE: |
205 |
+ table.append([str(i), 'closure']) |
206 |
+diff --git a/jerry-debugger/jerry_client_rawpacket.py b/jerry-debugger/jerry_client_rawpacket.py |
207 |
+index 5c3304ed..275be83c 100644 |
208 |
+--- a/jerry-debugger/jerry_client_rawpacket.py |
209 |
++++ b/jerry-debugger/jerry_client_rawpacket.py |
210 |
+@@ -17,2 +17,3 @@ |
211 |
+ import struct |
212 |
++import sys |
213 |
+ |
214 |
+@@ -20,2 +21,12 @@ MAX_BUFFER_SIZE = 256 |
215 |
+ |
216 |
++ |
217 |
++if sys.version_info.major >= 3: |
218 |
++ def safe_ord(c): |
219 |
++ if isinstance(c, int): |
220 |
++ return c |
221 |
++ return ord(c) |
222 |
++else: |
223 |
++ safe_ord = ord |
224 |
++ |
225 |
++ |
226 |
+ class RawPacket(object): |
227 |
+@@ -72,3 +83,3 @@ class RawPacket(object): |
228 |
+ if len(self.data_buffer) >= 1: |
229 |
+- size = ord(self.data_buffer[0]) |
230 |
++ size = safe_ord(self.data_buffer[0]) |
231 |
+ if size == 0: |
232 |
+diff --git a/jerry-debugger/jerry_client_websocket.py b/jerry-debugger/jerry_client_websocket.py |
233 |
+index fe2c761a..9c755966 100644 |
234 |
+--- a/jerry-debugger/jerry_client_websocket.py |
235 |
++++ b/jerry-debugger/jerry_client_websocket.py |
236 |
+@@ -17,2 +17,3 @@ |
237 |
+ import struct |
238 |
++import sys |
239 |
+ |
240 |
+@@ -22,2 +23,14 @@ WEBSOCKET_FIN_BIT = 0x80 |
241 |
+ |
242 |
++ |
243 |
++if sys.version_info.major >= 3: |
244 |
++ # pylint: disable=invalid-name |
245 |
++ _ord_orig = ord |
246 |
++ def _ord_compat(c): |
247 |
++ if isinstance(c, int): |
248 |
++ return c |
249 |
++ return _ord_orig(c) |
250 |
++ # pylint: disable=redefined-builtin |
251 |
++ ord = _ord_compat |
252 |
++ |
253 |
++ |
254 |
+ class WebSocket(object): |
255 |
+@@ -94,3 +107,3 @@ class WebSocket(object): |
256 |
+ WEBSOCKET_BINARY_FRAME | WEBSOCKET_FIN_BIT, |
257 |
+- WEBSOCKET_FIN_BIT + struct.unpack(byte_order + "B", packed_data[0])[0], |
258 |
++ WEBSOCKET_FIN_BIT + struct.unpack(byte_order + "B", packed_data[0:1])[0], |
259 |
+ 0) + packed_data[1:] |
260 |
|
261 |
diff --git a/dev-lang/jerryscript/jerryscript-2.4.0-r4.ebuild b/dev-lang/jerryscript/jerryscript-2.4.0-r4.ebuild |
262 |
new file mode 100644 |
263 |
index 000000000000..bc0002817e91 |
264 |
--- /dev/null |
265 |
+++ b/dev-lang/jerryscript/jerryscript-2.4.0-r4.ebuild |
266 |
@@ -0,0 +1,74 @@ |
267 |
+# Copyright 2021-2022 Gentoo Authors |
268 |
+# Distributed under the terms of the GNU General Public License v2 |
269 |
+ |
270 |
+EAPI=7 |
271 |
+ |
272 |
+PYTHON_COMPAT=(python3_{7,8,9,10}) |
273 |
+inherit cmake python-single-r1 |
274 |
+ |
275 |
+DESCRIPTION="Ultra-lightweight JavaScript engine for the Internet of Things" |
276 |
+HOMEPAGE="https://github.com/jerryscript-project/jerryscript" |
277 |
+SRC_URI="https://github.com/jerryscript-project/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz" |
278 |
+ |
279 |
+LICENSE="Apache-2.0" |
280 |
+SLOT="0" |
281 |
+KEYWORDS="~amd64" |
282 |
+IUSE="debugger" |
283 |
+RDEPEND="debugger? ( ${PYTHON_DEPS} )" |
284 |
+BDEPEND="${RDEPEND}" |
285 |
+REQUIRED_USE="debugger? ( ${PYTHON_REQUIRED_USE} )" |
286 |
+RESTRICT+=" test" |
287 |
+ |
288 |
+PATCHES=( |
289 |
+ "${FILESDIR}/jerryscript-2.4.0-python3-r4.patch" |
290 |
+) |
291 |
+ |
292 |
+src_prepare() { |
293 |
+ find . -name CMakeLists.txt -print0 | xargs -0 sed -i \ |
294 |
+ -e "s:lib/pkgconfig:$(get_libdir)/pkgconfig:" \ |
295 |
+ -e "s:DESTINATION lib):DESTINATION $(get_libdir)):" \ |
296 |
+ || die |
297 |
+ find . -name '*.pc.in' -print0 | xargs -0 sed -i \ |
298 |
+ -e "s|/lib\$|/$(get_libdir)|" \ |
299 |
+ || die |
300 |
+ cmake_src_prepare |
301 |
+} |
302 |
+ |
303 |
+src_configure() { |
304 |
+ local mycmakeargs=( |
305 |
+ -DENABLE_STRIP=OFF |
306 |
+ -DJERRY_DEBUGGER=ON |
307 |
+ -DJERRY_ERROR_MESSAGES=ON |
308 |
+ -DJERRY_EXTERNAL_CONTEXT=ON |
309 |
+ -DJERRY_LINE_INFO=ON |
310 |
+ -DJERRY_LOGGING=ON |
311 |
+ -DJERRY_PARSER_DUMP_BYTE_CODE=ON |
312 |
+ -DJERRY_PARSER=ON |
313 |
+ -DJERRY_REGEXP_DUMP_BYTE_CODE=ON |
314 |
+ -DJERRY_SNAPSHOT_EXEC=ON |
315 |
+ -DJERRY_SNAPSHOT_SAVE=ON |
316 |
+ ) |
317 |
+ cmake_src_configure |
318 |
+} |
319 |
+ |
320 |
+src_install() { |
321 |
+ local jerry_debugger_dir |
322 |
+ cmake_src_install |
323 |
+ |
324 |
+ if use debugger; then |
325 |
+ jerry_debugger_dir=/usr/$(get_libdir)/jerryscript/jerry-debugger |
326 |
+ insinto "${jerry_debugger_dir}" |
327 |
+ doins jerry-debugger/*.py |
328 |
+ python_optimize "${ED}${jerry_debugger_dir}" |
329 |
+ |
330 |
+ cat <<-EOF > "${T}/jerry-debugger" |
331 |
+ #!/usr/bin/python |
332 |
+ import sys |
333 |
+ sys.path.insert(0, "${EPREFIX}${jerry_debugger_dir}") |
334 |
+ with open("${jerry_debugger_dir}/jerry_client.py") as f: |
335 |
+ exec(f.read()) |
336 |
+ EOF |
337 |
+ |
338 |
+ python_doscript "${T}"/jerry-debugger |
339 |
+ fi |
340 |
+} |