Skip to content

Commit

Permalink
cmake-multiplatform: fix for others than x86-64
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-roos committed Nov 7, 2024
1 parent e1e4c10 commit 9bec3ab
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 44 deletions.
158 changes: 119 additions & 39 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,71 +9,133 @@ jobs:
strategy:
fail-fast: false
matrix:
build_type: [RelWithDebInfo, MinSizeRel]
architecture: [aarch64-linux-gnu, arm-linux-gnueabihf, ""]
architecture: [aarch64-linux-gnu, ""] # arm-linux-gnueabihf
build_type: [RelWithDebInfo] # MinSizeRel
steps:
- uses: actions/checkout@v4
- name: Install generic dependencies
run: |
sudo apt clean && sudo apt update
sudo apt-get -y install --no-install-recommends \
cmake \
curl \
libc6-dev-i386 \
git \
pkg-config \
systemd \
systemd-sysv \
dbus \
ca-certificates \
build-essential \
cmake \
file
- name: Install x86-64 dependencies / settings
if: matrix.architecture == ''
run: |
sudo apt-get -y install \
build-essential \
libcurl4-openssl-dev \
libevent-dev \
libssl-dev \
libsqlite3-dev \
libsystemd-dev \
liburiparser-dev \
libyaml-dev \
libzip-dev \
pkg-config \
libzip-dev \
uuid-dev
- name: Install x86-64 dependencies / settings
if: matrix.architecture == ''
run: |
sudo apt-get -y install \
build-essential
echo "cmake_settings=" >> "$GITHUB_OUTPUT"
- name: Install arm64 dependencies / settings
if: matrix.architecture == 'aarch64-linux-gnu'
run: |
sudo apt-get -y install --no-install-recommends \
qemu-user-static \
g++-aarch64-linux-gnu \
sudo apt-get remove -y libcurl4-openssl-dev \
cmake
sudo rm -rf /etc/apt/sources.list.d/*
cat << EOF | sudo tee -a /etc/apt/sources.list.d/cross-packages.list
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble-updates main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble-backports main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble-security main restricted universe multiverse
EOF
sudo dpkg --add-architecture arm64
sudo apt clean && sudo apt update
sudo apt-get -y remove \
libzip-dev \
libcurl4-openssl-dev \
libevent-dev \
libssl-dev \
libsqlite3-dev \
libsystemd-dev \
liburiparser-dev \
libyaml-dev \
libzip-dev \
uuid-dev
sudo apt-get -y install \
binutils-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
gcc-aarch64-linux-gnu
cat << EOF | tee -a ${{ matrix.architecture }}.cmake
libzip-dev:arm64 \
libcurl4-openssl-dev:arm64 \
libevent-dev:arm64 \
libssl-dev:arm64 \
libsqlite3-dev:arm64 \
libsystemd-dev:arm64 \
liburiparser-dev:arm64 \
libyaml-dev:arm64 \
libzip-dev:arm64 \
uuid-dev:arm64 \
cmake \
cat << EOF | tee -a ${{ github.workspace }}/${{ matrix.architecture }}.cmake
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_C_COMPILER_TARGET ${{ matrix.architecture }})
set(CMAKE_CXX_COMPILER_TARGET ${{ matrix.architecture }})
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_CROSSCOMPILING_EMULATOR qemu-aarch64-static -L /usr/${{ matrix.architecture }}/)
set(CMAKE_C_COMPILER_WORKS TRUE)
set(CMAKE_CXX_COMPILER_WORKS TRUE)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
find_program(C_COMPILER_FULL_PATH NAMES aarch64-linux-gnu-gcc)
find_program(C_COMPILER_FULL_PATH NAMES ${{ matrix.architecture }}-gcc)
if(NOT C_COMPILER_FULL_PATH)
message(FATAL_ERROR "Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found")
endif()
set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH})
find_program(CXX_COMPILER_FULL_PATH NAMES g++-${CMAKE_CXX_COMPILER_TARGET} ${CMAKE_CXX_COMPILER_TARGET}-g++)
if(CXX_COMPILER_FULL_PATH)
set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH})
find_program(CXX_COMPILER_FULL_PATH NAMES ${{ matrix.architecture }}-g++)
if(NOT CXX_COMPILER_FULL_PATH)
message(FATAL_ERROR "C++ Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found")
endif()
set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH})
set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/${{ matrix.architecture }}/pkgconfig")
EOF
echo "CMAKE_SETTINGS=-DCMAKE_TOOLCHAIN_FILE=${{ matrix.architecture }}.cmake" >> "$GITHUB_ENV"
echo CMAKE_SETTINGS="-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/${{ matrix.architecture }}.cmake" >> "$GITHUB_ENV"
- name: Install arm32 dependencies / settings
if: matrix.architecture == 'arm-linux-gnueabihf'
run: |
sudo apt-get -y install --no-install-recommends \
qemu-user-static \
libc-dev-armel-cross \
gcc-arm-linux-gnueabihf \
sudo rm -rf /etc/apt/sources.list.d/*
cat << EOF | sudo tee -a /etc/apt/sources.list.d/cross-packages.list
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ noble main restricted universe multiverse
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ noble-updates main restricted universe multiverse
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ noble-backports main restricted universe multiverse
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ noble-security main restricted universe multiverse
EOF
sudo dpkg --add-architecture armhf
sudo apt clean && sudo apt update
sudo apt-get -y install \
libc6-dev-armhf-cross \
libc6-armhf-cross \
binutils-arm-linux-gnueabihf \
g++-arm-linux-gnueabihf \
binutils-arm-linux-gnueabihf
cat << EOF | tee -a ${{ matrix.architecture }}.cmake
gcc-arm-linux-gnueabihf \
libcurl4-openssl-dev:armhf \
libevent-dev:armhf \
libssl-dev:armhf \
libsqlite3-dev:armhf \
libsystemd-dev:armhf \
liburiparser-dev:armhf \
libyaml-dev:armhf \
libzip-dev:armhf \
uuid-dev:armhf \
libcurl4-openssl-dev:armhf
cat << EOF | tee -a ${{ github.workspace }}/${{ matrix.architecture }}.cmake
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_SYSTEM_VERSION 1)
Expand All @@ -85,34 +147,52 @@ jobs:
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
find_program(C_COMPILER_FULL_PATH NAMES ${{ matrix.architecture }}-gcc)
if(NOT C_COMPILER_FULL_PATH)
message(FATAL_ERROR "Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found")
endif()
set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH})
find_program(CXX_COMPILER_FULL_PATH NAMES g++-${CMAKE_CXX_COMPILER_TARGET} ${CMAKE_CXX_COMPILER_TARGET}-g++)
if(CXX_COMPILER_FULL_PATH)
set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH})
find_program(CXX_COMPILER_FULL_PATH NAMES ${{ matrix.architecture }}-g++)
if(NOT CXX_COMPILER_FULL_PATH)
message(FATAL_ERROR "C++ Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found")
endif()
set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH})
EOF
echo "CMAKE_SETTINGS=-DCMAKE_TOOLCHAIN_FILE=${{ matrix.architecture }}.cmake" >> "$GITHUB_ENV"
echo CMAKE_SETTINGS=-DCMAKE_TOOLCHAIN_FILE=${{ matrix.architecture }}.cmake" >> "$GITHUB_ENV"
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name:
Configure CMake ${{ matrix.build_type }} / ${{ matrix.architecture }}
run: >
cmake ${{ env.CMAKE_SETTINGS }} -B ${{
steps.strings.outputs.build-output-dir }}
-DCMAKE_INSTALL_PREFIX=/opt/aws-greengrass-lite -DGGL_LOG_LEVEL=DEBUG
-S ${{ github.workspace }}
shell: bash
run: |
cmake \
${{ env.CMAKE_SETTINGS }} \
-B ${{ steps.strings.outputs.build-output-dir }} \
-DCMAKE_INSTALL_PREFIX=/opt/aws-greengrass-lite \
-DGGL_LOG_LEVEL=DEBUG \
-S ${{ github.workspace }} \
-DCMAKE_C_COMPILER_TARGET=${{ matrix.architecture }} \
-DCMAKE_FIND_DEBUG_MODE=ON \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
- name: Build
run: |
make -C ${{ steps.strings.outputs.build-output-dir }} -j$(nproc)
- name: Package
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: cpack -G DEB
run: |
cpack -G DEB
mkdir ${{ github.workspace }}/zipfile/
cp ${{ steps.strings.outputs.build-output-dir }}/*.deb ${{ github.workspace }}/zipfile/
- name: Generate readme / install file
run: |
cat ${{ github.workspace }}/.github/workflows/cmake-multi-platform/readme.template.txt >> ${{ github.workspace }}/zipfile/readme.txt
cp ${{ github.workspace }}/.github/workflows/cmake-multi-platform/install-greengrass-lite.sh ${{ github.workspace }}/zipfile/
- name: Save package
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.architecture }}_${{ matrix.build_type }}.deb
path: ${{ steps.strings.outputs.build-output-dir }}/*.deb
name: aws-greengrass-lite-ubuntu-${{ matrix.architecture || 'x86-64'}}_${{ matrix.build_type }}
path: |
${{ github.workspace }}/zipfile/*
retention-days: 1
16 changes: 16 additions & 0 deletions .github/workflows/cmake-multi-platform/install-greengrass-lite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

WIP


install -d ${D}/${gg_rundir}
chown ${gg_user}:${gg_group} ${D}/${gg_rundir}

install -d ${D}/${sysconfdir}/greengrass
install -d ${D}/${sysconfdir}/greengrass/config.d

install -m 0644 ${WORKDIR}/greengrass-lite.yaml ${D}/${sysconfdir}/greengrass/config.d
sed -i -e 's,@GG_WORKING_DIR@,${gg_workingdir},g' \
-e 's,@GG_USER@,${gg_user},g' \
-e 's,@GG_GROUP@,${gg_group},g' \
${D}/${sysconfdir}/greengrass/config.d/greengrass-lite.yaml
58 changes: 58 additions & 0 deletions .github/workflows/cmake-multi-platform/readme.template.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
This readme file will be generated by the build process, done now for the bug bash manually.

##################

SOME GENERAL INFO about gg-lite


##################

INSTALLATION:
##################

copy *.deb package from zip onto your device (e.g. scp)

copy ConnectionKit zip onto your device (e.g. scp)

sudo apt update

sudo apt install aws-greengrass-lite-0.1.1-Linux.deb

sudo apt install zip

sudo mkdir /etc/greengrass/

sudo unzip -jo connectionKit.zip -d /etc/greengrass/

sudo sed -i -e s:{{config_dir}}:\/etc\/greengrass:g -e s:{{data_dir}}:\/var\/lib\/aws-greengrass-v2:g -e s:{{nucleus_component}}:aws.greengrass.Nucleus-Lite:g /etc/greengrass/config.yaml

add greengrass lite config fragment to /etc/greengrass/config.d/greengrass-lite.yaml

replace @GG_WORKING_DIR@ with the directory you want to run it - can be the Desktop for testing: e.g. /home/ubuntu/Desktop
replace @GG_USER@ and @GG_GROUP@ with user and group you want to run it - e.g. ubuntu or the user you created.

---
system:
rootPath: "@GG_WORKING_DIR@"
services:
aws.greengrass.Nucleus-Lite:
componentType: "NUCLEUS"
configuration:
runWithDefault:
posixUser: "@GG_USER@:@GG_GROUP@"
greengrassDataPlanePort: "8443"
tesCredUrl: "http://127.0.0.1:8080/"


run_nucleus

##################


SOME ADDITIONAL INFO


##################


SOME LICENSE TEXT HERE
6 changes: 1 addition & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,7 @@ set(CPACK_GENERATOR DEB)

set(CPACK_DEBIAN_PACKAGE_RELEASE "${LINUX_DISTRO_STRING}")

if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64)
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
endif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "all")

set(CPACK_PACKAGE_CONTACT
"https://github.com/aws-greengrass/aws-greengrass-lite")
Expand Down

0 comments on commit 9bec3ab

Please sign in to comment.