Gentoo Archives: gentoo-commits

From: Conrad Kostecki <conikost@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: profiles/, dev-lua/lua-cjson/, dev-lua/lua-cjson/files/
Date: Tue, 01 Dec 2020 10:18:05
Message-Id: 1606817706.a7d176da22f2ec428c88cd2514c190f757d9ee26.conikost@gentoo
1 commit: a7d176da22f2ec428c88cd2514c190f757d9ee26
2 Author: Conrad Kostecki <conikost <AT> gentoo <DOT> org>
3 AuthorDate: Mon Nov 30 23:24:26 2020 +0000
4 Commit: Conrad Kostecki <conikost <AT> gentoo <DOT> org>
5 CommitDate: Tue Dec 1 10:15:06 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a7d176da
7
8 dev-lua/lua-cjson: migrate to lua eclass
9
10 Closes: https://bugs.gentoo.org/752618
11 Package-Manager: Portage-3.0.9, Repoman-3.0.2
12 Signed-off-by: Conrad Kostecki <conikost <AT> gentoo.org>
13
14 .../lua-cjson/files/lua-cjson-2.1.0.8-lua52.patch | 143 +++++++++++++++++++++
15 dev-lua/lua-cjson/lua-cjson-2.1.0.8-r100.ebuild | 105 +++++++++++++++
16 profiles/package.mask | 1 +
17 3 files changed, 249 insertions(+)
18
19 diff --git a/dev-lua/lua-cjson/files/lua-cjson-2.1.0.8-lua52.patch b/dev-lua/lua-cjson/files/lua-cjson-2.1.0.8-lua52.patch
20 new file mode 100644
21 index 00000000000..8f8c98243f1
22 --- /dev/null
23 +++ b/dev-lua/lua-cjson/files/lua-cjson-2.1.0.8-lua52.patch
24 @@ -0,0 +1,143 @@
25 +From e8dddaf2c9c370f3676441304955d81543c5cceb Mon Sep 17 00:00:00 2001
26 +From: leaf corcoran <leafot@×××××.com>
27 +Date: Sat, 21 Sep 2019 17:31:38 -0700
28 +Subject: [PATCH 1/5] support lua 5.2 with LUA_COMPAT_ALL
29 +
30 +---
31 + lua_cjson.c | 3 +++
32 + 1 file changed, 3 insertions(+)
33 +
34 +diff --git a/lua_cjson.c b/lua_cjson.c
35 +index 2a69699..83118b1 100644
36 +--- a/lua_cjson.c
37 ++++ b/lua_cjson.c
38 +@@ -36,6 +36,9 @@
39 + * difficult to know object/array sizes ahead of time.
40 + */
41 +
42 ++
43 ++#define LUA_COMPAT_ALL 1
44 ++
45 + #include <assert.h>
46 + #include <stdint.h>
47 + #include <string.h>
48 +
49 +From 2b3c3c866701a0110a6ac50a9bec9f23adc2956e Mon Sep 17 00:00:00 2001
50 +From: leaf corcoran <leafot@×××××.com>
51 +Date: Sat, 21 Sep 2019 18:01:05 -0700
52 +Subject: [PATCH 2/5] support lua 5.3 with LUA_COMPAT_5_1
53 +
54 +---
55 + lua_cjson.c | 1 +
56 + 1 file changed, 1 insertion(+)
57 +
58 +diff --git a/lua_cjson.c b/lua_cjson.c
59 +index 83118b1..9d25f7c 100644
60 +--- a/lua_cjson.c
61 ++++ b/lua_cjson.c
62 +@@ -38,6 +38,7 @@
63 +
64 +
65 + #define LUA_COMPAT_ALL 1
66 ++#define LUA_COMPAT_5_1 1
67 +
68 + #include <assert.h>
69 + #include <stdint.h>
70 +
71 +From 639c4a38bf0b1bddef4bfdb22bb6a3f8493cc3fe Mon Sep 17 00:00:00 2001
72 +From: leaf corcoran <leafot@×××××.com>
73 +Date: Sat, 21 Sep 2019 18:18:27 -0700
74 +Subject: [PATCH 3/5] Lua 5.2+ unpack support
75 +
76 +---
77 + lua/cjson/util.lua | 2 ++
78 + 1 file changed, 2 insertions(+)
79 +
80 +diff --git a/lua/cjson/util.lua b/lua/cjson/util.lua
81 +index 5d80106..48fa33c 100644
82 +--- a/lua/cjson/util.lua
83 ++++ b/lua/cjson/util.lua
84 +@@ -1,5 +1,7 @@
85 + local json = require "cjson"
86 +
87 ++local unpack = unpack or table.unpack
88 ++
89 + -- Various common routines used by the Lua CJSON package
90 + --
91 + -- Mark Pulford <mark@××××××××.au>
92 +
93 +From 9163dd3c431bd7ab45bdb218c32c8c9633ddf2cc Mon Sep 17 00:00:00 2001
94 +From: leaf corcoran <leafot@×××××.com>
95 +Date: Sat, 21 Sep 2019 18:43:47 -0700
96 +Subject: [PATCH 4/5] Lua 5.2+ maxn support
97 +
98 +---
99 + lua/cjson/util.lua | 12 +++++++++++-
100 + 1 file changed, 11 insertions(+), 1 deletion(-)
101 +
102 +diff --git a/lua/cjson/util.lua b/lua/cjson/util.lua
103 +index 48fa33c..2405257 100644
104 +--- a/lua/cjson/util.lua
105 ++++ b/lua/cjson/util.lua
106 +@@ -2,6 +2,16 @@ local json = require "cjson"
107 +
108 + local unpack = unpack or table.unpack
109 +
110 ++local maxn = table.maxn or function(t)
111 ++ local max = 0
112 ++ for k,v in pairs(t) do
113 ++ if type(k) == "number" and k > max then
114 ++ max = k
115 ++ end
116 ++ end
117 ++ return max
118 ++end
119 ++
120 + -- Various common routines used by the Lua CJSON package
121 + --
122 + -- Mark Pulford <mark@××××××××.au>
123 +@@ -194,7 +204,7 @@ local function run_test(testname, func, input, should_work, output)
124 + local result = {}
125 + local tmp = { pcall(func, unpack(input)) }
126 + local success = tmp[1]
127 +- for i = 2, table.maxn(tmp) do
128 ++ for i = 2, maxn(tmp) do
129 + result[i - 1] = tmp[i]
130 + end
131 +
132 +
133 +From c390998582b959389d0fc039743c96e861902587 Mon Sep 17 00:00:00 2001
134 +From: leaf corcoran <leafot@×××××.com>
135 +Date: Sun, 22 Sep 2019 13:43:18 -0700
136 +Subject: [PATCH 5/5] use macro instead of header defines for Lua 5.2+ support
137 +
138 +---
139 + lua_cjson.c | 8 ++++----
140 + 1 file changed, 4 insertions(+), 4 deletions(-)
141 +
142 +diff --git a/lua_cjson.c b/lua_cjson.c
143 +index 9d25f7c..718a5b9 100644
144 +--- a/lua_cjson.c
145 ++++ b/lua_cjson.c
146 +@@ -36,10 +36,6 @@
147 + * difficult to know object/array sizes ahead of time.
148 + */
149 +
150 +-
151 +-#define LUA_COMPAT_ALL 1
152 +-#define LUA_COMPAT_5_1 1
153 +-
154 + #include <assert.h>
155 + #include <stdint.h>
156 + #include <string.h>
157 +@@ -105,6 +101,10 @@
158 + #define json_lightudata_mask(ludata) (ludata)
159 + #endif
160 +
161 ++#if LUA_VERSION_NUM > 501
162 ++#define lua_objlen(L,i) lua_rawlen(L, (i))
163 ++#endif
164 ++
165 + static const char * const *json_empty_array;
166 + static const char * const *json_array;
167 +
168
169 diff --git a/dev-lua/lua-cjson/lua-cjson-2.1.0.8-r100.ebuild b/dev-lua/lua-cjson/lua-cjson-2.1.0.8-r100.ebuild
170 new file mode 100644
171 index 00000000000..c7ff3172c0b
172 --- /dev/null
173 +++ b/dev-lua/lua-cjson/lua-cjson-2.1.0.8-r100.ebuild
174 @@ -0,0 +1,105 @@
175 +# Copyright 1999-2020 Gentoo Authors
176 +# Distributed under the terms of the GNU General Public License v2
177 +
178 +EAPI=7
179 +
180 +LUA_COMPAT=( lua5-{1..3} luajit )
181 +
182 +inherit lua toolchain-funcs
183 +
184 +DESCRIPTION="A fast JSON encoding/parsing module for Lua"
185 +HOMEPAGE="https://www.kyne.com.au/~mark/software/lua-cjson.php https://github.com/openresty/lua-cjson"
186 +SRC_URI="https://github.com/openresty/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"
187 +
188 +LICENSE="MIT"
189 +SLOT="0"
190 +KEYWORDS="~amd64 ~arm ~arm64 ~x86"
191 +IUSE="+internal-fpconv test +threads"
192 +REQUIRED_USE="
193 + threads? ( internal-fpconv )
194 + ${LUA_REQUIRED_USE}
195 +"
196 +RESTRICT="!test? ( test )"
197 +
198 +RDEPEND="${LUA_DEPS}"
199 +DEPEND="${RDEPEND}"
200 +BDEPEND="test? ( dev-lang/perl )"
201 +
202 +DOCS=( "manual.txt" "NEWS" "performance.txt" "README.md" "THANKS" )
203 +
204 +PATCHES=(
205 + "${FILESDIR}/${PN}-2.1.0.8-sparse_array_test_fix.patch"
206 + "${FILESDIR}/${PN}-2.1.0.8-lua52.patch"
207 +)
208 +
209 +src_prepare() {
210 + default
211 +
212 + # Don't install tests
213 + sed -e '/cd tests/d' -i Makefile || die
214 +
215 + lua_copy_sources
216 +}
217 +
218 +lua_src_compile() {
219 + pushd "${BUILD_DIR}" || die
220 +
221 + local myemakeargs=(
222 + "CC=$(tc-getCC)"
223 + "CFLAGS=${CFLAGS}"
224 + "LDFLAGS=${LDFLAGS}"
225 + "LUA_INCLUDE_DIR=$(lua_get_include_dir)"
226 + )
227 +
228 + emake "${myemakeargs[@]}"
229 +
230 + popd
231 +}
232 +
233 +src_compile() {
234 + lua_foreach_impl lua_src_compile
235 +}
236 +
237 +lua_src_test() {
238 + if ! [[ ${ELUA} == "lua5.3" ]]; then
239 + pushd "${BUILD_DIR}" || die
240 + cd tests || die
241 +
242 + ln -s "${BUILD_DIR}"/cjson.so ./ || die
243 + ln -s "${S}"/lua/cjson ./ || die
244 +
245 + ./genutf8.pl || die
246 + ./test.lua || die
247 +
248 + popd
249 + else
250 + ewarn "Not running tests under ${ELUA} because they are known to fail"
251 + ewarn "See: https://github.com/openresty/lua-cjson/pull/50"
252 + return
253 + fi
254 +}
255 +
256 +src_test() {
257 + lua_foreach_impl lua_src_test
258 +}
259 +
260 +lua_src_install() {
261 + pushd "${BUILD_DIR}" || die
262 +
263 + local myemakeargs=(
264 + "DESTDIR=${D}"
265 + "LUA_CMODULE_DIR=$(lua_get_lmod_dir)"
266 + "LUA_MODULE_DIR=$(lua_get_lmod_dir)"
267 + "PREFIX=${EPREFIX}/usr"
268 + )
269 +
270 + emake "${myemakeargs[@]}" install install-extra
271 +
272 + popd
273 +}
274 +
275 +src_install() {
276 + lua_foreach_impl lua_src_install
277 +
278 + einstalldocs
279 +}
280
281 diff --git a/profiles/package.mask b/profiles/package.mask
282 index bbaafb49b59..8e2f28c10d2 100644
283 --- a/profiles/package.mask
284 +++ b/profiles/package.mask
285 @@ -531,6 +531,7 @@ dev-lua/luacrypto
286 >=dev-lua/lpeg-1.0.2-r100
287 >=dev-lua/lua-argparse-0.6.0-r100
288 >=dev-lua/lua-bit32-5.3.5-r100
289 +>=dev-lua/lua-cjson-2.1.0.8-r100
290 >=dev-lua/lua-term-0.7-r100
291 >=dev-lua/lua-utf8-0.1.3-r100
292 >=dev-lua/lua-zlib-1.2-r100