mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2025-10-26 02:42:25 +00:00
Update build scripts
Optimize codes.
This commit is contained in:
@@ -17,7 +17,8 @@ ENDIF()
|
||||
#remove std::regex support since it is not compatible with group modifiers and slow
|
||||
#OPTION(USING_STD_REGEX "Use std::regex from C++ library instead of PCRE2." OFF)
|
||||
OPTION(USING_MALLOC_TRIM "Call malloc_trim after processing request to lower memory usage (Your system must support malloc_trim)." OFF)
|
||||
OPTION(USING_MBEDTLS "Use mbedTLS instead of OpenSSL for MD5 calculation." OFF)
|
||||
#now using internal MD5 calculation
|
||||
#OPTION(USING_MBEDTLS "Use mbedTLS instead of OpenSSL for MD5 calculation." OFF)
|
||||
|
||||
INCLUDE(CheckCXXSourceCompiles)
|
||||
CHECK_CXX_SOURCE_COMPILES(
|
||||
@@ -26,10 +27,6 @@ CHECK_CXX_SOURCE_COMPILES(
|
||||
void main(){std::to_string(0);}
|
||||
" HAVE_TO_STRING)
|
||||
|
||||
IF(APPLE)
|
||||
ADD_DEFINITIONS(-D_MACOS)
|
||||
ENDIF()
|
||||
|
||||
IF(HAVE_TO_STRING)
|
||||
ADD_DEFINITIONS(-DHAVE_TO_STRING)
|
||||
ENDIF()
|
||||
@@ -62,34 +59,20 @@ SET(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
FIND_PACKAGE(Threads REQUIRED)
|
||||
TARGET_LINK_LIBRARIES(subconverter ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
PKG_CHECK_MODULES(LIBEVENT libevent REQUIRED)
|
||||
FIND_PATH(LIBEVENT_INCLUDE_DIR NAMES event.h PATHS ${LIBEVENT_INCLUDE_DIRS})
|
||||
FIND_LIBRARY(LIBEVENT_LIBRARY NAMES event PATHS ${LIBEVENT_LIBRARY_DIRS})
|
||||
PKG_CHECK_MODULES(LIBEVENT libevent>=2.1.10 REQUIRED)
|
||||
LINK_DIRECTORIES(${LIBEVENT_LIBRARY_DIRS})
|
||||
INCLUDE_DIRECTORIES(${LIBEVENT_INCLUDE_DIR})
|
||||
TARGET_LINK_LIBRARIES(subconverter ${LIBEVENT_LIBRARY})
|
||||
TARGET_LINK_LIBRARIES(subconverter ${LIBEVENT_LIBRARIES})
|
||||
|
||||
FIND_PACKAGE(CURL 7.54.0 REQUIRED)
|
||||
PKG_CHECK_MODULES(CURL libcurl>=7.54.0 REQUIRED)
|
||||
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS})
|
||||
TARGET_LINK_LIBRARIES(subconverter ${CURL_LIBRARIES})
|
||||
ADD_DEFINITIONS(-DCURL_STATICLIB)
|
||||
|
||||
IF(USING_MBEDTLS STREQUAL "ON")
|
||||
FIND_PACKAGE(MbedTLS REQUIRED)
|
||||
INCLUDE_DIRECTORIES(${MBEDTLS_INCLUDE_DIRS})
|
||||
TARGET_LINK_LIBRARIES(subconverter ${MBEDCRYPTO_LIBRARY})
|
||||
ADD_DEFINITIONS(-DUSE_MBEDTLS)
|
||||
ELSE()
|
||||
FIND_PACKAGE(OpenSSL 1.1.0 REQUIRED)
|
||||
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
|
||||
TARGET_LINK_LIBRARIES(subconverter ${OPENSSL_LIBRARIES})
|
||||
ENDIF()
|
||||
|
||||
FIND_PACKAGE(Rapidjson REQUIRED)
|
||||
INCLUDE_DIRECTORIES(${RAPIDJSON_INCLUDE_DIRS})
|
||||
|
||||
PKG_CHECK_MODULES(YAML_CPP yaml-cpp REQUIRED)
|
||||
FIND_LIBRARY(YAML_CPP_LIBRARY NAMES yaml-cpp yaml-cppd PATHS ${YAML_CPP_LIBRARY_DIRS})
|
||||
PKG_CHECK_MODULES(YAML_CPP yaml-cpp>=0.6.3 REQUIRED)
|
||||
LINK_DIRECTORIES(${YAML_CPP_LIBRARY_DIRS})
|
||||
INCLUDE_DIRECTORIES(${YAML_CPP_INCLUDE_DIRS})
|
||||
TARGET_LINK_LIBRARIES(subconverter ${YAML_CPP_LIBRARY})
|
||||
|
||||
@@ -2,7 +2,13 @@
|
||||
set -xe
|
||||
|
||||
apk add gcc g++ build-base linux-headers cmake make autoconf automake libtool python2
|
||||
apk add openssl-dev openssl-libs-static curl curl-dev curl-static nghttp2-static zlib-dev rapidjson-dev libevent-dev libevent-static zlib-static pcre2-dev bzip2-static
|
||||
apk add mbedtls-dev mbedtls-static nghttp2-dev nghttp2-static zlib-dev rapidjson-dev libevent-dev libevent-static zlib-static pcre2-dev
|
||||
|
||||
git clone https://github.com/curl/curl --depth=1
|
||||
cd curl
|
||||
cmake -DCMAKE_USE_MBEDTLS=ON -DHTTP_ONLY=ON -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_USE_LIBSSH2=OFF -DUSE_NGHTTP2=ON . > /dev/null
|
||||
make install -j2 > /dev/null
|
||||
cd ..
|
||||
|
||||
git clone https://github.com/jbeder/yaml-cpp --depth=1
|
||||
cd yaml-cpp
|
||||
@@ -14,21 +20,22 @@ git clone https://github.com/svaarala/duktape --depth=1
|
||||
cd duktape
|
||||
python2 -m ensurepip
|
||||
pip2 install PyYAML
|
||||
mkdir dist
|
||||
python2 util/dist.py
|
||||
cd dist/src
|
||||
cd dist/source/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 ./*.a /usr/lib
|
||||
install -m0644 ./duk*.h /usr/include
|
||||
install -m0644 ../extras/module-node/duk_module_node.h /usr/include
|
||||
cd ../../..
|
||||
cd ../../../..
|
||||
|
||||
cmake .
|
||||
make -j2
|
||||
rm subconverter
|
||||
g++ -o base/subconverter CMakeFiles/subconverter.dir/src/*.o -static -lpcre2-8 -levent -lyaml-cpp -lcurl -lnghttp2 -lssl -lcrypto -lz -lbz2 -lduktape -lduktape_module -ldl -lpthread -O3 -s
|
||||
g++ -o base/subconverter $(find CMakeFiles/subconverter.dir/src/ -name "*.o") -static -lpcre2-8 -levent -lyaml-cpp -L/usr/lib64 -lcurl -lnghttp2 -lmbedtls -lmbedcrypto -lmbedx509 -lz -lduktape -lduktape_module -O3 -s
|
||||
|
||||
cd base
|
||||
chmod +rx subconverter
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#!/bin/bash
|
||||
set -xe
|
||||
|
||||
brew reinstall rapidjson libevent zlib pcre2 bzip2 libssh2 pkgconfig
|
||||
brew reinstall rapidjson libevent zlib pcre2 pkgconfig
|
||||
|
||||
git clone https://github.com/curl/curl --depth=1
|
||||
cd curl
|
||||
#./buildconf > /dev/null
|
||||
#./configure --with-ssl=/usr/local/opt/openssl@1.1 --without-mbedtls --disable-ldap --disable-ldaps --disable-rtsp --without-libidn2 > /dev/null
|
||||
cmake -DHTTP_ONLY=ON -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1 . > /dev/null
|
||||
cmake -DCMAKE_USE_SECTRANSP=ON -DHTTP_ONLY=ON -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_USE_LIBSSH2=OFF . > /dev/null
|
||||
make -j8 > /dev/null
|
||||
cd ..
|
||||
|
||||
@@ -20,33 +20,29 @@ cd ..
|
||||
git clone https://github.com/svaarala/duktape --depth=1
|
||||
cd duktape
|
||||
pip2 install PyYAML
|
||||
mkdir dist
|
||||
python2 util/dist.py
|
||||
cd dist/src
|
||||
cd dist/source/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 ./*.a /usr/local/lib
|
||||
install -m0644 ./duk*.h /usr/local/include
|
||||
install -m0644 ../extras/module-node/duk_module_node.h /usr/local/include
|
||||
cd ../../..
|
||||
cd ../../../..
|
||||
|
||||
cp curl/lib/libcurl.a .
|
||||
cp yaml-cpp/libyaml-cpp.a .
|
||||
cp duktape/dist/src/*.a .
|
||||
cp /usr/local/lib/libevent.a .
|
||||
cp /usr/local/opt/zlib/lib/libz.a .
|
||||
cp /usr/local/opt/openssl@1.1/lib/libssl.a .
|
||||
cp /usr/local/opt/openssl@1.1/lib/libcrypto.a .
|
||||
cp /usr/local/lib/libpcre2-8.a .
|
||||
cp /usr/local/opt/bzip2/lib/libbz2.a .
|
||||
cp /usr/local/lib/libssh2.a .
|
||||
|
||||
export CMAKE_CXX_FLAGS="-I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/curl/include"
|
||||
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1 .
|
||||
cmake .
|
||||
make -j8
|
||||
rm subconverter
|
||||
c++ -Xlinker -unexported_symbol -Xlinker "*" -o base/subconverter CMakeFiles/subconverter.dir/src/*.o libpcre2-8.a libevent.a libcurl.a libz.a libssl.a libcrypto.a libyaml-cpp.a libbz2.a libssh2.a libduktape.a libduktape_module.a -ldl -lpthread -O3
|
||||
c++ -Xlinker -unexported_symbol -Xlinker "*" -o base/subconverter $(find CMakeFiles/subconverter.dir/src/ -name "*.o") $(find . -name "*.a") -O3
|
||||
|
||||
cd base
|
||||
chmod +rx subconverter
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
#define DO_CONCAT(a,b) CONCAT(a,b)
|
||||
template <typename T> class __defer_struct final {private: T fn; bool __cancelled = false; public: __defer_struct(T func) : fn(std::move(func)) {} ~__defer_struct() {if(!__cancelled) fn();} void cancel() {__cancelled = true;} };
|
||||
//#define defer(x) std::unique_ptr<void> DO_CONCAT(__defer_deleter_,__LINE__) (nullptr, [&](...){x});
|
||||
#define defer(x) __defer_struct DO_CONCAT(__defer_deleter,__COUNTER__) ([&](...){x;});
|
||||
#define defer(x) __defer_struct DO_CONCAT(__defer_deleter,__LINE__) ([&](...){x;});
|
||||
|
||||
#define getbit(x,n) (((int)x < 1) ? 0 : ((x >> (n - 1)) & 1))
|
||||
#define setbit(x,n,v) x ^= (-v ^ x) & (1UL << (n - 1))
|
||||
#define GETBIT(x,n) (((int)x < 1) ? 0 : ((x >> (n - 1)) & 1))
|
||||
#define SETBIT(x,n,v) x ^= (-v ^ x) & (1UL << (n - 1))
|
||||
|
||||
typedef std::string::size_type string_size;
|
||||
typedef std::vector<std::string> string_array;
|
||||
|
||||
@@ -1744,7 +1744,7 @@ std::string netchToSingle(std::vector<nodeInfo> &nodes, int types, extra_setting
|
||||
std::string protocol, protoparam, obfs, obfsparam;
|
||||
std::string id, aid, transproto, faketype, host, path, quicsecure, quicsecret;
|
||||
std::string proxyStr, allLinks;
|
||||
bool tlssecure, ss = getbit(types, 1), ssr = getbit(types, 2), vmess = getbit(types, 3), trojan = getbit(types, 4);
|
||||
bool tlssecure, ss = GETBIT(types, 1), ssr = GETBIT(types, 2), vmess = GETBIT(types, 3), trojan = GETBIT(types, 4);
|
||||
|
||||
for(nodeInfo &x : nodes)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user