Also added efornara's crossbuild - build containers - I'm planning to work them into the current build container stack, likely with lots of modifications. (https://github.com/efornara/crossbuild)

This commit is contained in:
Relintai 2022-03-27 13:02:12 +02:00
parent cb739deb8e
commit a197623126
17 changed files with 218 additions and 0 deletions

4
misc/build-containers-frt/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*.o
*.bin
build/
.clang-format

View File

@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>

View File

@ -0,0 +1,7 @@
https://github.com/efornara/crossbuild - 0e6be47aa48d4f1dbd47410d64027b67ac091f38
patreon: efornaralabs
Docker files to cross-compile SDL2-based projects for single board computers.
Very permissive license (http://unlicense.org/).

View File

@ -0,0 +1,5 @@
FROM crossbuild:base
RUN dpkg --add-architecture armhf && apt-get update && apt-get install -y -q \
crossbuild-essential-armhf
RUN apt-get install -y -q \
libstdc++-8-dev:armhf libsdl2-dev:armhf libgbm-dev:armhf libsamplerate0-dev:armhf

View File

@ -0,0 +1,5 @@
FROM crossbuild:base
RUN dpkg --add-architecture arm64 && apt-get update && apt-get install -y -q \
crossbuild-essential-arm64
RUN apt-get install -y -q \
libstdc++-8-dev:arm64 libsdl2-dev:arm64 libgbm-dev:arm64 libsamplerate0-dev:arm64

View File

@ -0,0 +1,10 @@
FROM debian:buster-backports
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get upgrade -y && \
apt-get install --no-install-recommends -y -q \
git-core vim-nox wget less nvi tmux lynx
RUN apt-get install -y -q \
build-essential clang llvm lld python3-pip
RUN apt-get install -y -q \
-t buster-backports cmake ninja-build
RUN python3 -m pip install scons meson

View File

@ -0,0 +1,11 @@
FROM debian:bullseye
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get upgrade -y && \
apt-get install --no-install-recommends -y -q \
git-core vim-nox wget less nvi tmux lynx
RUN apt-get install -y -q \
scons cmake ninja-build
RUN apt-get install -y -q \
unzip curl openjdk-11-jdk-headless
RUN apt-get install -y -q \
python3-protobuf

View File

@ -0,0 +1,3 @@
FROM crossbuild:base
RUN apt-get install -y -q \
libstdc++-8-dev libsdl2-dev libgbm-dev libsamplerate0-dev

View File

@ -0,0 +1,6 @@
#! /bin/sh
set -e
[ -f Dockerfile.$1 ]
exec docker build -t crossbuild:$1 -f Dockerfile.$1 .

View File

@ -0,0 +1,15 @@
#! /bin/sh
set -e
if [ $# -ne 1 ] ; then
echo 'usage: docker.sh arch'
exit 1
fi
exec docker run -it --rm \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/shadow:/etc/shadow:ro \
-v /etc/group:/etc/group:ro \
-v /opt:/opt \
-v $HOME:$HOME \
crossbuild:$1

View File

@ -0,0 +1,31 @@
#! /bin/sh
set -e
script=$(readlink -f "$0")
script_path=$(dirname "$script")
. $script_path/detect
if [ -z "$SDL2_SRC" ] ; then
echo "SDL2_SRC not set"
exit 1
fi
toplevel=`git rev-parse --show-toplevel`
obj="$toplevel/build/obj/$tag-sdl2"
mkdir -p $obj
cd $obj
if [ ! -f $obj/Makefile -o "x$1" = "xconfig" ] ; then
export CFLAGS="$archflags"
export CXXFLAGS="$archflags"
"$SDL2_SRC/configure" \
--prefix="$toplevel/build/bin/$tag-sdl2" \
--host=$host \
--disable-render \
--enable-video-kmsdrm \
--disable-video-vulkan \
#
fi
nice make -j 2
make install

View File

@ -0,0 +1,48 @@
# Detect Build Environment
#
# Example of platform override:
#
# platform=arm8 ./build_hello
#
if [ -z "$platform" ] ; then
if [ -x /usr/bin/arm-linux-gnueabihf-gcc ] ; then
if [ -x /usr/bin/x86_64-linux-gnu-gcc ] ; then
platform=arm7
else
# if not cross-compiling on x86_64, assume raspbian
platform=arm6
fi
elif [ -x /usr/bin/aarch64-linux-gnu-gcc ] ; then
platform=arm8
else
platform=pc
fi
fi
if [ "$platform" = arm6 ] ; then
host=arm-linux-gnueabihf
tag=linux-arm32v6
archflags="-march=armv6 -mfpu=vfp -mfloat-abi=hard"
elif [ "$platform" = arm7 ] ; then
host=arm-linux-gnueabihf
tag=linux-arm32v7
archflags="-march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard"
elif [ "$platform" = arm8 ] ; then
host=aarch64-linux-gnu
tag=linux-arm64v8
archflags="-march=armv8-a"
elif [ "$platform" = pc ] ; then
host=x86_64-linux-gnu
tag=linux-x86_64
archflags=""
else
echo "detect: unknown platform: '$platform'"
exit 1
fi
echo "detect:"
echo " host: $host"
echo " tag: $tag"
echo " archflags: $archflags"

View File

@ -0,0 +1,10 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR ARM)
set(archOpts "-march=armv6 -mfpu=vfp -mfloat-abi=hard")
set(ccOpts "")
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
set(CMAKE_C_FLAGS "${archOpts} ${ccOpts}")
set(CMAKE_CXX_FLAGS "${archOpts} ${ccOpts}")

View File

@ -0,0 +1,10 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR ARM)
set(archOpts "-march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard")
set(ccOpts "-target arm-linux-gnueabihf")
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_C_FLAGS "${archOpts} ${ccOpts}")
set(CMAKE_CXX_FLAGS "${archOpts} ${ccOpts}")

View File

@ -0,0 +1,10 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR ARM)
set(archOpts "-march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard")
set(ccOpts "")
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
set(CMAKE_C_FLAGS "${archOpts} ${ccOpts}")
set(CMAKE_CXX_FLAGS "${archOpts} ${ccOpts}")

View File

@ -0,0 +1,10 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR ARM)
set(archOpts "-march=armv8-a")
set(ccOpts "-target aarch64-linux-gnu")
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_C_FLAGS "${archOpts} ${ccOpts}")
set(CMAKE_CXX_FLAGS "${archOpts} ${ccOpts}")

View File

@ -0,0 +1,9 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR ARM)
set(archOpts "-march=armv8-a")
set(ccOpts "")
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
set(CMAKE_C_FLAGS "${archOpts} ${ccOpts}")
set(CMAKE_CXX_FLAGS "${archOpts} ${ccOpts}")