Skip to content

Commit 1604572

Browse files
[IMPROVEMENT] linux/build script revamp (#1494)
* improving `linux/build` script * docs for the improved `linux/build` script
1 parent 9125165 commit 1604572

File tree

6 files changed

+47
-17
lines changed

6 files changed

+47
-17
lines changed

docs/COMPILATION.MD

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ cd ccextractor/linux
5555
./build -without-rust
5656

5757
# compile with debug info
58-
./builddebug
58+
./build -debug # same as ./build_debug
59+
60+
# compile with hardsubx
61+
./build -hardsubx # same as ./build_hardsubx
62+
63+
# compile in debug mode without rust
64+
./build -debug -without-rust
5965

6066
# test your build
6167
./ccextractor

linux/build

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,34 @@
11
#!/usr/bin/env bash
2+
3+
RUST_LIB="rust/release/libccx_rust.a"
4+
RUST_PROFILE="--release"
5+
while [[ $# -gt 0 ]]; do
6+
case $1 in
7+
-debug)
8+
DEBUG=true
9+
BLD_FLAGS="$BLD_FLAGS -g"
10+
RUST_PROFILE=""
11+
RUST_LIB="rust/debug/libccx_rust.a"
12+
shift
13+
;;
14+
-without-rust)
15+
WITHOUT_RUST=true
16+
shift
17+
;;
18+
-hardsubx)
19+
HARDSUBX=true
20+
RUST_FEATURES="--features hardsubx_ocr"
21+
BLD_FLAGS="$BLD_FLAGS -DENABLE_HARDSUBX"
22+
BLD_LINKER="$BLD_LINKER -lswscale -lavutil -pthread -lavformat -lavcodec -lxcb-shm -lxcb -lX11 -llzma -lswresample"
23+
shift
24+
;;
25+
-*)
26+
echo "Unknown option $1"
27+
exit 1
28+
;;
29+
esac
30+
done
31+
232
BLD_FLAGS="$BLD_FLAGS -std=gnu99 -Wno-write-strings -Wno-pointer-sign -DGPAC_CONFIG_LINUX -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -DENABLE_OCR -DFT2_BUILD_LIBRARY -DGPAC_DISABLE_VTT -DGPAC_DISABLE_OD_DUMP -DGPAC_DISABLE_REMOTERY -DNO_GZIP -DGPAC_HAVE_CONFIG_H"
333
bit_os=$(getconf LONG_BIT)
434
if [ "$bit_os"=="64" ]
@@ -61,7 +91,7 @@ echo "Running pre-build script..."
6191
./pre-build.sh
6292
echo "Trying to compile..."
6393

64-
if [ "$1" = "-without-rust" ]; then
94+
if [ "$WITHOUT_RUST" = true ]; then
6595
echo "Building without rust files..."
6696
BLD_FLAGS="$BLD_FLAGS -DDISABLE_RUST"
6797
else
@@ -84,14 +114,9 @@ else
84114
fi
85115

86116
echo "Building rust files..."
87-
echo "${BLD_FLAGS}"
88-
tokens=( ${BLD_FLAGS} )
89-
if [ ${tokens[0]} = "-DENABLE_HARDSUBX" ]; then
90-
(cd ../src/rust && CARGO_TARGET_DIR=../../linux/rust cargo build --features "hardsubx_ocr") || { echo "Failed. " ; exit 1; }
91-
else
92-
(cd ../src/rust && CARGO_TARGET_DIR=../../linux/rust cargo build) || { echo "Failed. " ; exit 1; }
93-
fi
94-
cp rust/debug/libccx_rust.a ./libccx_rust.a
117+
(cd ../src/rust && CARGO_TARGET_DIR=../../linux/rust cargo build $RUST_PROFILE $RUST_FEATURES) || { echo "Failed. " ; exit 1; }
118+
119+
cp $RUST_LIB ./libccx_rust.a
95120
fi
96121

97122
echo "Building ccextractor"

linux/build-debug

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
./build -debug

linux/build-hardsubx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
./build -hardsubx

linux/build_hardsubx

Lines changed: 0 additions & 4 deletions
This file was deleted.

linux/builddebug

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)