Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions docs/COMPILATION.MD
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ sudo make install

`cmake` also accepts the options:
`-DWITH_OCR=ON` to enable OCR
`-DWITHOUT_RUST=ON` to disable rust.
`-DWITH_HARDSUBX=ON` to enable burned-in subtitles

([OPTIONAL] For hardsubx, you also need to set these environment variables correctly according to your machine)
Expand Down Expand Up @@ -176,7 +175,6 @@ make

`cmake` also accepts the options:
`-DWITH_OCR=ON` to enable OCR
`-DWITHOUT_RUST=ON` to disable rust.
`-DWITH_HARDSUBX=ON` to enable burned-in subtitles

#### Standard compilation through Autoconf scripts:
Expand Down
3 changes: 0 additions & 3 deletions docs/using_cmake_build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,5 @@ cmake -DWITH_OCR=ON ../src/
If you want to build CCExtractor with HARDSUBX support
cmake -DWITH_HARDSUBX=ON ../src/

If you want to build CCExtractor with rust disabled you need to pass
cmake -DWITHOUT_RUST=ON ../src/

Hint for looking all the things you want to set from outside
cmake -LAH ../src/
5 changes: 0 additions & 5 deletions linux/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,7 @@ ccextractor_LDADD += $(TESS_LIB)
ccextractor_LDADD += $(LEPT_LIB)
endif

if WITH_RUST
ccextractor_LDADD += ./rust/@RUST_TARGET_SUBDIR@/libccx_rust.a
else
ccextractor_CFLAGS += -DDISABLE_RUST
ccextractor_CPPFLAGS += -DDISABLE_RUST
endif

if DEBUG_RELEASE
CARGO_RELEASE_ARGS=
Expand Down
49 changes: 20 additions & 29 deletions linux/build
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ while [[ $# -gt 0 ]]; do
RUST_LIB="rust/debug/libccx_rust.a"
shift
;;
-without-rust)
WITHOUT_RUST=true
shift
;;
-hardsubx)
HARDSUBX=true
RUST_FEATURES="--features hardsubx_ocr"
Expand Down Expand Up @@ -90,34 +86,29 @@ echo "Running pre-build script..."
./pre-build.sh
echo "Trying to compile..."

if [ "$WITHOUT_RUST" = true ]; then
echo "Building without rust files..."
BLD_FLAGS="$BLD_FLAGS -DDISABLE_RUST"
else
BLD_LINKER="$BLD_LINKER ./libccx_rust.a"
echo "Checking for cargo..."
if ! [ -x "$(command -v cargo)" ]; then
echo 'Error: cargo is not installed.' >&2
exit 1
fi

rustc_version="$(rustc --version)"
semver=( ${rustc_version//./ } )
version="${semver[1]}.${semver[2]}.${semver[3]}"
MSRV="1.54.0"
if [ "$(printf '%s\n' "$MSRV" "$version" | sort -V | head -n1)" = "$MSRV" ]; then
echo "rustc >= MSRV(${MSRV})"
else
echo "Minimum supported rust version(MSRV) is ${MSRV}, please upgrade rust"
exit 1
fi

echo "Building rust files..."
(cd ../src/rust && CARGO_TARGET_DIR=../../linux/rust cargo build $RUST_PROFILE $RUST_FEATURES) || { echo "Failed. " ; exit 1; }
BLD_LINKER="$BLD_LINKER ./libccx_rust.a"
echo "Checking for cargo..."
if ! [ -x "$(command -v cargo)" ]; then
echo 'Error: cargo is not installed.' >&2
exit 1
fi

cp $RUST_LIB ./libccx_rust.a
rustc_version="$(rustc --version)"
semver=( ${rustc_version//./ } )
version="${semver[1]}.${semver[2]}.${semver[3]}"
MSRV="1.54.0"
if [ "$(printf '%s\n' "$MSRV" "$version" | sort -V | head -n1)" = "$MSRV" ]; then
echo "rustc >= MSRV(${MSRV})"
else
echo "Minimum supported rust version(MSRV) is ${MSRV}, please upgrade rust"
exit 1
fi

echo "Building rust files..."
(cd ../src/rust && CARGO_TARGET_DIR=../../linux/rust cargo build $RUST_PROFILE $RUST_FEATURES) || { echo "Failed. " ; exit 1; }

cp $RUST_LIB ./libccx_rust.a

echo "Building ccextractor"
out=$((LC_ALL=C gcc $BLD_FLAGS $BLD_INCLUDE -o ccextractor $BLD_SOURCES $BLD_LINKER)2>&1)
res=$?
Expand Down
6 changes: 1 addition & 5 deletions mac/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,8 @@ ccextractor_LDADD += $(TESS_LIB)
ccextractor_LDADD += $(LEPT_LIB)
endif

if WITH_RUST
ccextractor_LDADD += ./rust/@RUST_TARGET_SUBDIR@/libccx_rust.a
else
ccextractor_CFLAGS += -DDISABLE_RUST
ccextractor_CPPFLAGS += -DDISABLE_RUST
endif


if DEBUG_RELEASE
CARGO_RELEASE_ARGS=
Expand Down
219 changes: 172 additions & 47 deletions mac/build.command
Original file line number Diff line number Diff line change
@@ -1,58 +1,183 @@
#!/bin/bash
cd `dirname $0`
BLD_FLAGS="-std=gnu99 -Wno-write-strings -Wno-pointer-sign -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -Dfopen64=fopen -Dopen64=open -Dlseek64=lseek -DFT2_BUILD_LIBRARY -DGPAC_DISABLE_VTT -DGPAC_DISABLE_OD_DUMP -DGPAC_DISABLE_REMOTERY -DNO_GZIP -DDISABLE_RUST"
[[ $1 = "OCR" ]] && BLD_FLAGS="$BLD_FLAGS -DENABLE_OCR"

RUST_LIB="rust/release/libccx_rust.a"
RUST_PROFILE="--release"
RUST_FEATURES=""

# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
OCR)
ENABLE_OCR=true
shift
;;
-debug)
DEBUG=true
RUST_PROFILE=""
RUST_LIB="rust/debug/libccx_rust.a"
shift
;;
-hardsubx)
HARDSUBX=true
RUST_FEATURES="--features hardsubx_ocr"
shift
;;
-*)
echo "Unknown option $1"
exit 1
;;
esac
done

BLD_FLAGS="-std=gnu99 -Wno-write-strings -Wno-pointer-sign -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -Dfopen64=fopen -Dopen64=open -Dlseek64=lseek -DFT2_BUILD_LIBRARY -DGPAC_DISABLE_VTT -DGPAC_DISABLE_OD_DUMP -DGPAC_DISABLE_REMOTERY -DNO_GZIP"

# Add debug flags if needed
if [[ "$DEBUG" == "true" ]]; then
BLD_FLAGS="$BLD_FLAGS -g -fsanitize=address"
fi

# Add OCR support if requested
if [[ "$ENABLE_OCR" == "true" ]]; then
BLD_FLAGS="$BLD_FLAGS -DENABLE_OCR"
fi

# Add hardsubx support if requested
if [[ "$HARDSUBX" == "true" ]]; then
BLD_FLAGS="$BLD_FLAGS -DENABLE_HARDSUBX"
fi

BLD_INCLUDE="-I../src/ -I../src/lib_ccx -I../src/lib_hash -I../src/thirdparty/libpng -I../src/thirdparty -I../src/thirdparty/zlib -I../src/thirdparty/freetype/include `pkg-config --cflags --silence-errors gpac`"
[[ $1 = "OCR" ]] && BLD_INCLUDE="$BLD_INCLUDE `pkg-config --cflags --silence-errors tesseract`"

if [[ "$ENABLE_OCR" == "true" ]]; then
BLD_INCLUDE="$BLD_INCLUDE `pkg-config --cflags --silence-errors tesseract`"
fi

SRC_CCX="$(find ../src/lib_ccx -name '*.c')"
SRC_LIB_HASH="$(find ../src/thirdparty/lib_hash -name '*.c')"
SRC_LIBPNG="$(find ../src/thirdparty/libpng -name '*.c')"
SRC_UTF8="../src/thirdparty/utf8proc/utf8proc.c"
SRC_ZLIB="$(find ../src/thirdparty/zlib -name '*.c')"
SRC_FREETYPE="../src/thirdparty/freetype/autofit/autofit.c \
../src/thirdparty/freetype/base/ftbase.c \
../src/thirdparty/freetype/base/ftbbox.c \
../src/thirdparty/freetype/base/ftbdf.c \
../src/thirdparty/freetype/base/ftbitmap.c \
../src/thirdparty/freetype/base/ftcid.c \
../src/thirdparty/freetype/base/ftfntfmt.c \
../src/thirdparty/freetype/base/ftfstype.c \
../src/thirdparty/freetype/base/ftgasp.c \
../src/thirdparty/freetype/base/ftglyph.c \
../src/thirdparty/freetype/base/ftgxval.c \
../src/thirdparty/freetype/base/ftinit.c \
../src/thirdparty/freetype/base/ftlcdfil.c \
../src/thirdparty/freetype/base/ftmm.c \
../src/thirdparty/freetype/base/ftotval.c \
../src/thirdparty/freetype/base/ftpatent.c \
../src/thirdparty/freetype/base/ftpfr.c \
../src/thirdparty/freetype/base/ftstroke.c \
../src/thirdparty/freetype/base/ftsynth.c \
../src/thirdparty/freetype/base/ftsystem.c \
../src/thirdparty/freetype/base/fttype1.c \
../src/thirdparty/freetype/base/ftwinfnt.c \
../src/thirdparty/freetype/bdf/bdf.c \
../src/thirdparty/freetype/bzip2/ftbzip2.c \
../src/thirdparty/freetype/cache/ftcache.c \
../src/thirdparty/freetype/cff/cff.c \
../src/thirdparty/freetype/cid/type1cid.c \
../src/thirdparty/freetype/gzip/ftgzip.c \
../src/thirdparty/freetype/lzw/ftlzw.c \
../src/thirdparty/freetype/pcf/pcf.c \
../src/thirdparty/freetype/pfr/pfr.c \
../src/thirdparty/freetype/psaux/psaux.c \
../src/thirdparty/freetype/pshinter/pshinter.c \
../src/thirdparty/freetype/psnames/psnames.c \
../src/thirdparty/freetype/raster/raster.c \
../src/thirdparty/freetype/sfnt/sfnt.c \
../src/thirdparty/freetype/smooth/smooth.c \
../src/thirdparty/freetype/truetype/truetype.c \
../src/thirdparty/freetype/type1/type1.c \
../src/thirdparty/freetype/type42/type42.c \
../src/thirdparty/freetype/winfonts/winfnt.c"
BLD_SOURCES="../src/ccextractor.c $SRC_API $SRC_CCX $SRC_LIB_HASH $SRC_LIBPNG $SRC_UTF8 $SRC_ZLIB $SRC_ZVBI $SRC_FREETYPE"
BLD_LINKER="-lm -liconv -lpthread -ldl `pkg-config --libs --silence-errors tesseract` `pkg-config --libs --silence-errors gpac`"
[[ $1 = "OCR" ]] && BLD_LINKER="$BLD_LINKER `pkg-config --libs --silence-errors tesseract` `pkg-config --libs --silence-errors lept`"
../src/thirdparty/freetype/base/ftbase.c \
../src/thirdparty/freetype/base/ftbbox.c \
../src/thirdparty/freetype/base/ftbdf.c \
../src/thirdparty/freetype/base/ftbitmap.c \
../src/thirdparty/freetype/base/ftcid.c \
../src/thirdparty/freetype/base/ftfntfmt.c \
../src/thirdparty/freetype/base/ftfstype.c \
../src/thirdparty/freetype/base/ftgasp.c \
../src/thirdparty/freetype/base/ftglyph.c \
../src/thirdparty/freetype/base/ftgxval.c \
../src/thirdparty/freetype/base/ftinit.c \
../src/thirdparty/freetype/base/ftlcdfil.c \
../src/thirdparty/freetype/base/ftmm.c \
../src/thirdparty/freetype/base/ftotval.c \
../src/thirdparty/freetype/base/ftpatent.c \
../src/thirdparty/freetype/base/ftpfr.c \
../src/thirdparty/freetype/base/ftstroke.c \
../src/thirdparty/freetype/base/ftsynth.c \
../src/thirdparty/freetype/base/ftsystem.c \
../src/thirdparty/freetype/base/fttype1.c \
../src/thirdparty/freetype/base/ftwinfnt.c \
../src/thirdparty/freetype/bdf/bdf.c \
../src/thirdparty/freetype/bzip2/ftbzip2.c \
../src/thirdparty/freetype/cache/ftcache.c \
../src/thirdparty/freetype/cff/cff.c \
../src/thirdparty/freetype/cid/type1cid.c \
../src/thirdparty/freetype/gzip/ftgzip.c \
../src/thirdparty/freetype/lzw/ftlzw.c \
../src/thirdparty/freetype/pcf/pcf.c \
../src/thirdparty/freetype/pfr/pfr.c \
../src/thirdparty/freetype/psaux/psaux.c \
../src/thirdparty/freetype/pshinter/pshinter.c \
../src/thirdparty/freetype/psnames/psnames.c \
../src/thirdparty/freetype/raster/raster.c \
../src/thirdparty/freetype/sfnt/sfnt.c \
../src/thirdparty/freetype/smooth/smooth.c \
../src/thirdparty/freetype/truetype/truetype.c \
../src/thirdparty/freetype/type1/type1.c \
../src/thirdparty/freetype/type42/type42.c \
../src/thirdparty/freetype/winfonts/winfnt.c"

BLD_SOURCES="../src/ccextractor.c $SRC_CCX $SRC_LIB_HASH $SRC_LIBPNG $SRC_UTF8 $SRC_ZLIB $SRC_FREETYPE"

BLD_LINKER="-lm -liconv -lpthread -ldl `pkg-config --libs --silence-errors gpac`"

if [[ "$ENABLE_OCR" == "true" ]]; then
BLD_LINKER="$BLD_LINKER `pkg-config --libs --silence-errors tesseract` `pkg-config --libs --silence-errors lept`"
fi

if [[ "$HARDSUBX" == "true" ]]; then
BLD_LINKER="$BLD_LINKER -lswscale -lavutil -pthread -lavformat -lavcodec -lavfilter"
fi

echo "Running pre-build script..."
./pre-build.sh
gcc $BLD_FLAGS $BLD_INCLUDE -o ccextractor $BLD_SOURCES $BLD_LINKER
echo "Trying to compile..."

# Check for cargo
echo "Checking for cargo..."
if ! [ -x "$(command -v cargo)" ]; then
echo 'Error: cargo is not installed.' >&2
exit 1
fi

# Check rust version
rustc_version="$(rustc --version)"
semver=( ${rustc_version//./ } )
version="${semver[1]}.${semver[2]}.${semver[3]}"
MSRV="1.54.0"
if [ "$(printf '%s\n' "$MSRV" "$version" | sort -V | head -n1)" = "$MSRV" ]; then
echo "rustc >= MSRV(${MSRV})"
else
echo "Minimum supported rust version(MSRV) is ${MSRV}, please upgrade rust"
exit 1
fi

echo "Building rust files..."
(cd ../src/rust && CARGO_TARGET_DIR=../../mac/rust cargo build $RUST_PROFILE $RUST_FEATURES) || { echo "Failed building Rust components." ; exit 1; }

# Copy the Rust library
cp $RUST_LIB ./libccx_rust.a

# Add Rust library to linker flags
BLD_LINKER="$BLD_LINKER ./libccx_rust.a"

echo "Building ccextractor"
out=$((LC_ALL=C gcc $BLD_FLAGS $BLD_INCLUDE -o ccextractor $BLD_SOURCES $BLD_LINKER) 2>&1)
res=$?

# Handle common error cases
if [[ $out == *"gcc: command not found"* ]]; then
echo "Error: please install gcc or Xcode command line tools"
exit 1
fi

if [[ $out == *"curl.h: No such file or directory"* ]]; then
echo "Error: please install curl development library"
exit 2
fi

if [[ $out == *"capi.h: No such file or directory"* ]]; then
echo "Error: please install tesseract development library"
exit 3
fi

if [[ $out == *"allheaders.h: No such file or directory"* ]]; then
echo "Error: please install leptonica development library"
exit 4
fi

if [[ $res -ne 0 ]]; then # Unknown error
echo "Compiled with errors"
>&2 echo "$out"
exit 5
fi

if [[ "$out" != "" ]]; then
echo "$out"
echo "Compilation successful, compiler message shown in previous lines"
else
echo "Compilation successful, no compiler messages."
fi
7 changes: 2 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ include (CTest)
option (WITH_FFMPEG "Build using FFmpeg demuxer and decoder" OFF)
option (WITH_OCR "Build with OCR (Optical Character Recognition) feature" OFF)
option (WITH_HARDSUBX "Build with support for burned-in subtitles" OFF)
option (WITHOUT_RUST "Build without Rust library" OFF)

# Version number
set (CCEXTRACTOR_VERSION_MAJOR 0)
Expand Down Expand Up @@ -237,12 +236,10 @@ add_executable (ccextractor ${SOURCEFILE} ${FREETYPE_SOURCE} ${UTF8PROC_SOURCE})
# Build with Rust library
########################################################

if (PKG_CONFIG_FOUND AND NOT WITHOUT_RUST)
if (PKG_CONFIG_FOUND)
add_subdirectory (rust)
set (EXTRA_LIBS ${EXTRA_LIBS} ccx_rust)
else ()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDISABLE_RUST")
endif (PKG_CONFIG_FOUND AND NOT WITHOUT_RUST)
endif (PKG_CONFIG_FOUND)


target_link_libraries (ccextractor ${EXTRA_LIBS})
Expand Down
6 changes: 0 additions & 6 deletions src/ccextractor.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,15 +418,9 @@ int main(int argc, char *argv[])
// See docs/ccextractor.cnf.sample for more info.
parse_configuration(&ccx_options);

#ifndef DISABLE_RUST
ccxr_init_basic_logger();
#endif

#ifndef DISABLE_RUST
int compile_ret = ccxr_parse_parameters(argc, argv);
#else
int compile_ret = parse_parameters(&ccx_options, argc, argv);
#endif

if (compile_ret == EXIT_NO_INPUT_FILES)
{
Expand Down
4 changes: 0 additions & 4 deletions src/lib_ccx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ if (WITH_HARDSUBX)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_HARDSUBX")
endif (WITH_HARDSUBX)

if (WITHOUT_RUST)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDISABLE_RUST")
endif (WITHOUT_RUST)

file (GLOB HeaderFiles *.h)
file (WRITE ccx.pc "prefix=${CMAKE_INSTALL_PREFIX}\n"
"includedir=\${prefix}/include\n"
Expand Down
Loading
Loading