From a197623126926f3a45ab6a00aaed8dee8aa68cae Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 27 Mar 2022 13:02:12 +0200 Subject: [PATCH] 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) --- misc/build-containers-frt/.gitignore | 4 ++ misc/build-containers-frt/LICENSE | 24 ++++++++++ misc/build-containers-frt/README | 7 +++ .../docker/Dockerfile.arm32v7 | 5 ++ .../docker/Dockerfile.arm64v8 | 5 ++ .../docker/Dockerfile.base | 10 ++++ .../docker/Dockerfile.droid | 11 +++++ .../docker/Dockerfile.x86_64 | 3 ++ misc/build-containers-frt/docker/build.sh | 6 +++ misc/build-containers-frt/docker/docker.sh | 15 ++++++ misc/build-containers-frt/scripts/build_sdl2 | 31 ++++++++++++ misc/build-containers-frt/scripts/detect | 48 +++++++++++++++++++ .../toolchains/linux-arm32v6-gcc.cmake | 10 ++++ .../toolchains/linux-arm32v7-clang.cmake | 10 ++++ .../toolchains/linux-arm32v7-gcc.cmake | 10 ++++ .../toolchains/linux-arm64v8-clang.cmake | 10 ++++ .../toolchains/linux-arm64v8-gcc.cmake | 9 ++++ 17 files changed, 218 insertions(+) create mode 100644 misc/build-containers-frt/.gitignore create mode 100644 misc/build-containers-frt/LICENSE create mode 100644 misc/build-containers-frt/README create mode 100644 misc/build-containers-frt/docker/Dockerfile.arm32v7 create mode 100644 misc/build-containers-frt/docker/Dockerfile.arm64v8 create mode 100644 misc/build-containers-frt/docker/Dockerfile.base create mode 100644 misc/build-containers-frt/docker/Dockerfile.droid create mode 100644 misc/build-containers-frt/docker/Dockerfile.x86_64 create mode 100755 misc/build-containers-frt/docker/build.sh create mode 100755 misc/build-containers-frt/docker/docker.sh create mode 100755 misc/build-containers-frt/scripts/build_sdl2 create mode 100644 misc/build-containers-frt/scripts/detect create mode 100644 misc/build-containers-frt/toolchains/linux-arm32v6-gcc.cmake create mode 100644 misc/build-containers-frt/toolchains/linux-arm32v7-clang.cmake create mode 100644 misc/build-containers-frt/toolchains/linux-arm32v7-gcc.cmake create mode 100644 misc/build-containers-frt/toolchains/linux-arm64v8-clang.cmake create mode 100644 misc/build-containers-frt/toolchains/linux-arm64v8-gcc.cmake diff --git a/misc/build-containers-frt/.gitignore b/misc/build-containers-frt/.gitignore new file mode 100644 index 000000000..ddaeb2f50 --- /dev/null +++ b/misc/build-containers-frt/.gitignore @@ -0,0 +1,4 @@ +*.o +*.bin +build/ +.clang-format diff --git a/misc/build-containers-frt/LICENSE b/misc/build-containers-frt/LICENSE new file mode 100644 index 000000000..68a49daad --- /dev/null +++ b/misc/build-containers-frt/LICENSE @@ -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 diff --git a/misc/build-containers-frt/README b/misc/build-containers-frt/README new file mode 100644 index 000000000..ffe300921 --- /dev/null +++ b/misc/build-containers-frt/README @@ -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/). diff --git a/misc/build-containers-frt/docker/Dockerfile.arm32v7 b/misc/build-containers-frt/docker/Dockerfile.arm32v7 new file mode 100644 index 000000000..fe2fc8c4f --- /dev/null +++ b/misc/build-containers-frt/docker/Dockerfile.arm32v7 @@ -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 diff --git a/misc/build-containers-frt/docker/Dockerfile.arm64v8 b/misc/build-containers-frt/docker/Dockerfile.arm64v8 new file mode 100644 index 000000000..97612fabf --- /dev/null +++ b/misc/build-containers-frt/docker/Dockerfile.arm64v8 @@ -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 diff --git a/misc/build-containers-frt/docker/Dockerfile.base b/misc/build-containers-frt/docker/Dockerfile.base new file mode 100644 index 000000000..ac81b927f --- /dev/null +++ b/misc/build-containers-frt/docker/Dockerfile.base @@ -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 diff --git a/misc/build-containers-frt/docker/Dockerfile.droid b/misc/build-containers-frt/docker/Dockerfile.droid new file mode 100644 index 000000000..df604c04e --- /dev/null +++ b/misc/build-containers-frt/docker/Dockerfile.droid @@ -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 diff --git a/misc/build-containers-frt/docker/Dockerfile.x86_64 b/misc/build-containers-frt/docker/Dockerfile.x86_64 new file mode 100644 index 000000000..d524ceb6e --- /dev/null +++ b/misc/build-containers-frt/docker/Dockerfile.x86_64 @@ -0,0 +1,3 @@ +FROM crossbuild:base +RUN apt-get install -y -q \ + libstdc++-8-dev libsdl2-dev libgbm-dev libsamplerate0-dev diff --git a/misc/build-containers-frt/docker/build.sh b/misc/build-containers-frt/docker/build.sh new file mode 100755 index 000000000..fe8aeca98 --- /dev/null +++ b/misc/build-containers-frt/docker/build.sh @@ -0,0 +1,6 @@ +#! /bin/sh +set -e + +[ -f Dockerfile.$1 ] + +exec docker build -t crossbuild:$1 -f Dockerfile.$1 . diff --git a/misc/build-containers-frt/docker/docker.sh b/misc/build-containers-frt/docker/docker.sh new file mode 100755 index 000000000..79840bc88 --- /dev/null +++ b/misc/build-containers-frt/docker/docker.sh @@ -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 diff --git a/misc/build-containers-frt/scripts/build_sdl2 b/misc/build-containers-frt/scripts/build_sdl2 new file mode 100755 index 000000000..294aba838 --- /dev/null +++ b/misc/build-containers-frt/scripts/build_sdl2 @@ -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 diff --git a/misc/build-containers-frt/scripts/detect b/misc/build-containers-frt/scripts/detect new file mode 100644 index 000000000..72c83b815 --- /dev/null +++ b/misc/build-containers-frt/scripts/detect @@ -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" diff --git a/misc/build-containers-frt/toolchains/linux-arm32v6-gcc.cmake b/misc/build-containers-frt/toolchains/linux-arm32v6-gcc.cmake new file mode 100644 index 000000000..326dba999 --- /dev/null +++ b/misc/build-containers-frt/toolchains/linux-arm32v6-gcc.cmake @@ -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}") + diff --git a/misc/build-containers-frt/toolchains/linux-arm32v7-clang.cmake b/misc/build-containers-frt/toolchains/linux-arm32v7-clang.cmake new file mode 100644 index 000000000..cdb32c3c0 --- /dev/null +++ b/misc/build-containers-frt/toolchains/linux-arm32v7-clang.cmake @@ -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}") + diff --git a/misc/build-containers-frt/toolchains/linux-arm32v7-gcc.cmake b/misc/build-containers-frt/toolchains/linux-arm32v7-gcc.cmake new file mode 100644 index 000000000..5b8ddf11e --- /dev/null +++ b/misc/build-containers-frt/toolchains/linux-arm32v7-gcc.cmake @@ -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}") + diff --git a/misc/build-containers-frt/toolchains/linux-arm64v8-clang.cmake b/misc/build-containers-frt/toolchains/linux-arm64v8-clang.cmake new file mode 100644 index 000000000..b1d922af9 --- /dev/null +++ b/misc/build-containers-frt/toolchains/linux-arm64v8-clang.cmake @@ -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}") + diff --git a/misc/build-containers-frt/toolchains/linux-arm64v8-gcc.cmake b/misc/build-containers-frt/toolchains/linux-arm64v8-gcc.cmake new file mode 100644 index 000000000..b661d64d3 --- /dev/null +++ b/misc/build-containers-frt/toolchains/linux-arm64v8-gcc.cmake @@ -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}")