mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2025-10-26 10:52:21 +00:00
Complete refactor of project file structure
Fix incorrect handing of default node parameters in SSD subscription. Fix unable to parse some Clash rule-providers (#289). Fix not filtering inline comments in some Surge rulesets. (#285) Add Cron task options. Add clean context option for persisting a JS context across the whole request. Replace JS engine with QuickJS.
This commit is contained in:
@@ -1,26 +1,28 @@
|
||||
FROM alpine:3.12
|
||||
FROM alpine:3.13
|
||||
LABEL maintainer "tindy.it@gmail.com"
|
||||
|
||||
# build minimized
|
||||
WORKDIR /
|
||||
RUN apk add --no-cache --virtual .build-tools git g++ build-base linux-headers cmake python2 nodejs npm && \
|
||||
RUN apk add --no-cache --virtual .build-tools git g++ build-base linux-headers cmake && \
|
||||
apk add --no-cache --virtual .build-deps curl-dev rapidjson-dev libevent-dev pcre2-dev yaml-cpp-dev && \
|
||||
git clone https://github.com/svaarala/duktape --depth=1 && \
|
||||
cd duktape && \
|
||||
make -C src-tools && \
|
||||
python2 -m ensurepip && \
|
||||
pip2 install PyYAML --no-cache-dir && \
|
||||
python2 util/dist.py --output-directory dist && \
|
||||
cd dist/src && \
|
||||
cc -c -O3 -o duktape.o duktape.c && \
|
||||
cc -c -O3 -o duk_module_node.o -I. ../extras/module-node/duk_module_node.c && \
|
||||
ar cr libduktape.a duktape.o && \
|
||||
ar cr libduktape_module.a duk_module_node.o && \
|
||||
install -m0644 ./*.a /usr/lib && \
|
||||
install -m0644 duk*.h /usr/include && \
|
||||
install -m0644 ../extras/module-node/duk_module_node.h /usr/include && \
|
||||
cd ../../.. && \
|
||||
rm -rf duktape /usr/lib/python2.7 && \
|
||||
git clone https://github.com/ftk/quickjspp --depth=1 && \
|
||||
cd quickjspp && \
|
||||
cmake -DCMAKE_BUILD_TYPE=Release . && \
|
||||
make -j4 && \
|
||||
install -m644 quickjs/libquickjs.a /usr/lib && \
|
||||
install -m644 quickjs/quickjs.h quickjs/quickjs-libc.h /usr/include/quickjs && \
|
||||
install -m644 quickjspp.hpp /usr/include && \
|
||||
cd .. && \
|
||||
git clone https://github.com/PerMalmberg/libcron --depth=1 && \
|
||||
cd libcron && \
|
||||
cmake -DCMAKE_BUILD_TYPE=Release . && \
|
||||
make -j4 && \
|
||||
install -m644 libcron/out/Release/liblibcron.a /usr/lib && \
|
||||
install -d /usr/include/libcron/ && \
|
||||
install -m644 libcron/include/libcron/* /usr/include/libcron/ && \
|
||||
install -d /usr/include/date/ && \
|
||||
install -m644 libcron/externals/date/include/date/* /usr/include/date/ && \
|
||||
cd .. && \
|
||||
git clone https://github.com/tindy2013/subconverter --depth=1 && \
|
||||
cd subconverter && \
|
||||
cmake -DCMAKE_BUILD_TYPE=Release . && \
|
||||
|
||||
@@ -16,21 +16,25 @@ cmake -DCMAKE_BUILD_TYPE=Release -DYAML_CPP_BUILD_TESTS=OFF -DYAML_CPP_BUILD_TOO
|
||||
make install -j2 > /dev/null
|
||||
cd ..
|
||||
|
||||
git clone https://github.com/svaarala/duktape --depth=1
|
||||
cd duktape
|
||||
make -C src-tools
|
||||
python2 -m ensurepip
|
||||
pip2 install PyYAML
|
||||
python2 util/dist.py --output-directory dist
|
||||
cd dist/src
|
||||
cc -c -O3 -o duktape.o duktape.c
|
||||
cc -c -O3 -o duk_module_node.o -I. ../extras/module-node/duk_module_node.c
|
||||
ar cr libduktape.a duktape.o
|
||||
ar cr libduktape_module.a duk_module_node.o
|
||||
install -m0644 ./*.a /usr/lib
|
||||
install -m0644 ./duk*.h /usr/include
|
||||
install -m0644 ../extras/module-node/duk_module_node.h /usr/include
|
||||
cd ../../..
|
||||
git clone https://github.com/ftk/quickjspp --depth=1
|
||||
cd quickjspp
|
||||
cmake -DCMAKE_BUILD_TYPE=Release .
|
||||
make -j4
|
||||
install -m644 quickjs/libquickjs.a /usr/lib
|
||||
install -m644 quickjs/quickjs.h quickjs/quickjs-libc.h /usr/include/quickjs
|
||||
install -m644 quickjspp.hpp /usr/include
|
||||
cd ..
|
||||
|
||||
git clone https://github.com/PerMalmberg/libcron --depth=1
|
||||
cd libcron
|
||||
cmake -DCMAKE_BUILD_TYPE=Release .
|
||||
make -j4
|
||||
install -m644 libcron/out/Release/liblibcron.a /usr/lib
|
||||
install -d /usr/include/libcron/
|
||||
install -m644 libcron/include/libcron/* /usr/include/libcron/
|
||||
install -d /usr/include/date/
|
||||
install -m644 libcron/externals/date/include/date/* /usr/include/date/
|
||||
cd ..
|
||||
|
||||
export PKG_CONFIG_PATH=/usr/lib64/pkgconfig
|
||||
cmake -DCMAKE_BUILD_TYPE=Release .
|
||||
|
||||
@@ -17,20 +17,23 @@ cmake -DCMAKE_BUILD_TYPE=Release -DYAML_CPP_BUILD_TESTS=OFF -DYAML_CPP_BUILD_TOO
|
||||
make install -j8 > /dev/null
|
||||
cd ..
|
||||
|
||||
git clone https://github.com/svaarala/duktape --depth=1
|
||||
cd duktape
|
||||
make -C src-tools
|
||||
pip2 install PyYAML
|
||||
python2 util/dist.py --output-directory dist
|
||||
cd dist/src
|
||||
cc -c -O3 -o duktape.o duktape.c
|
||||
cc -c -O3 -o duk_module_node.o -I. ../extras/module-node/duk_module_node.c
|
||||
ar cr libduktape.a duktape.o
|
||||
ar cr libduktape_module.a duk_module_node.o
|
||||
install -m0644 ./*.a /usr/local/lib
|
||||
install -m0644 ./duk*.h /usr/local/include
|
||||
install -m0644 ../extras/module-node/duk_module_node.h /usr/local/include
|
||||
cd ../../..
|
||||
git clone https://github.com/ftk/quickjspp --depth=1
|
||||
cd quickjspp
|
||||
cmake -DCMAKE_BUILD_TYPE=Release .
|
||||
make -j4
|
||||
install -m644 quickjs/quickjs.h quickjs/quickjs-libc.h /usr/local/include/quickjs
|
||||
install -m644 quickjspp.hpp /usr/local/include
|
||||
cd ..
|
||||
|
||||
git clone https://github.com/PerMalmberg/libcron --depth=1
|
||||
cd libcron
|
||||
cmake -DCMAKE_BUILD_TYPE=Release .
|
||||
make -j4
|
||||
install -d /usr/local/include/libcron/
|
||||
install -m644 libcron/include/libcron/* /usr/local/include/libcron/
|
||||
install -d /usr/local/include/date/
|
||||
install -m644 libcron/externals/date/include/date/* /usr/local/include/date/
|
||||
cd ..
|
||||
|
||||
cp /usr/local/lib/libevent.a .
|
||||
cp /usr/local/opt/zlib/lib/libz.a .
|
||||
|
||||
@@ -13,19 +13,26 @@ cmake -DCMAKE_BUILD_TYPE=Release -DYAML_CPP_BUILD_TESTS=OFF -DYAML_CPP_BUILD_TOO
|
||||
make install -j4
|
||||
cd ..
|
||||
|
||||
git clone https://github.com/svaarala/duktape --depth=1
|
||||
cd duktape
|
||||
make -C src-tools
|
||||
node src-tools/index.js dist --output-directory dist
|
||||
cd dist/src
|
||||
gcc -c -O3 -o duktape.o duktape.c
|
||||
gcc -c -O3 -o duk_module_node.o -I. ../extras/module-node/duk_module_node.c
|
||||
ar cr libduktape.a duktape.o
|
||||
ar cr libduktape_module.a duk_module_node.o
|
||||
install -m0644 ./*.a "$MINGW_PREFIX/lib"
|
||||
install -m0644 ./duk*.h "$MINGW_PREFIX/include"
|
||||
install -m0644 ../extras/module-node/duk_module_node.h "$MINGW_PREFIX/include"
|
||||
cd ../../..
|
||||
git clone https://github.com/ftk/quickjspp --depth=1
|
||||
cd quickjspp
|
||||
patch quickjs/quickjs-libc.c -i ../scripts/patches/0001-quickjs-libc-add-realpath-for-Windows.patch
|
||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .
|
||||
make -j4
|
||||
install -m644 quickjs/libquickjs.a "$MINGW_PREFIX/lib"
|
||||
install -m644 quickjs/quickjs.h quickjs/quickjs-libc.h "$MINGW_PREFIX/include/quickjs"
|
||||
install -m644 quickjspp.hpp "$MINGW_PREFIX/include"
|
||||
cd ..
|
||||
|
||||
git clone https://github.com/PerMalmberg/libcron --depth=1
|
||||
cd libcron
|
||||
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .
|
||||
make -j4
|
||||
install -m644 libcron/out/Release/liblibcron.a "$MINGW_PREFIX/lib"
|
||||
install -d "$MINGW_PREFIX/include/libcron/"
|
||||
install -m644 libcron/include/libcron/* "$MINGW_PREFIX/include/libcron/"
|
||||
install -d "$MINGW_PREFIX/include/date/"
|
||||
install -m644 libcron/externals/date/include/date/* "$MINGW_PREFIX/include/date/"
|
||||
cd ..
|
||||
|
||||
git clone https://github.com/Tencent/rapidjson --depth=1
|
||||
cd rapidjson
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
--- quickjs-libc.c 2021-03-23 15:04:09.604314700 +0800
|
||||
+++ patched.c 2021-03-23 15:04:35.109289500 +0800
|
||||
@@ -132,6 +132,29 @@
|
||||
static uint64_t os_pending_signals;
|
||||
static int (*os_poll_func)(JSContext *ctx);
|
||||
|
||||
+static char *_realpath(const char *path, char *resolved_path)
|
||||
+{
|
||||
+#if defined(_WIN32)
|
||||
+ BOOL allocated = FALSE;
|
||||
+ if(resolved_path == NULL)
|
||||
+ {
|
||||
+ resolved_path = (char*) malloc(PATH_MAX);
|
||||
+ allocated = TRUE;
|
||||
+ }
|
||||
+ DWORD len = GetFullPathNameA(path, PATH_MAX, resolved_path, NULL);
|
||||
+ if(!len || len >= PATH_MAX)
|
||||
+ {
|
||||
+ if(allocated)
|
||||
+ free(resolved_path);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ resolved_path[len] = '\0';
|
||||
+ return resolved_path;
|
||||
+#else
|
||||
+ return realpath(path, resolved_path);
|
||||
+#endif // _WIN32
|
||||
+}
|
||||
+
|
||||
static void js_std_dbuf_init(JSContext *ctx, DynBuf *s)
|
||||
{
|
||||
dbuf_init2(s, JS_GetRuntime(ctx), (DynBufReallocFunc *)js_realloc_rt);
|
||||
@@ -530,19 +553,19 @@
|
||||
return -1;
|
||||
if (!strchr(module_name, ':')) {
|
||||
strcpy(buf, "file://");
|
||||
-#if !defined(_WIN32)
|
||||
+//#if !defined(_WIN32)
|
||||
/* realpath() cannot be used with modules compiled with qjsc
|
||||
because the corresponding module source code is not
|
||||
necessarily present */
|
||||
if (use_realpath) {
|
||||
- char *res = realpath(module_name, buf + strlen(buf));
|
||||
+ char *res = _realpath(module_name, buf + strlen(buf));
|
||||
if (!res) {
|
||||
JS_ThrowTypeError(ctx, "realpath failure");
|
||||
JS_FreeCString(ctx, module_name);
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
-#endif
|
||||
+//#endif
|
||||
{
|
||||
pstrcat(buf, sizeof(buf), module_name);
|
||||
}
|
||||
@@ -2588,8 +2611,6 @@
|
||||
return JS_NewInt32(ctx, ret);
|
||||
}
|
||||
|
||||
-#if !defined(_WIN32)
|
||||
-
|
||||
/* return [path, errorcode] */
|
||||
static JSValue js_os_realpath(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
@@ -2601,7 +2622,7 @@
|
||||
path = JS_ToCString(ctx, argv[0]);
|
||||
if (!path)
|
||||
return JS_EXCEPTION;
|
||||
- res = realpath(path, buf);
|
||||
+ res = _realpath(path, buf);
|
||||
JS_FreeCString(ctx, path);
|
||||
if (!res) {
|
||||
buf[0] = '\0';
|
||||
@@ -2612,6 +2633,8 @@
|
||||
return make_string_error(ctx, buf, err);
|
||||
}
|
||||
|
||||
+#if !defined(_WIN32)
|
||||
+
|
||||
static JSValue js_os_symlink(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
@@ -3598,9 +3621,9 @@
|
||||
#endif
|
||||
JS_CFUNC_MAGIC_DEF("stat", 1, js_os_stat, 0 ),
|
||||
JS_CFUNC_DEF("utimes", 3, js_os_utimes ),
|
||||
+ JS_CFUNC_DEF("realpath", 1, js_os_realpath ),
|
||||
#if !defined(_WIN32)
|
||||
JS_CFUNC_MAGIC_DEF("lstat", 1, js_os_stat, 1 ),
|
||||
- JS_CFUNC_DEF("realpath", 1, js_os_realpath ),
|
||||
JS_CFUNC_DEF("symlink", 2, js_os_symlink ),
|
||||
JS_CFUNC_DEF("readlink", 1, js_os_readlink ),
|
||||
JS_CFUNC_DEF("exec", 1, js_os_exec ),
|
||||
Reference in New Issue
Block a user