commit:     cae78ddb3b3444528430424b6d50d6d7efb16656
Author:     Haelwenn (lanodan) Monnier <contact <AT> hacktivis <DOT> me>
AuthorDate: Mon Apr  1 20:58:31 2024 +0000
Commit:     Julien Roy <julien <AT> jroy <DOT> ca>
CommitDate: Mon Apr  1 21:23:36 2024 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=cae78ddb

dev-lang/quickjs: add 2024.01.13

Signed-off-by: Haelwenn (lanodan) Monnier <contact <AT> hacktivis.me>

 dev-lang/quickjs/Manifest                          |  1 +
 .../files/quickjs-2024-01-13-respect-env.patch     | 46 +++++++++++++++++
 .../files/quickjs-2024-01-13-sharedlib.patch       | 59 ++++++++++++++++++++++
 dev-lang/quickjs/quickjs-2024.01.13.ebuild         | 48 ++++++++++++++++++
 4 files changed, 154 insertions(+)

diff --git a/dev-lang/quickjs/Manifest b/dev-lang/quickjs/Manifest
index 7d664f78ea..559f41a64d 100644
--- a/dev-lang/quickjs/Manifest
+++ b/dev-lang/quickjs/Manifest
@@ -1 +1,2 @@
 DIST quickjs-2021-03-27.tar.xz 753556 BLAKE2B 
a959da95ca4861b5675359ac81598b50a80170ec4f4d819c44d666dd4ecb5a2e11d63230f98b611d5109941f5b21f5c8f791d56d153b818408ec1c59350d5e1d
 SHA512 
eeb810083484df213bc658a8703ca3ef094b7789c2b49eed86cb4068c9f9da401ad0300261d61a163c6ea82306f3ef50bf8e29a64920f704fd8958ef08a7286c
+DIST quickjs-2024-01-13.tar.xz 765800 BLAKE2B 
6d65d9ae19ef816a7e4784821d138d2be9965bbbea42c11f13adc0560dc6d67db9cd75c367680a5caec34182a320819127fc0d0c95c10fcf441161ca7880d5aa
 SHA512 
9f426404e4dc1e2a41fcc235b72e58708041aed24eadd5fb9e82f62435501003d3a6b04831f307b04852551d2fd265b94cd400b3293ec0810465f52de8a6c057

diff --git a/dev-lang/quickjs/files/quickjs-2024-01-13-respect-env.patch 
b/dev-lang/quickjs/files/quickjs-2024-01-13-respect-env.patch
new file mode 100644
index 0000000000..aa2efa9ea3
--- /dev/null
+++ b/dev-lang/quickjs/files/quickjs-2024-01-13-respect-env.patch
@@ -0,0 +1,46 @@
+--- a/Makefile.old
++++ b/Makefile
+@@ -69,7 +69,7 @@ endif
+ ifdef CONFIG_CLANG
+   HOST_CC=clang
+   CC=$(CROSS_PREFIX)clang
+-  CFLAGS+=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d
++  CFLAGS+=-Wall -MMD -MF $(OBJDIR)/$(@F).d
+   CFLAGS += -Wextra
+   CFLAGS += -Wno-sign-compare
+   CFLAGS += -Wno-missing-field-initializers
+@@ -92,13 +92,13 @@ else ifdef CONFIG_COSMO
+   HOST_CC=gcc
+   CC=cosmocc
+   # cosmocc does not correct support -MF
+-  CFLAGS=-g -Wall #-MMD -MF $(OBJDIR)/$(@F).d
++  CFLAGS=-Wall #-MMD -MF $(OBJDIR)/$(@F).d
+   CFLAGS += -Wno-array-bounds -Wno-format-truncation
+   AR=cosmoar
+ else
+   HOST_CC=gcc
+   CC=$(CROSS_PREFIX)gcc
+-  CFLAGS+=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d
++  CFLAGS+=-Wall -MMD -MF $(OBJDIR)/$(@F).d
+   CFLAGS += -Wno-array-bounds -Wno-format-truncation
+   ifdef CONFIG_LTO
+     AR=$(CROSS_PREFIX)gcc-ar
+@@ -120,14 +120,14 @@ DEFINES+=-D__USE_MINGW_ANSI_STDIO # for standard 
snprintf behavior
+ endif
+ 
+ CFLAGS+=$(DEFINES)
+-CFLAGS_DEBUG=$(CFLAGS) -O0
+-CFLAGS_SMALL=$(CFLAGS) -Os
+-CFLAGS_OPT=$(CFLAGS) -O2
++CFLAGS_DEBUG=$(CFLAGS)
++CFLAGS_SMALL=$(CFLAGS)
++CFLAGS_OPT=$(CFLAGS)
+ CFLAGS_NOLTO:=$(CFLAGS_OPT)
+ ifdef CONFIG_COSMO
+ LDFLAGS+=-s # better to strip by default
+ else
+-LDFLAGS+=-g
++LDFLAGS+=
+ endif
+ ifdef CONFIG_LTO
+ CFLAGS_SMALL+=-flto

diff --git a/dev-lang/quickjs/files/quickjs-2024-01-13-sharedlib.patch 
b/dev-lang/quickjs/files/quickjs-2024-01-13-sharedlib.patch
new file mode 100644
index 0000000000..15a6ddcc35
--- /dev/null
+++ b/dev-lang/quickjs/files/quickjs-2024-01-13-sharedlib.patch
@@ -0,0 +1,59 @@
+From c57e930e9573ce29d816899bb3e7303d8ae2d69b Mon Sep 17 00:00:00 2001
+From: "Haelwenn (lanodan) Monnier" <cont...@hacktivis.me>
+Date: Mon, 1 Apr 2024 22:33:10 +0200
+Subject: [PATCH] Makefile: Allow building libquickjs as a shared library
+
+Adapted from 
https://git.alpinelinux.org/aports/tree/community/quickjs/01-sharedlib.patch?id=27a8f649949c36bfc3e45854e08c48a8eb06e07c
+
+Co-authored-by: Celeste <20312-cele...@users.gitlab.alpinelinux.org>
+---
+ Makefile | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+
+diff --git a/Makefile b/Makefile
+index 0270a6ad8..76c2a4b11 100644
+--- a/Makefile
++++ b/Makefile
+@@ -32,6 +32,8 @@ endif
+ #CONFIG_WIN32=y
+ # use link time optimization (smaller and faster executables but slower build)
+ #CONFIG_LTO=y
++# also build libquickjs as a shared library
++#CONFIG_SHARED=y
+ # consider warnings as errors (for development)
+ #CONFIG_WERROR=y
+ # force 32 bit build for some utilities
+@@ -205,6 +207,10 @@ PROGS+=libquickjs.a
+ ifdef CONFIG_LTO
+ PROGS+=libquickjs.lto.a
+ endif
++ifdef CONFIG_SHARED
++SO_VERSION=$(shell sed 's/-/./g' VERSION)
++PROGS+=libquickjs.so.$(SO_VERSION)
++endif
+ 
+ # examples
+ ifeq ($(CROSS_PREFIX),)
+@@ -289,6 +295,11 @@ libquickjs.a: $(patsubst %.o, %.nolto.o, $(QJS_LIB_OBJS))
+       $(AR) rcs $@ $^
+ endif # CONFIG_LTO
+ 
++ifdef CONFIG_SHARED
++libquickjs.so.$(SO_VERSION): $(patsubst %.o, %.pic.o, $(QJS_LIB_OBJS))
++      $(CC) -shared -Wl,-soname,$@ $(LDFLAGS) -o $@ $^
++endif # CONFIG_SHARED
++
+ repl.c: $(QJSC) repl.js
+       $(QJSC) -c -o $@ -m repl.js
+ 
+@@ -362,6 +373,10 @@ install: all
+       install -m644 libquickjs.a "$(DESTDIR)$(PREFIX)/lib/quickjs"
+ ifdef CONFIG_LTO
+       install -m644 libquickjs.lto.a "$(DESTDIR)$(PREFIX)/lib/quickjs"
++endif
++ifdef CONFIG_SHARED
++      install -Dm755 libquickjs.so.$(SO_VERSION) "$(DESTDIR)$(PREFIX)/lib"
++      ln -s libquickjs.so.$(SO_VERSION) 
"$(DESTDIR)$(PREFIX)/lib/libquickjs.so"
+ endif
+       mkdir -p "$(DESTDIR)$(PREFIX)/include/quickjs"
+       install -m644 quickjs.h quickjs-libc.h 
"$(DESTDIR)$(PREFIX)/include/quickjs"

diff --git a/dev-lang/quickjs/quickjs-2024.01.13.ebuild 
b/dev-lang/quickjs/quickjs-2024.01.13.ebuild
new file mode 100644
index 0000000000..bdd0ed5173
--- /dev/null
+++ b/dev-lang/quickjs/quickjs-2024.01.13.ebuild
@@ -0,0 +1,48 @@
+# Copyright 2021-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit toolchain-funcs
+
+MY_P="${PN}-${PV//./-}"
+
+DESCRIPTION="Small embeddable Javascript engine"
+HOMEPAGE="https://bellard.org/quickjs/";
+SRC_URI="https://bellard.org/quickjs/${MY_P}.tar.xz";
+S="${WORKDIR}/${MY_P}"
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~amd64"
+IUSE="lto"
+
+PATCHES=(
+       "${FILESDIR}/quickjs-2020.11.08_Remove-TTY-check-in-test.patch"
+       "${FILESDIR}/quickjs-2024-01-13-sharedlib.patch"
+       "${FILESDIR}/quickjs-2024-01-13-respect-env.patch"
+)
+
+src_prepare() {
+       # Changed in master
+       sed -i '/^CONFIG_LTO=/s;^;#;' Makefile || die
+
+       default
+
+       sed -i '/$(STRIP) .*/d' Makefile || die "Failed removing STRIP call"
+
+       sed -Ei '/^\s*(CC|AR)=/d' Makefile \
+               || die "Failed to remove hard-coded tools."
+
+       sed -i 's;$(PREFIX)/lib;$(LIBDIR);' Makefile || die "Failed fixing 
libdir"
+}
+
+src_configure() {
+       export CC="$(tc-getCC)"
+       export AR="$(tc-getAR)"
+
+       export PREFIX=/usr
+       export LIBDIR="/usr/$(get_libdir)"
+
+       export CONFIG_LTO=$(use lto)
+       export CONFIG_SHARED=y
+}

Reply via email to