quickjs: clean up integration

Pass CFLAGS and LDFLAGS the correct way via environment variables and
not as arguments so the upstream Makefile CFLAGS/LDFLAGS do not get
overwritten and no ugly workaround is needed. Set PREFIX correctly and
do not set CONFIG_SMALL which was implemented in a patch that was
dropped. Remove commented out code (libquickjs.lto.a is no longer
built by default). Set PKG_SOURCE_DATE correctly as the date of the
upstream git repo and not the date of the OpenWrt package. Fix
whitespace issues in patch. Do not create empty /usr/lib/quickjs
This commit is contained in:
Erik Karlsson 2025-08-15 13:41:40 +02:00 committed by Vivek Dutta
parent afde0b98ad
commit 417a127dd9
2 changed files with 18 additions and 23 deletions

View file

@ -5,7 +5,7 @@ PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/bellard/quickjs.git
PKG_SOURCE_DATE:=2025-07-22
PKG_SOURCE_DATE:=2025-07-09
PKG_SOURCE_VERSION:=1fdc768fdc8571300755cdd3e4654ce99c0255ce
PKG_MIRROR_HASH:=skip
PKG_LICENSE:=MIT
@ -31,8 +31,7 @@ define Package/quickjs/description
endef
MAKE_FLAGS = \
prefix=/usr \
CONFIG_SMALL=y \
PREFIX=/usr \
EXTRA_LIBS="-latomic" \
CROSS_PREFIX="$(TARGET_CROSS)"
@ -42,12 +41,10 @@ define Build/Compile
# the host tools ('host-qjsc', 'unicode_gen') with the host compiler
# and flags.
# We still pass MAKE_FLAGS so the upstream Makefile knows we're cross-compiling.
# We have to manually add DEFINES from the upstream Makefile to HOST_CFLAGS
# because we are overriding CFLAGS.
CFLAGS="$(HOST_CFLAGS)" \
LDFLAGS="$(HOST_LDFLAGS)" \
$(MAKE) -C $(PKG_BUILD_DIR) \
$(MAKE_FLAGS) \
CFLAGS="$(HOST_CFLAGS) -D_GNU_SOURCE -DCONFIG_VERSION='\"$(shell cat $(PKG_BUILD_DIR)/VERSION | tr -d '\n')\"'" \
LDFLAGS="$(HOST_LDFLAGS)" \
host-qjsc unicode_gen
# Then we proceed with the default build process for the target binaries.
@ -56,17 +53,16 @@ define Build/Compile
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/lib/quickjs
$(CP) $(PKG_INSTALL_DIR)/usr/local/lib/quickjs/libquickjs.a $(1)/usr/lib/
# $(CP) $(PKG_INSTALL_DIR)/usr/local/lib/quickjs/libquickjs.lto.a $(1)/usr/lib/
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/quickjs/libquickjs.a $(1)/usr/lib/
$(INSTALL_DIR) $(1)/usr/include/quickjs
$(CP) $(PKG_INSTALL_DIR)/usr/local/include/quickjs/quickjs.h $(1)/usr/include/quickjs/
$(CP) $(PKG_INSTALL_DIR)/usr/local/include/quickjs/quickjs-libc.h $(1)/usr/include/quickjs/
$(CP) $(PKG_INSTALL_DIR)/usr/include/quickjs/quickjs.h $(1)/usr/include/quickjs/
$(CP) $(PKG_INSTALL_DIR)/usr/include/quickjs/quickjs-libc.h $(1)/usr/include/quickjs/
endef
define Package/quickjs/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/local/bin/qjs $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/qjs $(1)/usr/bin/
endef
$(eval $(call BuildPackage,quickjs))

View file

@ -1,12 +1,12 @@
Index: quickjs-2025-07-22-1fdc768f/quickjs-libc.c
===================================================================
--- quickjs-2025-07-22-1fdc768f.orig/quickjs-libc.c
+++ quickjs-2025-07-22-1fdc768f/quickjs-libc.c
@@ -385,20 +385,94 @@ fail:
diff --git a/quickjs-libc.c b/quickjs-libc.c
index 54a7a15..a64c4d6 100644
--- a/quickjs-libc.c
+++ b/quickjs-libc.c
@@ -385,12 +385,86 @@ fail:
return JS_EXCEPTION;
}
+#define READALL_CHUNK 10*1024
+#define READALL_CHUNK (10*1024)
+
+static int readall(FILE *f, JSContext *ctx, uint8_t **dataptr, size_t *sizeptr)
+{
@ -86,12 +86,11 @@ Index: quickjs-2025-07-22-1fdc768f/quickjs-libc.c
uint8_t *buf;
size_t buf_len;
- long lret;
-
+ long lret = 0;
+
f = fopen(filename, "rb");
if (!f)
return NULL;
@@ -398,7 +472,7 @@ uint8_t *js_load_file(JSContext *ctx, size_t *pbuf_len, const char *filename)
if (fseek(f, 0, SEEK_END) < 0)
goto fail;
lret = ftell(f);
@ -100,7 +99,7 @@ Index: quickjs-2025-07-22-1fdc768f/quickjs-libc.c
goto fail;
/* XXX: on Linux, ftell() return LONG_MAX for directories */
if (lret == LONG_MAX) {
@@ -414,13 +488,19 @@ uint8_t *js_load_file(JSContext *ctx, si
@@ -414,13 +488,19 @@ uint8_t *js_load_file(JSContext *ctx, size_t *pbuf_len, const char *filename)
buf = malloc(buf_len + 1);
if (!buf)
goto fail;