Skip to content

Commit 0264e7d

Browse files
authored
[IMPROVEMENT] Update Rust and fix windows build (#1480)
* fix: bump leptonica-sys to 0.4.3 and update Cargo.lock * fix: bump rust version to 1.57.0 and build vcpkg for window hardsubx builds * fix: add Bcrypt dependency * fix: switch to rust stable * chore: bump package versions * fix: try to remove i686 to fix error * fix: install tesseract and lint fixes * fix: try using ffmpeg the third * fix: include headers * fix: add rsmpeg * fix: switch default triplet to static md * fix: import errors * fix: directory path * fix: pre build commands * fix: update vcxproj * fix: linux ci * fix: ci fixes * chore: lint fixes * fix: error * fix: copy include files * fix: ci error * fix: link swresample lib * fix: some errors * fix: include directory path and include all libraries * fix: try to add library directories * fix: fixes in libraries * fix: formatting ci * fix: mflat errors * fix: libcurl * fix: preprocessor definitions * fix: add libcrypto * fix: remove lib_hash to fix conflicts (we have libcrypto already) * fix: add avcodec and avformat dependencies on windows * fix: add remaining deps that may fix the build * fix: add crypt depdency * fix: rename conflicting names * Revert "fix: remove lib_hash to fix conflicts (we have libcrypto already)" This reverts commit f57ff71. * fix: prefix with CC_ * fix: post build actions * fix: ocr error * Revert "fix: ocr error" This reverts commit 9259945. * fix: xcopy error * fix: generated file name for x64 * fix: ocr error * fix: add item group at top to see if it works * fix: remove unwanted headers, removed \\ from VCPKG_ROOT, remove unwanted includes in vcxproj * fix: add libpng for non hardsubx, comment the broken ocr code again * fix: libpng path * feat: add lib png headers in ClCompile * fix: png.h not found * fix: last try for ocr fix * fix: libpng not found * fix: cl compile headers * fix: libpng and ocr * fix: libpng error * fix: redefinition error * fix: zlib for non hardsubx * fix: lib names * fix: zlib.h not found
1 parent 257388b commit 0264e7d

File tree

181 files changed

+793
-34787
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+793
-34787
lines changed

.github/workflows/build_linux.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Build CCExtractor on Linux
22

33
on:
4+
workflow_dispatch:
45
push:
56
paths:
67
- '.github/workflows/build_linux.yml'
@@ -73,11 +74,16 @@ jobs:
7374
steps:
7475
- uses: actions/checkout@v3
7576
- name: dependencies
76-
run: sudo apt update && sudo apt install libtesseract-dev libavformat-dev libswscale-dev yasm
77+
run: sudo apt update && sudo apt install libtesseract-dev libavformat-dev libavdevice-dev libswscale-dev yasm
7778
- name: cmake
78-
run: mkdir build && cd build && cmake -DWITH_OCR=ON -DWITH_HARDSUBX=ON ../src
79+
run: |
80+
mkdir build && cd build
81+
cmake -DWITH_OCR=ON -DWITH_HARDSUBX=ON ../src
7982
- name: build
80-
run: make -j$(nproc)
83+
run: |
84+
FFMPEG_INCLUDE_DIR=/usr/include/x86_64-linux-gnu \
85+
FFMPEG_PKG_CONFIG_PATH=/usr/x86_64-linux-gnu/lib/pkgconfig \
86+
make -j$(nproc)
8187
working-directory: build
8288
- name: Display version information
8389
run: ./build/ccextractor --version
@@ -96,7 +102,7 @@ jobs:
96102
restore-keys: ${{ runner.os }}-cargo-
97103
- uses: actions-rs/toolchain@v1
98104
with:
99-
toolchain: 1.56.0
105+
toolchain: stable
100106
override: true
101107
- name: build
102108
run: cargo build

.github/workflows/build_windows.yml

Lines changed: 59 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Build CCExtractor on Windows
22

33
on:
4+
workflow_dispatch:
45
push:
56
paths:
67
- ".github/workflows/build_windows.yml"
@@ -27,16 +28,27 @@ jobs:
2728
run: choco install llvm
2829
- uses: actions-rs/toolchain@v1
2930
with:
30-
toolchain: 1.56.0
31+
toolchain: stable
3132
override: true
3233
- name: Install Win 10 SDK
3334
uses: ilammy/msvc-dev-cmd@v1
35+
- name: Setup Vcpkg
36+
id: vcpkg
37+
uses: friendlyanon/setup-vcpkg@v1
38+
with:
39+
committish: "2023.02.24"
40+
cache-version: "1"
41+
ignore-reserve-cache-error: true
42+
- name: Install dependencies
43+
run: cd vcpkg && vcpkg integrate install && vcpkg install libpng --triplet x64-windows-static-md
3444
- name: build Release
3545
env:
3646
LIBCLANG_PATH: "C:\\Program Files\\LLVM\\lib"
3747
LLVM_CONFIG_PATH: "C:\\Program Files\\LLVM\\bin\\llvm-config"
3848
CARGO_TARGET_DIR: "..\\..\\windows"
3949
BINDGEN_EXTRA_CLANG_ARGS: -fmsc-version=0
50+
VCPKG_DEFAULT_TRIPLET: x64-windows-static-md
51+
VCPKG_ROOT: ${{ github.workspace }}\vcpkg
4052
run: msbuild ccextractor.sln /p:Configuration=Release /p:Platform=x64
4153
working-directory: ./windows
4254
- name: Display version information
@@ -59,16 +71,27 @@ jobs:
5971
run: choco install llvm
6072
- uses: actions-rs/toolchain@v1
6173
with:
62-
toolchain: 1.56.0
74+
toolchain: stable
6375
override: true
6476
- name: Install Win 10 SDK
6577
uses: ilammy/msvc-dev-cmd@v1
78+
- name: Setup Vcpkg
79+
id: vcpkg
80+
uses: friendlyanon/setup-vcpkg@v1
81+
with:
82+
committish: "2023.02.24"
83+
cache-version: "1"
84+
ignore-reserve-cache-error: true
85+
- name: Install dependencies
86+
run: cd vcpkg && vcpkg integrate install && vcpkg install libpng --triplet x64-windows-static-md
6687
- name: build Debug
6788
env:
6889
LIBCLANG_PATH: "C:\\Program Files\\LLVM\\lib"
6990
LLVM_CONFIG_PATH: "C:\\Program Files\\LLVM\\bin\\llvm-config"
7091
CARGO_TARGET_DIR: "..\\..\\windows"
7192
BINDGEN_EXTRA_CLANG_ARGS: -fmsc-version=0
93+
VCPKG_DEFAULT_TRIPLET: x64-windows-static-md
94+
VCPKG_ROOT: ${{ github.workspace }}\vcpkg
7295
run: msbuild ccextractor.sln /p:Configuration=Debug /p:Platform=x64
7396
working-directory: ./windows
7497
- name: Display version information
@@ -89,34 +112,41 @@ jobs:
89112
- name: Setup MSBuild.exe
90113
uses: microsoft/setup-msbuild@v1.3.1
91114
- name: Install llvm and clang
92-
uses: egor-tensin/setup-clang@v1
93-
with:
94-
version: latest
95-
platform: x86
115+
run: choco install llvm
96116
- uses: actions-rs/toolchain@v1
97117
with:
98-
toolchain: 1.56.0
118+
toolchain: stable
99119
override: true
100-
target: i686-pc-windows-msvc
101120
- name: Install Win 10 SDK
102121
uses: ilammy/msvc-dev-cmd@v1
122+
- name: Setup Vcpkg
123+
id: vcpkg
124+
uses: friendlyanon/setup-vcpkg@v1
125+
with:
126+
committish: "2023.02.24"
127+
cache-version: "1"
128+
ignore-reserve-cache-error: true
129+
- name: Install dependencies
130+
run: cd vcpkg && vcpkg integrate install && vcpkg install leptonica tesseract ffmpeg --triplet x64-windows-static-md
103131
- name: build Release-Full
104132
env:
105133
LIBCLANG_PATH: "C:\\Program Files\\LLVM\\lib"
106134
LLVM_CONFIG_PATH: "C:\\Program Files\\LLVM\\bin\\llvm-config"
107135
CARGO_TARGET_DIR: "..\\..\\windows"
108136
BINDGEN_EXTRA_CLANG_ARGS: -fmsc-version=0
109-
run: msbuild ccextractor.sln /p:Configuration=Release-Full /p:Platform=Win32
137+
VCPKG_DEFAULT_TRIPLET: x64-windows-static-md
138+
VCPKG_ROOT: ${{ github.workspace }}\vcpkg
139+
run: msbuild ccextractor.sln /p:Configuration=Release-Full /p:Platform=x64
110140
working-directory: ./windows
111141
- name: Display version information
112142
run: ./ccextractorwinfull.exe --version
113-
working-directory: ./windows/Release-Full
143+
working-directory: ./windows/x64/Release-Full
114144
- uses: actions/upload-artifact@v3
115145
with:
116146
name: CCExtractor Windows OCR and HardSubX Release build
117147
path: |
118-
./windows/Release-Full/ccextractorwinfull.exe
119-
./windows/Release-Full/*.dll
148+
./windows/x64/Release-Full/ccextractorwinfull.exe
149+
./windows/x64/Release-Full/*.dll
120150
build_ocr_hardsubx_debug:
121151
runs-on: windows-2019
122152
steps:
@@ -125,15 +155,20 @@ jobs:
125155
- name: Setup MSBuild.exe
126156
uses: microsoft/setup-msbuild@v1.3.1
127157
- name: Install llvm and clang
128-
uses: egor-tensin/setup-clang@v1
158+
run: choco install llvm
159+
- name: Setup Vcpkg
160+
id: vcpkg
161+
uses: friendlyanon/setup-vcpkg@v1
129162
with:
130-
version: latest
131-
platform: x86
163+
committish: "2023.02.24"
164+
cache-version: "1"
165+
ignore-reserve-cache-error: true
166+
- name: Install dependencies
167+
run: cd vcpkg && vcpkg integrate install && vcpkg install leptonica tesseract ffmpeg --triplet x64-windows-static-md
132168
- uses: actions-rs/toolchain@v1
133169
with:
134-
toolchain: 1.56.0
170+
toolchain: stable
135171
override: true
136-
target: i686-pc-windows-msvc
137172
- name: Install Win 10 SDK
138173
uses: ilammy/msvc-dev-cmd@v1
139174
- name: build Debug-Full
@@ -142,15 +177,17 @@ jobs:
142177
LLVM_CONFIG_PATH: "C:\\Program Files\\LLVM\\bin\\llvm-config"
143178
CARGO_TARGET_DIR: "..\\..\\windows"
144179
BINDGEN_EXTRA_CLANG_ARGS: -fmsc-version=0
145-
run: msbuild ccextractor.sln /p:Configuration=Debug-Full /p:Platform=Win32
180+
VCPKG_DEFAULT_TRIPLET: x64-windows-static-md
181+
VCPKG_ROOT: ${{ github.workspace }}\vcpkg
182+
run: msbuild ccextractor.sln /p:Configuration=Debug-Full /p:Platform=x64
146183
working-directory: ./windows
147184
- name: Display version information
148185
run: ./ccextractorwinfull.exe --version
149-
working-directory: ./windows/Debug-Full
186+
working-directory: ./windows/x64/Debug-Full
150187
- uses: actions/upload-artifact@v3
151188
with:
152189
name: CCExtractor Windows OCR and HardSubX Debug build
153190
path: |
154-
./windows/Debug-Full/ccextractorwinfull.exe
155-
./windows/Debug-Full/ccextractorwinfull.pdb
156-
./windows/Debug-Full/*.dll
191+
./windows/x64/Debug-Full/ccextractorwinfull.exe
192+
./windows/x64/Debug-Full/ccextractorwinfull.pdb
193+
./windows/x64/Debug-Full/*.dll

.github/workflows/format.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@ jobs:
4242
restore-keys: ${{ runner.os }}-cargo-
4343
- uses: actions-rs/toolchain@v1
4444
with:
45-
toolchain: 1.56.0
45+
toolchain: stable
4646
override: true
4747
components: rustfmt, clippy
4848
- name: dependencies
49-
run: sudo apt update && sudo apt install libtesseract-dev libavformat-dev libswscale-dev yasm
49+
run: sudo apt update && sudo apt install libtesseract-dev libavformat-dev libavdevice-dev libswscale-dev yasm
5050
- name: rustfmt
5151
run: cargo fmt --all -- --check
5252
- name: clippy
53-
run: cargo clippy --all-features -- -D warnings
53+
run: |
54+
FFMPEG_INCLUDE_DIR=/usr/include/x86_64-linux-gnu \
55+
FFMPEG_PKG_CONFIG_PATH=/usr/x86_64-linux-gnu/lib/pkgconfig \
56+
cargo clippy --all-features -- -D warnings

.github/workflows/release.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ jobs:
2121
uses: egor-tensin/setup-clang@v1
2222
with:
2323
version: latest
24-
platform: x86
24+
platform: x64
2525
- uses: actions-rs/toolchain@v1
2626
with:
27-
toolchain: 1.56.0
27+
toolchain: stable
2828
override: true
29-
target: i686-pc-windows-msvc
3029
- name: Install Win 10 SDK
3130
uses: ilammy/msvc-dev-cmd@v1
3231
- name: build Release-Full

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,7 @@ src/rust/CMakeCache.txt
150150
src/rust/Makefile
151151
src/rust/cmake_install.cmake
152152
src/rust/target/
153+
windows/ccx_rust.lib
154+
windows/*/debug/*
155+
windows/*/CACHEDIR.TAG
156+
windows/.rustc_info.json

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ if(WIN32)
128128
include_directories ("${PROJECT_SOURCE_DIR}/thirdparty/win_spec_incld/")
129129
include_directories ("${PROJECT_SOURCE_DIR}/thirdparty/win_iconv/")
130130
aux_source_directory ("${PROJECT_SOURCE_DIR}/thirdparty/win_iconv/" SOURCEFILE)
131-
set (EXTRA_LIBS ${EXTRA_LIBS} ws2_32 winmm)
131+
set (EXTRA_LIBS ${EXTRA_LIBS} ws2_32 winmm Bcrypt)
132132
else (WIN32)
133133
# Adding some platform specific library path
134134
link_directories (/opt/local/lib)

src/lib_ccx/ccx_encoders_helpers.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "ccx_decoders_structs.h"
77
#include "ccx_decoders_608.h"
88
#include "ccx_encoders_common.h"
9-
#include "png.h"
9+
#include <png.h>
1010

1111
extern struct word_list capitalization_list;
1212
extern struct word_list profane;
@@ -15,7 +15,8 @@ extern const char *profane_builtin[];
1515

1616
extern unsigned char usercolor_rgb[8];
1717

18-
struct ccx_encoders_helpers_settings_t {
18+
struct ccx_encoders_helpers_settings_t
19+
{
1920
int trim_subs;
2021
int no_font_color;
2122
int no_type_setting;
@@ -36,9 +37,9 @@ int add_word(struct word_list *list, const char *word);
3637
int add_builtin_words(const char *builtin[], struct word_list *list);
3738
void correct_spelling_and_censor_words(struct encoder_ctx *context, unsigned char *line, unsigned int length);
3839

39-
unsigned encode_line (struct encoder_ctx *ctx, unsigned char *buffer, unsigned char *text);
40+
unsigned encode_line(struct encoder_ctx *ctx, unsigned char *buffer, unsigned char *text);
4041

41-
void shell_sort(void *base, int nb, size_t size, int(*compar)(const void*p1, const void *p2, void*arg), void *arg);
42+
void shell_sort(void *base, int nb, size_t size, int (*compar)(const void *p1, const void *p2, void *arg), void *arg);
4243

4344
void ccx_encoders_helpers_perform_shellsort_words(void);
4445
void ccx_encoders_helpers_setup(enum ccx_encoding_type encoding, int no_font_color, int no_type_setting, int trim_subs);

src/lib_ccx/ccx_encoders_sami.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "lib_ccx.h"
22
#include "ccx_common_option.h"
33
#include "ccx_encoders_common.h"
4-
#include "png.h"
4+
#include <png.h>
55
#include "ocr.h"
66
#include "utility.h"
77
#include "ccx_encoders_helpers.h"

src/lib_ccx/ccx_encoders_smptett.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "lib_ccx.h"
2525
#include "ccx_common_option.h"
2626
#include "ccx_encoders_common.h"
27-
#include "png.h"
27+
#include <png.h>
2828
#include "ocr.h"
2929
#include "utility.h"
3030
#include "ccx_encoders_helpers.h"

src/lib_ccx/ccx_encoders_spupng.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "ccfont2.xbm" // CC font from libzvbi
22
#include "ccx_common_common.h"
33
#include "ccx_encoders_common.h"
4-
#include "png.h"
4+
#include <png.h>
55
#include <ft2build.h>
66
#include <math.h>
77
#include FT_FREETYPE_H

0 commit comments

Comments
 (0)