Skip to content

Commit

Permalink
update to JNI lib build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
zoff99 committed Oct 8, 2023
1 parent 3f43a06 commit dbe6f98
Show file tree
Hide file tree
Showing 10 changed files with 1,195 additions and 22 deletions.
26 changes: 26 additions & 0 deletions .localrun/Dockerfile_ub20
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# syntax=docker/dockerfile:1
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get -y --force-yes install \
ca-certificates \
libconfig-dev \
wget \
unzip \
zip \
automake \
autotools-dev \
build-essential \
check \
checkinstall \
libtool \
pkg-config \
rsync \
git \
gdb \
nano \
yasm \
openjdk-17-jdk-headless

4 changes: 2 additions & 2 deletions .localrun/docker_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ echo "$_HOME_"
cd "$_HOME_" || exit


build_for='ubuntu:18.04
build_for='ubuntu:20.04
'


Expand Down Expand Up @@ -77,7 +77,7 @@ pkgs_Ubuntu_18_04="
gdb
nano
yasm
openjdk-11-jdk-headless
openjdk-17-jdk-headless
"
pkgs_Ubuntu_20_04="$pkgs_Ubuntu_18_04"
Expand Down
105 changes: 105 additions & 0 deletions .localrun/docker_linux_fast.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#! /bin/bash

_HOME2_=$(dirname "$0")
export _HOME2_
_HOME_=$(cd "$_HOME2_" || exit;pwd)
export _HOME_

echo "$_HOME_"
cd "$_HOME_" || exit

if [ "$1""x" == "buildx" ]; then
docker build -f Dockerfile_ub20 -t trifa_materia_002_ub20 .
exit 0
fi


build_for='ubuntu:20.04
'


for system_to_build_for in $build_for ; do

system_to_build_for_orig="$system_to_build_for"
system_to_build_for=$(echo "$system_to_build_for_orig" 2>/dev/null|tr ':' '_' 2>/dev/null)"_linux"

cd "$_HOME_"/ || exit
mkdir -p "$_HOME_"/"$system_to_build_for"/

# rm -Rf $_HOME_/"$system_to_build_for"/script 2>/dev/null
# rm -Rf $_HOME_/"$system_to_build_for"/workspace 2>/dev/null

mkdir -p "$_HOME_"/"$system_to_build_for"/artefacts
mkdir -p "$_HOME_"/"$system_to_build_for"/script
mkdir -p "$_HOME_"/"$system_to_build_for"/workspace

ls -al "$_HOME_"/"$system_to_build_for"/

rsync -a ../ --exclude=.localrun "$_HOME_"/"$system_to_build_for"/workspace/data
chmod a+rwx -R "$_HOME_"/"$system_to_build_for"/workspace/data

echo '#! /bin/bash
#------------------------
pwd
ls -al
id -a
mkdir -p /workspace/data/jni-c-toxcore/
cd /workspace/data/jni-c-toxcore/ || exit 1
ls -al
set -x
if [ "$1""x" == "localx" ]; then
../circle_scripts/deps_linux.sh local || exit 1
../circle_scripts/java_jni_lib_linux.sh local || exit 1
else
../circle_scripts/deps_linux.sh || exit 1
../circle_scripts/java_jni_lib_linux.sh || exit 1
fi
#------------------------
' > "$_HOME_"/"$system_to_build_for"/script/run.sh

if [ "$1""x" == "localx" ]; then
echo " ******* LOCAL *******"
echo " ******* LOCAL *******"
echo " ******* LOCAL *******"
docker run -ti --rm \
-v "$_HOME_"/"$system_to_build_for"/artefacts:/artefacts \
-v "$_HOME_"/"$system_to_build_for"/script:/script \
-v "$_HOME_"/"$system_to_build_for"/workspace:/workspace \
-v "$_HOME_"/"$system_to_build_for"/c-toxcore:/c-toxcore \
--net=host \
"trifa_materia_002_ub20" \
/bin/sh -c "apk add bash >/dev/null 2>/dev/null; /bin/bash /script/run.sh local"
if [ $? -ne 0 ]; then
echo "** ERROR **:$system_to_build_for_orig"
exit 1
else
echo "--SUCCESS--:$system_to_build_for_orig"
fi
else
docker run -ti --rm \
-v "$_HOME_"/"$system_to_build_for"/artefacts:/artefacts \
-v "$_HOME_"/"$system_to_build_for"/script:/script \
-v "$_HOME_"/"$system_to_build_for"/workspace:/workspace \
--net=host \
"trifa_materia_002_ub20" \
/bin/sh -c "apk add bash >/dev/null 2>/dev/null; /bin/bash /script/run.sh"
if [ $? -ne 0 ]; then
echo "** ERROR **:$system_to_build_for_orig"
exit 1
else
echo "--SUCCESS--:$system_to_build_for_orig"
fi
fi
done

70 changes: 52 additions & 18 deletions circle_scripts/deps_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,29 @@ export MAKEFLAGS
WGET_OPTIONS="--timeout=10"
export WGET_OPTIONS

export CXXFLAGS="$CXXFLAGS -fPIC"
export CFLAGS="$CFLAGS -fPIC"
FLAGS_ASAN='-fsanitize=address -fno-omit-frame-pointer' # -static-libasan'
CXXFLAGS_ADDON='-O2 -g -fPIC'
CFLAGS_ADDON='-O2 -g -fPIC'
CFLAGS_MORE='--param=ssp-buffer-size=1 -fstack-protector-all'
# ----------- config ------------


# ------- deps verisions ---------
NASM_VERSION="nasm-2.16.01"
FFMPEG_VERSION="n6.0"
OPUS_VERSION="v1.4"
SODIUM_VERSION="1.0.19"
VPX_VERSION="v1.13.1"
_X264_VERSION_="baee400fa9ced6f5481a728138fed6e867b0ff7f"
# ------- deps verisions ---------



# ---------- ffmpeg ---------
if [ 1 == 1 ]; then

cd "$_SRC_"

FFMPEG_VERSION=n6.0
FFMPEG_FILENAME="$FFMPEG_VERSION.tar.gz"
rm -f "ffmpeg"*.tar.*
wget $WGET_OPTIONS "https://github.com/FFmpeg/FFmpeg/archive/refs/tags/$FFMPEG_FILENAME" -O "ffmpeg_""$FFMPEG_FILENAME"
Expand All @@ -55,7 +66,9 @@ export LDFLAGS=" "
# libavcodec.a(h264_qpel_10bit.o): relocation R_X86_64_PC32 against symbol `ff_pw_1023' can not be used when making a shared object; recompile with -fPIC
#

./configure \
export CXXFLAGS=${CXXFLAGS_ADDON}
export CFLAGS=${CFLAGS_ADDON}
./configure \
--enable-gpl \
--prefix="$_INST_" \
--disable-asm \
Expand Down Expand Up @@ -105,6 +118,9 @@ export LDFLAGS=" "
make -j || exit 1
make install

unset CXXFLAGS
unset CFLAGS

cd "$_HOME_"

fi
Expand All @@ -116,7 +132,7 @@ if [ 1 == 1 ]; then

cd "$_SRC_"

OPUS_VERSION=v1.4

OPUS_FILENAME="$OPUS_VERSION.tar.gz"
rm -f "opus"*.tar.gz
wget $WGET_OPTIONS "https://github.com/xiph/opus/archive/refs/tags/$OPUS_FILENAME" -O "opus_""$OPUS_FILENAME"
Expand All @@ -125,7 +141,9 @@ rm -f "opus"*.tar.gz
cd opus*/

./autogen.sh
CFLAGS="-O2 -g -fPIC" ./configure \
export CXXFLAGS=${CXXFLAGS_ADDON}
export CFLAGS=${CFLAGS_ADDON}
./configure \
--prefix="$_INST_" \
--disable-shared \
--enable-static \
Expand All @@ -134,6 +152,8 @@ cd opus*/
--disable-doc || exit 1
make || exit 1
make install
unset CXXFLAGS
unset CFLAGS

cd "$_HOME_"

Expand All @@ -147,21 +167,24 @@ if [ 1 == 1 ]; then

cd "$_SRC_"

SODIUM_VERSION=1.0.18
SODIUM_FILENAME="libsodium-$SODIUM_VERSION.tar.gz"
rm -f libsodium-*.tar.gz
wget $WGET_OPTIONS "https://download.libsodium.org/libsodium/releases/$SODIUM_FILENAME" -O "$SODIUM_FILENAME"
tar -xf "$SODIUM_FILENAME"
cd libsodium*/

CFLAGS="-O2 -g -fPIC" ./configure \
export CXXFLAGS=${CXXFLAGS_ADDON}
export CFLAGS=${CFLAGS_ADDON}
./configure \
--prefix="$_INST_" \
--disable-shared \
--enable-static \
--with-pic || exit 1

make || exit 1
make install
unset CXXFLAGS
unset CFLAGS

cd "$_HOME_"

Expand All @@ -174,15 +197,17 @@ if [ 1 == 1 ]; then

cd "$_SRC_"

VPX_VERSION=v1.8.0
VPX_FILENAME="libvpx-$VPX_VERSION.tar.gz"
rm -f libvpx-*.tar.gz
wget $WGET_OPTIONS "https://github.com/webmproject/libvpx/archive/$VPX_VERSION.tar.gz" -O "$VPX_FILENAME"

VPX_FILENAME="$VPX_VERSION.tar.gz"

rm -f *.tar.gz
wget $WGET_OPTIONS "https://github.com/webmproject/libvpx/archive/refs/tags/""$VPX_VERSION"".tar.gz" -O "$VPX_FILENAME"
tar -xf "$VPX_FILENAME"
cd libvpx*/


CFLAGS="-O2 -g -fPIC" ./configure \
export CXXFLAGS=${CXXFLAGS_ADDON}
export CFLAGS=${CFLAGS_ADDON}
./configure \
--prefix="$_INST_" \
--disable-shared \
--size-limit=16384x16384 \
Expand All @@ -199,6 +224,8 @@ cd libvpx*/

make || exit 1
make install
unset CXXFLAGS
unset CFLAGS

cd "$_HOME_"

Expand All @@ -216,7 +243,7 @@ cd "$_SRC_"
rm -Rf nasm
git clone http://repo.or.cz/nasm.git
cd nasm/
git checkout nasm-2.13.03
git checkout "$NASM_VERSION"

./autogen.sh
./configure --prefix=/
Expand Down Expand Up @@ -245,12 +272,13 @@ if [ 1 == 1 ]; then
cd "$_SRC_"

git clone https://code.videolan.org/videolan/x264.git
_X264_VERSION_="1771b556ee45207f8711744ccbd5d42a3949b14c"
cd x264/

git checkout "$_X264_VERSION_"

CFLAGS="-O2 -g -fPIC" ./configure \
export CXXFLAGS=${CXXFLAGS_ADDON}
export CFLAGS=${CFLAGS_ADDON}
./configure \
--prefix="$_INST_" \
--disable-opencl \
--enable-static \
Expand All @@ -260,6 +288,8 @@ cd x264/

make || exit 1
make install
unset CXXFLAGS
unset CFLAGS

cd "$_HOME_"

Expand Down Expand Up @@ -291,8 +321,10 @@ cat toxcore/tox.h | grep 'TOX_GIT_COMMIT_HASH'
# ------ set c-toxcore git commit hash ------

autoreconf -fi

./configure \
CFLAGS=" -O3 -g -fPIC -fstack-protector-all -DTOX_CAPABILITIES_ACTIVE $LOGG " \
CXXFLAGS="$CXXFLAGS_ADDON" \
CFLAGS="-fPIC $CFLAGS_ADDON $CFLAGS_MORE -DTOX_CAPABILITIES_ACTIVE $LOGG" \
--prefix="$_INST_" \
--disable-soname-versions \
--disable-shared \
Expand All @@ -301,6 +333,8 @@ autoreconf -fi

make || exit 1
make install
unset CXXFLAGS
unset CFLAGS

cd "$_HOME_"

Expand Down
Loading

0 comments on commit dbe6f98

Please sign in to comment.