From 3a17e63f7e4822fedeecfa6d576bd32d5545a699 Mon Sep 17 00:00:00 2001 From: Lai Zenan Date: Sat, 23 Mar 2024 06:09:22 +0800 Subject: [PATCH 1/4] docs: Add instruction for furture contributors --- .gitignore | 16 ++++++ CONTRIBUTING.md | 102 +++++++++++++++++++++++++++++++++ scripts/dev.windows.release.sh | 61 ++++++++++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 CONTRIBUTING.md create mode 100644 scripts/dev.windows.release.sh diff --git a/.gitignore b/.gitignore index 567b77607..0ee33ff2e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,19 @@ subconverter.exe cmake-build-debug .idea base/cache + +# Build files +/CmakeFiles +/CMakeCache.txt +/Makefile +/cmake_install.cmake +/tmp +/subconverter + +# Dependencies for development +/curl +/libcron +/quickjspp +/toml11 +/yaml-cpp +/rapidjson diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..4a85125f7 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,102 @@ +# Contributing to Subconverter + +Welcome, and thank you for your interest in contributing to subconverter! + +## Reporting Issues + +- Check if the issue already exists. +- Use the issue template to create a new issue. +- Be as detailed as possible. + +## Feature Requests + +- Check the feature doesn't already exist. +- Use the feature request template to submit a new request. + +## Pull Requests + +- Fork the repository. +- Create a new branch for your changes. +- Follow the coding style and guidelines. +- Test the features as much as you can. +- Update the documentation as needed. +- Submit a pull request with a detailed description of your changes. + +## Setting Up Your Development Environment + +To contribute to Subconverter, you'll need to set up your development environment. Here's a brief overview: + +### Windows Build Instructions + +1. install the prerequisites: +for example if you are using msys2 and mingw-w64 for compilation: +```shell +pacman -S base-devel git mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-pcre2 patch python +``` + +2. run script to initialize the project for development: +```shell +sh scripts/dev.windows.release.sh +``` + +3. debug the project with GDB: +```shell +gdb ./subconverter/subconverter.exe +``` +or use VSCode with the following configuration: +```json +{ + "name": "C/C++: g++.exe build and debug active file", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/subconverter/subconverter.exe", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}/subconverter/", + "environment": [], + "externalConsole": true, + "MIMode": "gdb", + "miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set Disassembly Flavor to Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ], +} +``` + +4. increamental build during development: + +```shell +make -j4 && cp subconverter.exe subconverter/subconverter.exe +``` + +### Linux / macOS + +1. install the prerequisites: + +You should install all the following prequisites via your package manager. +- cmake +- pcre2 +- patch +- python + +2. run the script to initialize the project for development: + +```shell +sh scripts/build.macos.release.sh +``` + +3. run the executable for test: +```shell +./subconverter +``` + +Thank you for contributing to subconverter! diff --git a/scripts/dev.windows.release.sh b/scripts/dev.windows.release.sh new file mode 100644 index 000000000..26d708590 --- /dev/null +++ b/scripts/dev.windows.release.sh @@ -0,0 +1,61 @@ +#!/bin/bash +set -xe +# remove all old deps +rm -rf curl libcron quickjspp rapidjson toml11 yaml-cpp +# remove tmp folder +rm -rf tmp + +git clone https://github.com/curl/curl --depth=1 --branch curl-8_4_0 +cd curl +cmake -DCMAKE_BUILD_TYPE=Debug -DCURL_USE_LIBSSH2=OFF -DHTTP_ONLY=ON -DCURL_USE_SCHANNEL=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF -DCMAKE_INSTALL_PREFIX="$MINGW_PREFIX" -G "Unix Makefiles" -DHAVE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF . +make install -j4 +cd .. + +git clone https://github.com/jbeder/yaml-cpp --depth=1 +cd yaml-cpp +cmake -DCMAKE_BUILD_TYPE=Debug -DYAML_CPP_BUILD_TESTS=OFF -DYAML_CPP_BUILD_TOOLS=OFF -DCMAKE_INSTALL_PREFIX="$MINGW_PREFIX" -G "Unix Makefiles" . +make install -j4 +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=Debug . +make quickjs -j4 +install -d "$MINGW_PREFIX/lib/quickjs/" +install -m644 quickjs/libquickjs.a "$MINGW_PREFIX/lib/quickjs/" +install -d "$MINGW_PREFIX/include/quickjs" +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 +git submodule update --init +cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="$MINGW_PREFIX" . +make libcron install -j4 +cd .. + +git clone https://github.com/Tencent/rapidjson --depth=1 +cd rapidjson +cmake -DRAPIDJSON_BUILD_DOC=OFF -DRAPIDJSON_BUILD_EXAMPLES=OFF -DRAPIDJSON_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX="$MINGW_PREFIX" -G "Unix Makefiles" . +make install -j4 +cd .. + +git clone https://github.com/ToruNiina/toml11 --depth=1 +cd toml11 +cmake -DCMAKE_INSTALL_PREFIX="$MINGW_PREFIX" -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=11 . +make install -j4 +cd .. + +python -m ensurepip +python -m pip install gitpython +python scripts/update_rules.py -c scripts/rules_config.conf + +rm -f C:/Strawberry/perl/bin/pkg-config C:/Strawberry/perl/bin/pkg-config.bat +cmake -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles" . +make -j4 +rm subconverter.exe +# shellcheck disable=SC2046 +g++ $(find CMakeFiles/subconverter.dir/src -name "*.obj") curl/lib/libcurl-d.a -o base/subconverter.exe -static -lbcrypt -lpcre2-8 -l:quickjs/libquickjs.a -llibcron -lyaml-cpp -liphlpapi -lcrypt32 -lws2_32 -lwsock32 -lz -s +cp -rf base subconverter From 8ab27a39038c28a4fef2c3dbfa610987750c33bc Mon Sep 17 00:00:00 2001 From: laizenan Date: Sun, 24 Mar 2024 11:39:12 -0700 Subject: [PATCH 2/4] feat: update scripts for macos development --- .gitignore | 2 + CONTRIBUTING.md | 13 +++- scripts/build.macos.dev.sh | 73 +++++++++++++++++++ ...indows.release.sh => build.windows.dev.sh} | 0 4 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 scripts/build.macos.dev.sh rename scripts/{dev.windows.release.sh => build.windows.dev.sh} (100%) diff --git a/.gitignore b/.gitignore index 0ee33ff2e..c0ed146dd 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ base/cache /cmake_install.cmake /tmp /subconverter +/base/subconverter +/*.a # Dependencies for development /curl diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4a85125f7..3434ec92c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,7 +36,7 @@ pacman -S base-devel git mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x 2. run script to initialize the project for development: ```shell -sh scripts/dev.windows.release.sh +sh scripts/build.windows.dev.sh ``` 3. debug the project with GDB: @@ -78,7 +78,7 @@ or use VSCode with the following configuration: make -j4 && cp subconverter.exe subconverter/subconverter.exe ``` -### Linux / macOS +### macOS 1. install the prerequisites: @@ -88,10 +88,15 @@ You should install all the following prequisites via your package manager. - patch - python -2. run the script to initialize the project for development: +for macos run +```shell +brew reinstall rapidjson zlib pcre2 pkgconfig +``` + +1. run the script to initialize the project for development: ```shell -sh scripts/build.macos.release.sh +sh scripts/build.macos.dev.sh ``` 3. run the executable for test: diff --git a/scripts/build.macos.dev.sh b/scripts/build.macos.dev.sh new file mode 100644 index 000000000..08782cec3 --- /dev/null +++ b/scripts/build.macos.dev.sh @@ -0,0 +1,73 @@ +#!/bin/bash +set -xe + +# remove all old deps +rm -rf curl libcron quickjspp rapidjson toml11 yaml-cpp +# remove tmp folder +rm -rf tmp + +# brew reinstall rapidjson zlib pcre2 pkgconfig + +#git clone https://github.com/curl/curl --depth=1 --branch curl-7_88_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 -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 .. + +git clone https://github.com/jbeder/yaml-cpp --depth=1 +cd yaml-cpp +cmake -DCMAKE_BUILD_TYPE=Debug -DYAML_CPP_BUILD_TESTS=OFF -DYAML_CPP_BUILD_TOOLS=OFF . > /dev/null +make install -j8 > /dev/null +cd .. + +git clone https://github.com/ftk/quickjspp --depth=1 +cd quickjspp +cmake -DCMAKE_BUILD_TYPE=Debug . +make quickjs -j8 +install -d /usr/local/lib/quickjs/ +install -m644 quickjs/libquickjs.a /usr/local/lib/quickjs/ +install -d /usr/local/include/quickjs/ +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 +git submodule update --init +cmake -DCMAKE_BUILD_TYPE=Debug . +make libcron install -j8 +install -m644 libcron/out/Debug/liblibcron.a /usr/local/lib/ +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 .. + +git clone https://github.com/ToruNiina/toml11 --depth=1 +cd toml11 +cmake -DCMAKE_CXX_STANDARD=11 . +make install -j4 +cd .. + +cp /usr/local/opt/zlib/lib/libz.a . +cp /usr/local/lib/libpcre2-8.a . + +cmake -DCMAKE_BUILD_TYPE=Debug . +make -j8 +rm subconverter +# shellcheck disable=SC2046 +c++ -Xlinker -unexported_symbol -Xlinker "*" -o base/subconverter -framework CoreFoundation -framework Security $(find CMakeFiles/subconverter.dir/src/ -name "*.o") $(find . -name "*.a") -lcurl -O3 + +python -m ensurepip +python -m pip install gitpython +python scripts/update_rules.py -c scripts/rules_config.conf + +cd base +chmod +rx subconverter +chmod +r ./* +cd .. +mv base subconverter + +set +xe diff --git a/scripts/dev.windows.release.sh b/scripts/build.windows.dev.sh similarity index 100% rename from scripts/dev.windows.release.sh rename to scripts/build.windows.dev.sh From 136d4f90cb5e442b67b4e11c9bece4e4c61e1fad Mon Sep 17 00:00:00 2001 From: laizenan Date: Tue, 26 Mar 2024 23:33:12 +0800 Subject: [PATCH 3/4] feat: update contributing.md for macos --- CONTRIBUTING.md | 6 ++++++ scripts/build.macos.dev.sh | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3434ec92c..2197514ad 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -99,6 +99,12 @@ brew reinstall rapidjson zlib pcre2 pkgconfig sh scripts/build.macos.dev.sh ``` +2. increamental build during development: + +```shell +make -j && cp subconverter subconverter/subconverter +``` + 3. run the executable for test: ```shell ./subconverter diff --git a/scripts/build.macos.dev.sh b/scripts/build.macos.dev.sh index 08782cec3..6fd37795d 100644 --- a/scripts/build.macos.dev.sh +++ b/scripts/build.macos.dev.sh @@ -68,6 +68,6 @@ cd base chmod +rx subconverter chmod +r ./* cd .. -mv base subconverter +cp base subconverter set +xe From 8cf2f04fa8644928fcb5fec077abe077a1856c39 Mon Sep 17 00:00:00 2001 From: Lai Zenan Date: Mon, 9 Sep 2024 02:56:08 +0800 Subject: [PATCH 4/4] feat: add script for ubuntu setup --- scripts/build.ubuntu.dev.sh | 61 +++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 scripts/build.ubuntu.dev.sh diff --git a/scripts/build.ubuntu.dev.sh b/scripts/build.ubuntu.dev.sh new file mode 100644 index 000000000..cf81613b9 --- /dev/null +++ b/scripts/build.ubuntu.dev.sh @@ -0,0 +1,61 @@ +#!/bin/bash +set -xe +# remove all old deps +sudo rm -rf curl libcron quickjspp rapidjson toml11 yaml-cpp +# remove tmp folder +sudo rm -rf tmp + +sudo apt install gcc build-essential g++ cmake make autoconf automake libtool python2 python3 python3-pip +sudo apt install libmbedtls-dev zlib1g-dev rapidjson-dev libpcre2-dev + +git clone https://github.com/curl/curl --depth=1 --branch curl-8_4_0 +cd curl +cmake -DCURL_USE_MBEDTLS=ON -DHTTP_ONLY=ON -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_USE_LIBSSH2=OFF -DBUILD_CURL_EXE=OFF . > /dev/null +sudo make install -j2 > /dev/null +cd .. + +git clone https://github.com/jbeder/yaml-cpp --depth=1 +cd yaml-cpp +cmake -DCMAKE_BUILD_TYPE=Release -DYAML_CPP_BUILD_TESTS=OFF -DYAML_CPP_BUILD_TOOLS=OFF . > /dev/null +sudo make install -j3 > /dev/null +cd .. + +git clone https://github.com/ftk/quickjspp --depth=1 +cd quickjspp +cmake -DCMAKE_BUILD_TYPE=Release . +make quickjs -j3 > /dev/null +sudo install -d /usr/lib/quickjs/ +sudo install -m644 quickjs/libquickjs.a /usr/lib/quickjs/ +sudo install -d /usr/include/quickjs/ +sudo install -m644 quickjs/quickjs.h quickjs/quickjs-libc.h /usr/include/quickjs/ +sudo install -m644 quickjspp.hpp /usr/include/ +cd .. + +git clone https://github.com/PerMalmberg/libcron --depth=1 +cd libcron +git submodule update --init +cmake -DCMAKE_BUILD_TYPE=Release . +sudo make libcron install -j3 +cd .. + +git clone https://github.com/ToruNiina/toml11 --branch="v3.7.1" --depth=1 +cd toml11 +cmake -DCMAKE_CXX_STANDARD=11 . +sudo make install -j4 +cd .. + +# export PKG_CONFIG_PATH=/usr/lib/pkgconfig +cmake -DCMAKE_BUILD_TYPE=Release . +make -j3 +rm subconverter +# shellcheck disable=SC2046 +g++ -o base/subconverter $(find CMakeFiles/subconverter.dir/src/ -name "*.o") -static -lpcre2-8 -lyaml-cpp -L/usr/lib64 -lcurl -lmbedtls -lmbedcrypto -lmbedx509 -lz -l:quickjs/libquickjs.a -llibcron -O3 -s + +python3 -m pip install gitpython +python3 scripts/update_rules.py -c scripts/rules_config.conf + +cd base +chmod +rx subconverter +chmod +r ./* +cd .. +mv base subconverter