Create toolchain for multiple architectures on linux

This commit is contained in:
Lorenzooone 2024-08-09 22:31:50 +02:00
parent 8d76e38a37
commit 08420c916f
19 changed files with 302 additions and 28 deletions

View File

@ -16,36 +16,42 @@ jobs:
fail-fast: false
matrix:
platform:
- { name: Windows VS2022, os: windows-2022 }
- { name: Windows VS2022 ARM, os: windows-2022, flags: -A ARM64}
- { name: Linux GCC, os: ubuntu-latest }
- { name: macOS Apple Silicon, os: macos-14 }
- { name: Windows VS2022 x64, os: windows-2022, flags: -A x64}
- { name: Windows VS2022 ARM, os: windows-2022, flags: -A ARM64}
- { name: Windows VS2022 Win32, os: windows-2022, flags: -A Win32}
- { name: Linux GCC x64, os: ubuntu-latest, flags: 64}
- { name: Linux GCC 32, os: ubuntu-latest, flags: 32}
- { name: Linux GCC ARM 64, os: ubuntu-latest, flags: arm64}
- { name: Linux GCC ARM 32, os: ubuntu-latest, flags: arm32}
- { name: macOS Apple Silicon, os: macos-14 }
config:
- { name: Static, flags: -DBUILD_SHARED_LIBS=FALSE }
steps:
- name: Install Linux Dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install libxrandr-dev libxcursor-dev libudev-dev libopenal-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev
- name: Checkout
uses: actions/checkout@v3
- name: Configure
if: runner.os != 'Linux'
shell: bash
run: cmake -S . -B build -DCMAKE_INSTALL_PREFIX=install ${{matrix.platform.flags}} ${{matrix.config.flags}}
- name: Build Linux
if: runner.os == 'Linux'
run: docker run --rm -u root -v ${PWD}:/home/builder/cc3dsfs lorenzooone/cc3dsfs:builder${{matrix.platform.flags}}
- name: Build Windows
if: runner.os == 'Windows'
shell: bash
run: cmake --build build --config Release
- name: Build (not Windows)
if: runner.os != 'Windows'
- name: Build macOS
if: runner.os == 'macOS'
shell: bash
run: cmake --build build --config Release -j
- name: Pack
- name: Pack (not Linux)
if: runner.os != 'Linux'
shell: bash
run: cd build && cpack -G ZIP
@ -82,5 +88,11 @@ jobs:
files: >
cc3dsfs_windows_arm64.zip
cc3dsfs_windows_x86_64.zip
cc3dsfs_windows_x86_32.zip
cc3dsfs_linux_x86_32.zip
cc3dsfs_linux_x86_64.zip
cc3dsfs_linux_arm32.zip
cc3dsfs_linux_arm64.zip
cc3dsfs_linux_pi32.zip
cc3dsfs_linux_pi64.zip
cc3dsfs_macos.zip

View File

@ -11,36 +11,42 @@ jobs:
fail-fast: false
matrix:
platform:
- { name: Windows VS2022, os: windows-2022 }
- { name: Windows VS2022 ARM, os: windows-2022, flags: -A ARM64}
- { name: Linux GCC, os: ubuntu-latest }
- { name: macOS Apple Silicon, os: macos-14 }
- { name: Windows VS2022 x64, os: windows-2022, flags: -A x64}
- { name: Windows VS2022 ARM, os: windows-2022, flags: -A ARM64}
- { name: Windows VS2022 Win32, os: windows-2022, flags: -A Win32}
- { name: Linux GCC x64, os: ubuntu-latest, flags: 64}
- { name: Linux GCC 32, os: ubuntu-latest, flags: 32}
- { name: Linux GCC ARM 64, os: ubuntu-latest, flags: arm64}
- { name: Linux GCC ARM 32, os: ubuntu-latest, flags: arm32}
- { name: macOS Apple Silicon, os: macos-14 }
config:
- { name: Static, flags: -DBUILD_SHARED_LIBS=FALSE }
steps:
- name: Install Linux Dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install libxrandr-dev libxcursor-dev libudev-dev libopenal-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev
- name: Checkout
uses: actions/checkout@v3
- name: Configure
if: runner.os != 'Linux'
shell: bash
run: cmake -S . -B build -DCMAKE_INSTALL_PREFIX=install ${{matrix.platform.flags}} ${{matrix.config.flags}}
- name: Build Linux
if: runner.os == 'Linux'
run: docker run --rm -u root -v ${PWD}:/home/builder/cc3dsfs lorenzooone/cc3dsfs:builder${{matrix.platform.flags}}
- name: Build Windows
if: runner.os == 'Windows'
shell: bash
run: cmake --build build --config Release
- name: Build (not Windows)
if: runner.os != 'Windows'
- name: Build macOS
if: runner.os == 'macOS'
shell: bash
run: cmake --build build --config Release -j
- name: Pack
- name: Pack (not Linux)
if: runner.os != 'Linux'
shell: bash
run: cd build && cpack -G ZIP

4
.gitignore vendored
View File

@ -8,5 +8,7 @@ cc3dsfs.exe
*.zip
ftd3xx/
presets/
build/
build*/
!build-dockers/
.config/
out/

View File

@ -5,6 +5,7 @@ project(cc3dsfs VERSION 1.0.0 LANGUAGES CXX)
include(ExternalProject)
set(WINDOWS_ARM64 0)
set(WINDOWS_x86_32 0)
set(FETCHCONTENT_UPDATES_DISCONNECTED ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
@ -27,10 +28,14 @@ if (RASPBERRY_PI_COMPILATION)
set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS}-DRASPI 1 ")
endif()
if((${CMAKE_SYSTEM_NAME} STREQUAL "Windows") AND ((${CMAKE_GENERATOR_PLATFORM} MATCHES "ARM64") OR ("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "" AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "ARM64")))
if((${CMAKE_SYSTEM_NAME} STREQUAL "Windows") AND ((${CMAKE_GENERATOR_PLATFORM} MATCHES "ARM64") OR (("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "") AND (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ARM64"))))
set(WINDOWS_ARM64 1)
endif()
if((${CMAKE_SYSTEM_NAME} STREQUAL "Windows") AND ((${CMAKE_GENERATOR_PLATFORM} MATCHES "Win32") OR (("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "") AND (${CMAKE_SYSTEM_PROCESSOR} MATCHES "Win32"))))
set(WINDOWS_x86_32 1)
endif()
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
@ -384,13 +389,21 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
if(WINDOWS_ARM64)
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_windows_arm64)
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_windows_x86_64)
elseif(WINDOWS_x86_32)
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_windows_x86_32)
else()
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_windows_${CMAKE_SYSTEM_PROCESSOR})
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_windows_x86_64)
endif()
else()
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_linux_${CMAKE_SYSTEM_PROCESSOR})
if(RASPBERRY_PI_COMPILATION)
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_linux_pi64)
else()
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_linux_pi32)
endif()
else()
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_linux_${CMAKE_SYSTEM_PROCESSOR})
endif()
endif()
include(CPack)

View File

@ -66,6 +66,11 @@ When compiling on a Raspberry Pi, to enable usage of GPIO, use:
cmake -B build -DRASPBERRY_PI_COMPILATION=TRUE ; cmake --build build --config Release
```
### Docker Compilation
Alternatively, one may use Docker to compile the Linux version for its different architectures by running: `docker run --rm -it -v ${PWD}:/home/builder/cc3dsfs lorenzooone/cc3dsfs:<builder>`
The following builders are available: builder32, builder64, builderarm32 and builderarm64.
## Controls
The software has a GUI which exposes all of the available settings. There are also various available keyboard shortcuts which allow quicker access to the options.

View File

@ -0,0 +1,60 @@
################################################################################
### Build cmake ###
################################################################################
FROM ubuntu:jammy as base_builder
RUN apt update && apt install -y lsb-release g++ build-essential wget git libssl-dev pkg-config
RUN wget https://github.com/Kitware/CMake/releases/download/v3.30.2/cmake-3.30.2.tar.gz
RUN tar -xvf cmake-3.30.2.tar.gz
RUN cd cmake-3.30.2 && ./bootstrap && make -j && make install
RUN useradd builder -m
RUN mkdir -p /home/builder/cc3dsfs
RUN mkdir -p /home/builder/building
RUN chown -R builder:builder /home/builder
################################################################################
### Build x86_32 ###
################################################################################
FROM base_builder as builder32
COPY linux_install_packages.sh /
RUN chmod +x /linux_install_packages.sh ; /linux_install_packages.sh i386
WORKDIR /home/builder/building
COPY docker_build_starter /
RUN chmod +x /docker_build_starter
USER builder
CMD /docker_build_starter docker-scripts/docker_build_x86_32
################################################################################
### Build x86_64 ###
################################################################################
FROM base_builder as builder64
COPY linux_install_packages.sh /
RUN chmod +x /linux_install_packages.sh ; /linux_install_packages.sh amd64
WORKDIR /home/builder/building
COPY docker_build_starter /
RUN chmod +x /docker_build_starter
USER builder
CMD /docker_build_starter docker-scripts/docker_build_x86_64
################################################################################
### Build arm 32 ###
################################################################################
FROM base_builder as builderarm32
COPY linux_install_packages.sh /
RUN chmod +x /linux_install_packages.sh ; /linux_install_packages.sh armhf
WORKDIR /home/builder/building
COPY docker_build_starter /
RUN chmod +x /docker_build_starter
USER builder
CMD /docker_build_starter docker-scripts/docker_build_arm32
################################################################################
### Build arm 64 ###
################################################################################
FROM base_builder as builderarm64
COPY linux_install_packages.sh /
RUN chmod +x /linux_install_packages.sh ; /linux_install_packages.sh arm64
WORKDIR /home/builder/building
COPY docker_build_starter /
RUN chmod +x /docker_build_starter
USER builder
CMD /docker_build_starter docker-scripts/docker_build_arm64

View File

@ -0,0 +1,9 @@
#!/bin/bash
docker image rm lorenzooone/cc3dsfs:builder32
docker build --target builder32 . -t lorenzooone/cc3dsfs:builder32
docker image rm lorenzooone/cc3dsfs:builder64
docker build --target builder64 . -t lorenzooone/cc3dsfs:builder64
docker image rm lorenzooone/cc3dsfs:builderarm32
docker build --target builderarm32 . -t lorenzooone/cc3dsfs:builderarm32
docker image rm lorenzooone/cc3dsfs:builderarm64
docker build --target builderarm64 . -t lorenzooone/cc3dsfs:builderarm64

View File

@ -0,0 +1,6 @@
#!/bin/sh
cp -R /home/builder/cc3dsfs/. .
chmod -R +x .
$1

View File

@ -0,0 +1,68 @@
#!/bin/bash
BASE_AMD_STR="deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu/ "
BASE_SECURITY_AMD_STR="deb [arch=amd64,i386] http://security.ubuntu.com/ubuntu/ "
BASE_ARM_STR="deb [arch=arm64,armhf] http://ports.ubuntu.com/ "
NO_SPECIAL_STR=" main multiverse universe"
SECURITY_STR="-security main multiverse universe"
BACKPORTS_STR="-backports main multiverse universe"
UPDATES_STR="-updates main multiverse universe"
LOCATION_BASE="/etc/apt/sources.list.d"
LOCATION_AMD="${LOCATION_BASE}/x86_compilers.list"
LOCATION_ARM="${LOCATION_BASE}/arm_compilers.list"
LIST_ARCHITECTURES=("amd64" "i386" "arm64" "armhf")
LIST_PACKAGES_BASE=("libxinerama-dev" "libxi-dev" "libxss-dev" "libxxf86vm-dev" "libxkbfile-dev" "libxv-dev" "libx11-dev" "libxrandr-dev" "libxcursor-dev" "libudev-dev" "libopenal-dev" "libflac-dev" "libvorbis-dev" "libgl1-mesa-dev" "libegl1-mesa-dev" "libdrm-dev" "libgbm-dev" "libfreetype-dev")
LIST_PACKAGES_NORMAL=("g++-multilib-i686-linux-gnu" "g++-aarch64-linux-gnu" "g++-arm-linux-gnueabihf" "g++:amd64" "g++" "git" "xorg-dev")
LIST_PACKAGES_SPECIAL=("libgpiod-dev")
echo "${BASE_AMD_STR}$(lsb_release -sc)${NO_SPECIAL_STR}" > ${LOCATION_AMD}
echo "${BASE_SECURITY_AMD_STR}$(lsb_release -sc)${SECURITY_STR}" >> ${LOCATION_AMD}
echo "${BASE_AMD_STR}$(lsb_release -sc)${BACKPORTS_STR}" >> ${LOCATION_AMD}
echo "${BASE_AMD_STR}$(lsb_release -sc)${UPDATES_STR}" >> ${LOCATION_AMD}
echo "${BASE_ARM_STR}$(lsb_release -sc)${NO_SPECIAL_STR}" > ${LOCATION_ARM}
echo "${BASE_ARM_STR}$(lsb_release -sc)${SECURITY_STR}" >> ${LOCATION_ARM}
echo "${BASE_ARM_STR}$(lsb_release -sc)${BACKPORTS_STR}" >> ${LOCATION_ARM}
echo "${BASE_ARM_STR}$(lsb_release -sc)${UPDATES_STR}" >> ${LOCATION_ARM}
#for a in ${LIST_ARCHITECTURES[@]};
#do
# dpkg --add-architecture ${a}
#done
dpkg --add-architecture $1
apt update
#for a in ${LIST_ARCHITECTURES[@]};
#do
# PACKAGES=""
# for p in ${LIST_PACKAGES_BASE[@]};
# do
# PACKAGES="${PACKAGES} ${p}:${a}"
# done
# apt install -y ${PACKAGES}
#done
PACKAGES=""
for p in ${LIST_PACKAGES_SPECIAL[@]};
do
PACKAGES="${PACKAGES} ${p}:$1"
done
apt install -y ${PACKAGES}
PACKAGES=""
for p in ${LIST_PACKAGES_BASE[@]};
do
PACKAGES="${PACKAGES} ${p}:$1"
done
apt install -y ${PACKAGES}
PACKAGES=""
for p in ${LIST_PACKAGES_NORMAL[@]};
do
PACKAGES="${PACKAGES} ${p}"
done
apt install -y ${PACKAGES}

View File

@ -0,0 +1,4 @@
#!/bin/sh
docker-scripts/docker_build_base buildarm32 "-DCMAKE_TOOLCHAIN_FILE=toolchains/linux_arm32.cmake"
docker-scripts/docker_build_base buildarm32 "-DRASPBERRY_PI_COMPILATION=TRUE -DCMAKE_TOOLCHAIN_FILE=toolchains/linux_arm32.cmake"

View File

@ -0,0 +1,4 @@
#!/bin/sh
docker-scripts/docker_build_base buildarm64 "-DCMAKE_TOOLCHAIN_FILE=toolchains/linux_arm64.cmake"
docker-scripts/docker_build_base buildarm64 "-DRASPBERRY_PI_COMPILATION=TRUE -DCMAKE_TOOLCHAIN_FILE=toolchains/linux_arm64.cmake"

View File

@ -0,0 +1,9 @@
#!/bin/sh
cmake -S . -B $1 $2
cmake --build $1 --config Release -j
cd $1
cpack -G ZIP
mkdir -p /home/builder/cc3dsfs/build
cp cc3dsfs*.zip /home/builder/cc3dsfs/build
cd ..

View File

@ -0,0 +1,3 @@
#!/bin/sh
docker-scripts/docker_build_base build32 "-DCMAKE_TOOLCHAIN_FILE=toolchains/linux_x86_32.cmake"

View File

@ -0,0 +1,3 @@
#!/bin/sh
docker-scripts/docker_build_base build64 "-DCMAKE_TOOLCHAIN_FILE=toolchains/linux_x86_64.cmake"

View File

@ -0,0 +1,17 @@
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm32)
# which C and C++ compiler to use
set(CMAKE_C_COMPILER "/usr/bin/arm-linux-gnueabihf-gcc")
set(CMAKE_CXX_COMPILER "/usr/bin/arm-linux-gnueabihf-g++")
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /usr/lib/arm-linux-gnueabihf)
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)

View File

@ -0,0 +1,17 @@
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm64)
# which C and C++ compiler to use
set(CMAKE_C_COMPILER "/usr/bin/aarch64-linux-gnu-gcc")
set(CMAKE_CXX_COMPILER "/usr/bin/aarch64-linux-gnu-g++")
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /usr/lib/aarch64-linux-gnu)
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)

View File

@ -0,0 +1,17 @@
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_32)
# which C and C++ compiler to use
set(CMAKE_C_COMPILER "/usr/bin/i686-linux-gnu-gcc")
set(CMAKE_CXX_COMPILER "/usr/bin/i686-linux-gnu-g++")
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /usr/lib/i386-linux-gnu)
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)

View File

@ -0,0 +1,17 @@
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
# which C and C++ compiler to use
set(CMAKE_C_COMPILER /usr/bin/x86_64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /usr/bin/x86_64-linux-gnu-g++)
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /usr/lib/x86_64-linux-gnu)
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)

View File

@ -1,4 +1,6 @@
cmake_minimum_required(VERSION 3.16)
unset(ENV{CC})
unset(ENV{CXX})
project(CMakeBin2C VERSION 1.0.0 LANGUAGES CXX)
add_executable(CMakeBin2C bin2c.cpp)