[vlc-devel] [PATCH] extra: packages: add a Raspberry Pi build scripts

Steve Lhomme robux4 at ycbcr.xyz
Fri Jan 31 08:11:13 CET 2020


On 2020-01-30 16:39, Alexandre Janniaux wrote:
> Hi,
> 
> Comments inline,
> 
> On Thu, Jan 30, 2020 at 04:11:00PM +0100, Steve Lhomme wrote:
>> Tested cross compiling for armv7 with this docker image
>> https://code.videolan.org/robUx4/docker-images/commits/raspbian/2
>> ---
>>   extras/package/raspberry/build.sh     | 169 ++++++++++++++++++++++++++
>>   extras/package/raspberry/configure.sh |  22 ++++
>>   2 files changed, 191 insertions(+)
>>   create mode 100755 extras/package/raspberry/build.sh
>>   create mode 100755 extras/package/raspberry/configure.sh
>>
>> diff --git a/extras/package/raspberry/build.sh b/extras/package/raspberry/build.sh
>> new file mode 100755
>> index 00000000000..87d15797813
>> --- /dev/null
>> +++ b/extras/package/raspberry/build.sh
>> @@ -0,0 +1,169 @@
>> +#!/bin/sh
>> +
>> +set -e
>> +set -x
>> +
>> +info()
>> +{
>> +    local green="\033[1;32m"
>> +    local normal="\033[0m"
>> +    echo "[${green}build${normal}] $1"
>> +}
>> +
>> +usage()
>> +{
>> +cat << EOF
>> +usage: $0 [options]
>> +
>> +Build vlc in the current directory
>> +
>> +OPTIONS:
>> +   -h            Show some help
>> +   -r            Release mode (default is debug)
>> +   -a <arch>     Use the specified arch (default: arm, possible aarch64)
>> +   -p            Use a Prebuilt contrib package (speeds up compilation)
>> +   -c            Create a Prebuilt contrib package (rarely used)
>> +   -l            Enable translations (can be slow)
>> +   -s            Interactive shell (get correct environment variables for build)
>> +EOF
>> +}
>> +
>> +ARCH="arm"
>> +while getopts "hra:pcli:sd" OPTION
>> +do
>> +     case $OPTION in
>> +         h)
>> +             usage
>> +             exit 1
>> +         ;;
>> +         r)
>> +             RELEASE="yes"
>> +         ;;
>> +         a)
>> +             ARCH=$OPTARG
>> +         ;;
>> +         p)
>> +             PREBUILT="yes"
>> +         ;;
>> +         c)
>> +             PACKAGE="yes"
>> +         ;;
>> +         l)
>> +             I18N="yes"
>> +         ;;
>> +         s)
>> +             INTERACTIVE="yes"
>> +         ;;
>> +     esac
>> +done
>> +shift $(($OPTIND - 1))
>> +
>> +if [ "x$1" != "x" ]; then
>> +    usage
>> +    exit 1
>> +fi
>> +
>> +case $ARCH in
>> +    aarch64)
>> +        SHORTARCH="linuxarm64"
>> +        EABI="gnu"
>> +        ;;
>> +    arm)
>> +        SHORTARCH="linuxarm"
>> +        EABI="gnueabihf"
>> +        ;;
>> +    *)
>> +        usage
>> +        exit 1
>> +esac
>> +
>> +#####
>> +
>> +SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
>> +
>> +: ${JOBS:=$(getconf _NPROCESSORS_ONLN 2>&1)}
>> +TRIPLET=$ARCH-linux-$EABI
>> +
>> +info "Building extra tools"
>> +mkdir -p tools
>> +cd tools
>> +export PATH="$PWD/build/bin":"$PATH"
>> +if [ "$INTERACTIVE" != "yes" ] || [ ! -f ./Makefile ]; then
>> +    ${SCRIPT_PATH}/../../tools/bootstrap
>> +fi
>> +make -j$JOBS --output-sync=recurse
>> +cd ..
>> +
>> +export USE_FFMPEG=1
>> +
>> +if [ "$INTERACTIVE" = "yes" ]; then
>> +if [ "x$SHELL" != "x" ]; then
>> +    exec $SHELL
>> +else
>> +    exec /bin/sh
>> +fi
>> +fi
>> +
>> +info "Building contribs"
>> +
>> +mkdir -p contrib/contrib-$SHORTARCH && cd contrib/contrib-$SHORTARCH
>> +
>> +# issue with arm detection of the target (detects i686)
>> +CONTRIBFLAGS="$CONTRIBFLAGS --disable-x265"
>> +
>> +${SCRIPT_PATH}/../../../contrib/bootstrap --host=$TRIPLET $CONTRIBFLAGS
>> +
>> +# use the system headers for the OS and firmware
>> +export CFLAGS="$CFLAGS -mfpu=neon -I/usr/$TRIPLET/include -I/opt/vc/include"
>> +export CXXFLAGS="$CXXFLAGS -mfpu=neon -I/usr/$TRIPLET/include -I/opt/vc/include"
>> +export CPPFLAGS="$CPPFLAGS -mfpu=neon -I/usr/$TRIPLET/include -I/opt/vc/include"
>> +export LDFLAGS="$LDFLAGS -L/usr/$TRIPLET/lib -L/opt/vc/lib -L/usr/lib/$TRIPLET"
> 
> I don't think neon should be enabled in the buildscript via
> CFLAGS.

Me neither but libaom doesn't compile properly without it. I does 
compile with Neon, but it doesn't work because it doesn't pass this 
flag. Probably something wrong in CMake or their use of it (surprise!).

I don't see how putting the exact same values in config.mak help. Maybe 
when trying to rebuild parts of contribs when not using this script. But 
then you still have to set the proper environment to build VLC anyway.

>> +
>> +# force the same compiler as current Raspbian binaries
>> +export CC="arm-linux-gnueabihf-gcc-8"
>> +export CXX="arm-linux-gnueabihf-g++-8"
>> +export AR="arm-linux-gnueabihf-gcc-ar-8"
>> +export RANLIB="arm-linux-gnueabihf-gcc-ranlib-8"
> 
> Using experience from previous buildscript, you should write
> this in config.mak and pass it as environment variable to VLC
> configure. Otherwise it could break contribs.

I have the opposite experience. The MSVC builds where using custom 
wrapper scripts and were passed this way. Anything that would attempt to 
be built outside these scripts would fail. And apart from qt all 
contribs were built.

>> +
>> +export PKG_CONFIG=${TRIPLET}-pkg-config
>> +
>> +# Rebuild the contribs or use the prebuilt ones
>> +if [ "$PREBUILT" != "yes" ]; then
>> +make list
>> +make -j$JOBS --output-sync=recurse fetch
>> +make -j$JOBS --output-sync=recurse -k || make -j1
>> +if [ "$PACKAGE" = "yes" ]; then
>> +make package
>> +fi
>> +else
>> +make prebuilt
>> +fi
>> +cd ../..
>> +
>> +info "Bootstrapping"
>> +
>> +${SCRIPT_PATH}/../../../bootstrap
>> +
>> +info "Configuring VLC"
>> +mkdir $SHORTARCH || true
>> +cd $SHORTARCH
>> +
>> +if [ "$RELEASE" != "yes" ]; then
>> +     CONFIGFLAGS="$CONFIGFLAGS --enable-debug"
>> +else
>> +     CONFIGFLAGS="$CONFIGFLAGS --disable-debug"
>> +fi
>> +if [ "$I18N" != "yes" ]; then
>> +     CONFIGFLAGS="$CONFIGFLAGS --disable-nls"
>> +fi
>> +
>> +ac_cv_path_MOC="qtchooser -qt=qt5-$TRIPLET -run-tool=moc" \
>> +ac_cv_path_RCC="qtchooser -qt=qt5-$TRIPLET -run-tool=rcc" \
>> +ac_cv_path_UIC="qtchooser -qt=qt5-$TRIPLET -run-tool=uic" \
>> +${SCRIPT_PATH}/configure.sh --host=$TRIPLET --with-contrib=../contrib/$TRIPLET $CONFIGFLAGS \
>> +    CFLAGS="$CFLAGS  -Werror=incompatible-pointer-types -Werror=missing-field-initializers -g" \
>> +    CPPFLAGS="$CPPFLAGS -Werror=incompatible-pointer-types -Werror=missing-field-initializers -g" \
>> +    CXXFLAGS="$CXXFLAGS -Werror=missing-field-initializers -g"
> 
> Can qtchooser be made non-mandatory with the correct
> environement setup?

You mean rewrite what qtchooser does but in this shell script or in 
configure.ac ? It's probably doable, but it is worth the effort ? 
qtchooser seems the proper thing to use when cross-compiling for qt, 
including selecting between version 4 and 5.


More information about the vlc-devel mailing list