Skip to content

Commit

Permalink
cmakeGTK3: move from cross compilation to native with QEMU
Browse files Browse the repository at this point in the history
Cross compilation had some issues with the GTK 4 template due to Debian
dependencies. To keep the GTK 3 and GTK 4 templates as close as
possible, move both to using native compilation (with the help of QEMU
emulation).

This also solves an issue with 32-bit Arm cross-compilation specific to
the IDE Templates variable substitution.

Signed-off-by: Leonardo Graboski Veiga <[email protected]>
  • Loading branch information
leograba committed Dec 5, 2024
1 parent 81bf8eb commit ddf6eae
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 77 deletions.
1 change: 0 additions & 1 deletion cmakeGTK3/.doc/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# C++ CMake GTK 3 Template Specific Documentation


> ⚠️ **WARNING:** This is just the documentation part specific of this template. **For the complete and general Torizon IDE documentation, check the [developer website documentation](https://developer.toradex.com/torizon/application-development/ide-extension/)** ⚠️
All projects follow the pipeline of tasks described in the [common contributing documentation](https://github.com/toradex/vscode-torizon-templates/blob/bookworm/CONTRIBUTING.md#contributing-templates). However, each project has its own specificities in terms of technologies and methods used to compile, deploy, and debug the code. Therefore, each of them has their own specific tasks in the `tasks.json` file.
Expand Down
55 changes: 18 additions & 37 deletions cmakeGTK3/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
ARG CROSS_SDK_BASE_TAG=4
ARG BASE_VERSION=4
##
# Board architecture
##
ARG IMAGE_ARCH=

##
# Board GPU vendor prefix
##
ARG GPU=

##
# Directory of the application inside container
##
ARG APP_ROOT=


# BUILD ------------------------------------------------------------------------
FROM torizon/cross-toolchain-${IMAGE_ARCH}:${CROSS_SDK_BASE_TAG} AS build
FROM --platform=linux/${IMAGE_ARCH} torizon/wayland-gtk3${GPU}:${BASE_VERSION} AS build

ARG APP_ROOT
ARG GPU
ARG IMAGE_ARCH

# for vivante GPU we need some "special" sauce
# __deps__
RUN apt-get -q -y update && \
if [ "${GPU}" = "-vivante" ] || [ "${GPU}" = "-imx8" ]; then \
if [ "${GPU}" = "-vivante" ] || [ "${GPU}" = "-imx8" ]; then \
apt-get -q -y install \
imx-gpu-viv-wayland-dev \
; else \
Expand All @@ -28,14 +33,10 @@ RUN apt-get -q -y update && \
libgles-dev \
; fi \
&& \
apt-get clean && apt-get autoremove && \
rm -rf /var/lib/apt/lists/*

# __deps__
RUN apt-get -q -y update && \
apt-get -q -y install \
build-essential \
cmake \
libgtk-3-dev:${IMAGE_ARCH} \
libgtk-3-dev \
# DO NOT REMOVE THIS LABEL: this is used for VS Code automation
# __torizon_packages_build_start__
# __torizon_packages_build_end__
Expand All @@ -50,44 +51,24 @@ WORKDIR ${APP_ROOT}

# Remove the code from the debug builds, inside this container, to build the
# release version from a clean build
RUN rm -rf ${APP_ROOT}/build-${IMAGE_ARCH}

RUN if [ "$IMAGE_ARCH" = "arm64" ] ; then \
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -Bbuild-${IMAGE_ARCH} ; \
elif [ "$IMAGE_ARCH" = "arm" ] ; then \
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -Bbuild-${IMAGE_ARCH} ; \
fi

RUN cmake --build build-${IMAGE_ARCH}
RUN rm -rf ${APP_ROOT}/build-${IMAGE_ARCH} && \
cmake -DCMAKE_BUILD_TYPE=Release -Bbuild-${IMAGE_ARCH} && \
cmake --build build-${IMAGE_ARCH}

# BUILD ------------------------------------------------------------------------


##
# Deploy Step
##
FROM --platform=linux/${IMAGE_ARCH} torizon/wayland-gtk3:${BASE_VERSION} AS deploy
FROM --platform=linux/${IMAGE_ARCH} torizon/wayland-gtk3${GPU}:${BASE_VERSION} AS deploy

ARG IMAGE_ARCH
ARG GPU
ARG APP_ROOT

# for vivante GPU we need some "special" sauce
RUN apt-get -q -y update && \
if [ "${GPU}" = "-vivante" ] || [ "${GPU}" = "-imx8" ]; then \
apt-get -q -y install \
imx-gpu-viv-wayland-dev \
; else \
apt-get -q -y install \
libgl1 \
libgles-dev \
; fi \
&& \
apt-get clean && apt-get autoremove && \
rm -rf /var/lib/apt/lists/*

RUN apt-get -y update && \
apt-get install -y --no-install-recommends \
libgtk-3-0 \
RUN apt-get -y update && apt-get install -y --no-install-recommends \
libgtk-4-1 \
# DO NOT REMOVE THIS LABEL: this is used for VS Code automation
# __torizon_packages_prod_start__
# __torizon_packages_prod_end__
Expand Down
27 changes: 9 additions & 18 deletions cmakeGTK3/Dockerfile.debug
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ ARG DEBUG_SSH_PORT=
##
ARG SSHUSERNAME=

##
# Board GPU vendor prefix
##
ARG GPU=

##
# Application root directory inside the container
##
Expand All @@ -31,11 +36,12 @@ ARG APP_ROOT=
# Deploy Step
##
FROM --platform=linux/${IMAGE_ARCH} \
torizon/wayland-gtk3:${BASE_VERSION} AS debug
torizon/wayland-gtk3${GPU}:${BASE_VERSION} AS debug

ARG IMAGE_ARCH
ARG DEBUG_SSH_PORT
ARG SSHUSERNAME
ARG GPU
ARG APP_ROOT

# SSH for remote debug
Expand All @@ -44,31 +50,16 @@ EXPOSE ${DEBUG_SSH_PORT}
# Make sure we don't get notifications we can't answer during building.
ENV DEBIAN_FRONTEND="noninteractive"

# for vivante GPU we need some "special" sauce
RUN apt-get -q -y update && \
if [ "${GPU}" = "-vivante" ] || [ "${GPU}" = "-imx8" ]; then \
apt-get -q -y install \
imx-gpu-viv-wayland-dev \
; else \
apt-get -q -y install \
libgl1 \
libgles-dev \
; fi \
&& \
apt-get clean && apt-get autoremove && \
rm -rf /var/lib/apt/lists/*

# your regular RUN statements here
# Install packages required for debug
# Install required packages
RUN apt-get -q -y update && \
apt-get -q -y install \
openssl \
openssh-server \
rsync \
file \
curl \
gdb \
&& \
gdb && \
apt-get clean && apt-get autoremove && \
rm -rf /var/lib/apt/lists/*

Expand Down
36 changes: 15 additions & 21 deletions cmakeGTK3/Dockerfile.sdk
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# ARGUMENTS --------------------------------------------------------------------
ARG CROSS_SDK_BASE_TAG=4
ARG BASE_VERSION=4

##
# Board architecture
##
ARG IMAGE_ARCH=
##
# Board architecture
##
ARG IMAGE_ARCH=

##
# Board GPU vendor prefix
##
ARG GPU=

##
# Application root directory inside the container
Expand All @@ -13,30 +18,18 @@ ARG APP_ROOT=


# BUILD ------------------------------------------------------------------------
FROM torizon/cross-toolchain-${IMAGE_ARCH}:${CROSS_SDK_BASE_TAG}
FROM --platform=linux/${IMAGE_ARCH} torizon/wayland-gtk3${GPU}:${BASE_VERSION}

ARG APP_ROOT
ARG GPU
ARG IMAGE_ARCH

# for vivante GPU we need some "special" sauce
RUN apt-get -q -y update && \
if [ "${GPU}" = "-vivante" ] || [ "${GPU}" = "-imx8" ]; then \
apt-get -q -y install \
imx-gpu-viv-wayland-dev \
; else \
apt-get -q -y install \
libgl1 \
libgles-dev \
; fi \
&& \
apt-get clean && apt-get autoremove && \
rm -rf /var/lib/apt/lists/*

# __deps__
RUN apt-get -q -y update && \
apt-get -q -y install \
build-essential \
cmake \
libgtk-3-dev:${IMAGE_ARCH} \
libgtk-3-dev \
# ADD YOUR PACKAGES HERE
&& \
apt-get clean && apt-get autoremove && \
Expand All @@ -56,3 +49,4 @@ RUN apt-get -q -y update && \

USER torizon
WORKDIR ${APP_ROOT}

0 comments on commit ddf6eae

Please sign in to comment.