From 7843534d9e47c31d0c390034da59774a724e8422 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sat, 25 Jan 2020 14:23:31 +0100 Subject: [PATCH] Better build of datapipes and some documentation --- Jenkinsfile | 4 -- TeaSpeak | 2 +- build-helpers | 2 +- build_nice.md | 99 ++++++++++++++++++++++++++++++++++-- libraries/DataPipes | 2 +- libraries/build_datapipes.sh | 25 +++++++-- libraries/glibc | 2 +- setup_alpine | 18 +++++++ setup_arm | 12 ++--- 9 files changed, 144 insertions(+), 22 deletions(-) create mode 100644 setup_alpine diff --git a/Jenkinsfile b/Jenkinsfile index c090cfa..66a65d0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,10 +9,6 @@ pipeline { } environment { - //General flags - CXX_FLAGS = '' - C_FLAGS = '' - //CMake specific flags CMAKE_OPTIONS = '' CMAKE_MAKE_OPTIONS = '-j 12' diff --git a/TeaSpeak b/TeaSpeak index 9e41b82..f180f62 160000 --- a/TeaSpeak +++ b/TeaSpeak @@ -1 +1 @@ -Subproject commit 9e41b825c04999bb78411df23cb491dadeb02a18 +Subproject commit f180f62f2c0798c80b6147111162cb42f28b569c diff --git a/build-helpers b/build-helpers index 958b088..d7203d8 160000 --- a/build-helpers +++ b/build-helpers @@ -1 +1 @@ -Subproject commit 958b088e0b3a3711c1ee015efd5d22ada2d2aeb4 +Subproject commit d7203d854b75cb7954a2580c645729e7def8f297 diff --git a/build_nice.md b/build_nice.md index a8eef66..9472ea1 100644 --- a/build_nice.md +++ b/build_nice.md @@ -6,25 +6,118 @@ tar -xvf Python-3.6.3.tgz && \ cd Python-3.6.3 && \ sudo ./configure --enable-optimizations && \ make -j32 && \ -sudo make install +sudo make install && \ +sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3.6 60 pip3.6 install --upgrade pip ``` ## Ninja +### Using official version (may be outdated) ```shell script sudo apt install ninja ``` +### Building from source +```shell script +apt-get purge ninja + +git clone git://github.com/ninja-build/ninja.git && \ +cd ninja && \ +git checkout release && \ +./configure.py --bootstrap && \ +mv ninja /usr/local/bin/ +``` ## Meson ```shell script pip3.6 install meson ``` +## objcopy +`objcopy` must be build from source because the option "--add-symbol" is mouse likely not available... +```shell script +apt-get install -y texinfo bison flex + +git clone git://sourceware.org/git/binutils-gdb.git && cd binutils-gdb && \ +git checkout binutils-2_32-branch && \ +CXXFLAGS="-Wno-error=unused-function -O2" CFLAGS="-Wno-error=unused-function -O2" ./configure && \ +make -j32 && \ +make install +``` + # Building GLIB2.0 +Building GLIB2.0 ```shell script git clone https://github.com/GNOME/glib.git && \ cd glib && \ git checkout glib-2-62 && \ -meson _build -Dlibmount=false -``` \ No newline at end of file +meson _build -Dlibmount=false --prefix=`pwd`/out --buildtype=release --default-library=both -Diconv=libc + +ninja -C _build && \ +ninja -C _build install && \ +cd .. +``` +Publishing GLIB2.0 +```shell script +export build_os_type=linux +export build_os_arch=amd64 +export prebuild_path="`pwd`/glibc-prebuild/${build_os_type}_${build_os_arch}/" + +git clone https://git.did.science/WolverinDEV/glibc-prebuild.git +[[ -d $prebuild_path ]] && rm -r "$prebuild_path" +mkdir $prebuild_path && \ +cp -r glib/out/include/ $prebuild_path && \ +cp -r glib/out/lib/ $prebuild_path +``` + +# Building libnice +Building boringssl +```shell script +git clone https://boringssl.googlesource.com/boringssl && cd boringssl && \ +git checkout 1cc95ac0 # This version does TeaSpeak use + +[[ "`getconf LONG_BIT`" != "64" ]] && { export _toolchain="-DCMAKE_TOOLCHAIN_FILE=../util/32-bit-toolchain.cmake"; } +cmake . -DCMAKE_INSTALL_PREFIX=`pwd`/out -DOPENSSL_NO_ASM=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release $_toolchain && \ +make -j32 +``` + +Build libnice +```shell script +apt-get install gtk-doc-tools +git clone https://github.com/libnice/libnice.git && cd libnice + +export glib20_dir="`pwd`/../glibc-prebuild/linux_amd64/" +export glib20_lib_path="$glib20_dir/lib/"*"/" +export boringssl_path="`pwd`/../boringssl/" + +#pkg-config --static --cflags glib-2.0 := -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include +#pkg-config --static --libs glib-2.0 gio-2.0 gobject-2.0 := -pthread -lgio-2.0 -lz -lresolv -lselinux -lgmodule-2.0 -ldl -lgobject-2.0 -lffi -lglib-2.0 -lpcre +export GLIB_CFLAGS="-I$glib20_dir/include/glib-2.0 -I`echo "$glib20_dir/lib/"*"/glib-2.0/include"`" +export GLIB_LIBS="$glib20_lib_path/libgio-2.0.a -lz -lresolv $glib20_lib_path/libgmodule-2.0.a -ldl $glib20_lib_path/libgobject-2.0.a $glib20_lib_path/libffi.a $glib20_lib_path/libglib-2.0.a -lpcre -pthread" +export LDFLAGS="-L$boringssl_path/crypto/ -L$boringssl_path/ssl/" + +./autogen.sh --prefix=`pwd`/out --with-pic --with-crypto-library=openssl --without-gstreamer --disable-assert --disable-gtk-doc --enable-static=no --enable-shared=yes && \ +make && \ +make install + +cd .. +``` + +Publishing libnice +```shell script +[[ -z "${build_os_type}" ]] && export build_os_type=linux +[[ -z "${build_os_type}" ]] && export build_os_arch=amd64 +export prebuild_path="`pwd`/libnice-prebuild/${build_os_type}_${build_os_arch}/" + +[[ ! -d libnice-prebuild ]] && git clone https://git.did.science/WolverinDEV/libnice-prebuild.git +[[ -d $prebuild_path ]] && rm -r "$prebuild_path" +mkdir $prebuild_path && \ +cp -r libnice/out/include/ $prebuild_path && \ +cp -r libnice/out/lib/ $prebuild_path +``` + +# Troubleshooting +## GLIB2.0 hangs on meson +Ninja may be too sold. It should work with 1.9.0. + +export GLIB_LIBS="$glib20_lib_path/libgio-2.0.a -lz -lresolv $glib20_lib_path/libgmodule-2.0.a $glib20_lib_path/libgobject-2.0.a $glib20_lib_path/libffi.a $glib20_lib_path/libglib-2.0.a -lpcre -pthread" diff --git a/libraries/DataPipes b/libraries/DataPipes index 20d5c40..80adb70 160000 --- a/libraries/DataPipes +++ b/libraries/DataPipes @@ -1 +1 @@ -Subproject commit 20d5c4030bd723c34d2abe6fa3dc65a0ec134fb6 +Subproject commit 80adb70bfc6cc4c68a7be4ccbb1a9e7fa201b624 diff --git a/libraries/build_datapipes.sh b/libraries/build_datapipes.sh index 0fcee45..452b12e 100755 --- a/libraries/build_datapipes.sh +++ b/libraries/build_datapipes.sh @@ -14,6 +14,7 @@ requires_rebuild ${library_path} [[ -z "${datapipes_webrtc}" ]] && datapipes_webrtc=1 [[ "${datapipes_webrtc}" -eq 1 ]] && _datapipes_webrtc="ON" || datapipes_webrtc="OFF" +web_cmake_flags="-DBUILD_WEBRTC=${_datapipes_webrtc}" if [[ ${build_os_type} != "win32" && "${_datapipes_webrtc}" == "ON" ]]; then cd ${library_path} @@ -28,19 +29,33 @@ if [[ ${build_os_type} != "win32" && "${_datapipes_webrtc}" == "ON" ]]; then #fi echo "Building dependencies" - ./build_usrsctp.sh + #./build_usrsctp.sh check_err_exit ${library_path} "Failed to build usrsctp!" - ./build_srtp.sh + #./build_srtp.sh check_err_exit ${library_path} "Failed to build srtp!" - ./build_sdptransform.sh - check_err_exit ${library_path} "Failed to build sdptransform!" + cd .. + + glib20_dir=$(realpath "$(pwd)/glibc/linux_${build_os_arch}/") + # shellcheck disable=SC2125 + glib20_lib_path=$(realpath "$glib20_dir/lib/"*"/") + + # TODO: pcre really required here? + web_cmake_flags="$web_cmake_flags -DGLIB_PREBUILD_FLAGS=\"-I$glib20_dir/include -I$glib20_dir/include/glib-2.0/ -I$glib20_lib_path/glib-2.0/include/\"" + web_cmake_flags="$web_cmake_flags -DGLIB_PREBUILD_LIBRARIES=\"$glib20_lib_path/libgio-2.0.a;z;resolv;$glib20_lib_path/libgmodule-2.0.a;$glib20_lib_path/libgobject-2.0.a;$glib20_lib_path/libffi.a;$glib20_lib_path/libglib-2.0.a;pcre\"" + web_cmake_flags="$web_cmake_flags -DLIBNICE_PREBUILD_PATH=\"../libnice/linux_${build_os_arch}\"" + echo "WebRTC flags: $web_cmake_flags" fi _cxx_options="" [[ ${build_os_type} != "win32" ]] && _cxx_options="-fPIC -static-libgcc -static-libstdc++" [[ ${build_os_type} == "win32" ]] && _cxx_options="-DWIN32" -cmake_build ${library_path} -DCrypto_ROOT_DIR="`pwd`/boringssl/" -DCRYPTO_TYPE="boringssl" -DCMAKE_CXX_FLAGS="-fPIC -static-libgcc -static-libstdc++ ${CXX_FLAGS}" -DBUILD_TESTS=OFF -DCMAKE_C_FLAGS="${C_FLAGS} -fPIC" -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" ${CMAKE_OPTIONS} -DLIBNICE_PREBUILD_PATH="../libnice/linux_${build_os_arch}" -DGLIBC_PREBUILD_PATH="../glibc/linux_${build_os_arch}" -DBUILD_STATIC=0 -DBUILD_SHARED=1 -DBUILD_WEBRTC=${_datapipes_webrtc} + +general_options="-DCMAKE_C_FLAGS=\"-fPIC\" -DCMAKE_CXX_FLAGS=\"$_cxx_options\" -DBUILD_TESTS=OFF -DBUILD_STATIC=0 -DBUILD_SHARED=1 -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" +crypto_options="-DCrypto_ROOT_DIR=\"$(pwd)/boringssl/lib/\" -DCRYPTO_TYPE=\"boringssl\"" + +command="cmake_build ${library_path} ${general_options} ${crypto_options} ${web_cmake_flags} ${CMAKE_OPTIONS}" +eval "$command" check_err_exit ${library_path} "Failed to build DataPipes!" set_build_successful ${library_path} diff --git a/libraries/glibc b/libraries/glibc index b09017c..3396416 160000 --- a/libraries/glibc +++ b/libraries/glibc @@ -1 +1 @@ -Subproject commit b09017c340b04a8ce9373e93aa55780144428958 +Subproject commit 3396416fab69945f420f31dea30850806e199984 diff --git a/setup_alpine b/setup_alpine new file mode 100644 index 0000000..335685c --- /dev/null +++ b/setup_alpine @@ -0,0 +1,18 @@ +# Basic Setup +#linux-headers for unistd.h +#bsd-compat-headers for sys/cdefs.h (arm only!) +apk add bash coreutils build-base autoconf git wget sqlite-dev openssl-dev cmake patchelf go linux-headers bsd-compat-headers +git config --global credential.helper store + +# Create TeaSpeak +git clone https://git.did.science/WolverinDEV/TeaSpeak-Parent.git server && cd server && \ +git submodule update --init --recursive +./libraries/build.sh + + +# -------- Troubleshooting ---------- +If go raises an error/crashes install a newer version: +$ sudo add-apt-repository ppa:gophers/archive +$ sudo apt-get update +$ sudo apt-get install golang-1.11-go +sudo update-alternatives --install /usr/bin/go go /usr/lib/go-1.11/bin/go 1 diff --git a/setup_arm b/setup_arm index dad4804..204c9c2 100644 --- a/setup_arm +++ b/setup_arm @@ -7,7 +7,7 @@ sudo apt-get install gcc-9 g++-9 -y && \ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-9 && \ sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-9 60 --slave /usr/bin/c++ c++ /usr/bin/c++-9 -apt-get install autoconf git wget libssl-dev realpath +apt-get install autoconf git wget libssl-dev realpath libsqlite3-dev libmysqlclient-dev wget https://github.com/Kitware/CMake/releases/download/v3.16.3/cmake-3.16.3.tar.gz && tar xvf cmake-3.16.3.tar.gz cd cmake-3.16.3 && ./configure --parallel=16 @@ -17,10 +17,10 @@ cd .. git config --global credential.helper store # Patchelf -wget http://nixos.org/releases/patchelf/patchelf-0.10/patchelf-0.10.tar.bz2 -tar xf patchelf-0.10.tar.bz2 -cd patchelf-0.10 -./configure +wget http://nixos.org/releases/patchelf/patchelf-0.10/patchelf-0.10.tar.bz2 && \ +tar xf patchelf-0.10.tar.bz2 && \ +cd patchelf-0.10 && \ +./configure && \ make install # Create TeaSpeak @@ -36,4 +36,4 @@ If go raises an error/crashes install a newer version: $ sudo add-apt-repository ppa:gophers/archive $ sudo apt-get update $ sudo apt-get install golang-1.11-go -sudo update-alternatives --install /usr/bin/go go /usr/lib/go-1.11/bin/go 1 \ No newline at end of file +sudo update-alternatives --install /usr/bin/go go /usr/lib/go-1.11/bin/go 1