diff --git a/README.md b/README.md index 8fed4fc33..748698b51 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ We encourage you to also contribute templates. The community supported templates | ![](https://raw.githubusercontent.com/toradex/vscode-torizon-templates-documentation/refs/heads/main/thumbnails/avaloniagtk.png?raw=true) | .NET 8 C# Avalonia GTK MVVM | .NET 8.0 | C# | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [dotnetAvalonia](./dotnetAvalonia) | ![](https://avatars.githubusercontent.com/u/2633321?v=4&s=64) [@microhobby](https://www.github.com/microhobby) | | ![](https://raw.githubusercontent.com/toradex/vscode-torizon-templates-documentation/refs/heads/main/thumbnails/gambasform.png?raw=true) | Gambas3 Form Project | Gambas3 | Visual Basic | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [gambasForms](./gambasForms) | ![](https://avatars.githubusercontent.com/u/2633321?v=4&s=64) [@microhobby](https://www.github.com/microhobby) | | ![](https://raw.githubusercontent.com/toradex/vscode-torizon-templates-documentation/refs/heads/main/thumbnails/python3console.png?raw=true) | Python 3 Pyside 2(Qt5) QML | Pyside 2 | Python 3 | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [python3Pyside2QML](./python3Pyside2QML) | ![](https://github.com/toradex/vscode-torizon-templates-documentation/blob/main/thumbnails/none.png?raw=true) [@andreriesco](https://www.github.com/andreriesco) | +| ![](https://raw.githubusercontent.com/toradex/vscode-torizon-templates-documentation/refs/heads/main/thumbnails/gtk3.png?raw=true) | CMake C++ GTK 3 | GTK 3 | C++ | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [cmakeGTK3](./cmakeGTK3) | ![](https://avatars.githubusercontent.com/u/7726309?v=4&s=64) ![](https://avatars.githubusercontent.com/u/142019321?v=4&s=64) [@torizon](https://www.github.com/torizon) | | ![](https://raw.githubusercontent.com/toradex/vscode-torizon-templates-documentation/refs/heads/main/thumbnails/cconsole.png?raw=true) | C Makefile Console Application | libc | C | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) ![](assets/img/riscv64.png?raw=true&id=2) ![](assets/img/x8664.png?raw=true&id=2) | [cConsole](./cConsole) | ![](https://avatars.githubusercontent.com/u/19562097?v=4&s=64) [@hiagofranco](https://www.github.com/hiagofranco) | | ![](https://raw.githubusercontent.com/toradex/vscode-torizon-templates-documentation/refs/heads/main/thumbnails/zig-console.png?raw=true) | Zig Console Application | no-libc | Zig | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [zigConsole](./zigConsole) | ![](https://avatars.githubusercontent.com/u/6756180?v=4&s=64) [@kassane](https://www.github.com/kassane) | | ![](https://raw.githubusercontent.com/toradex/vscode-torizon-templates-documentation/refs/heads/main/thumbnails/unogtk5.png?raw=true) | .NET 8 C# Uno 5 Platform Skia.GTK | .NET 8.0 | C# | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [dotnetUno5](./dotnetUno5) | ![](https://avatars.githubusercontent.com/u/2633321?v=4&s=64) [@microhobby](https://www.github.com/microhobby) | diff --git a/cmakeGTK3/.conf/deps.json b/cmakeGTK3/.conf/deps.json new file mode 100644 index 000000000..75d0f7afc --- /dev/null +++ b/cmakeGTK3/.conf/deps.json @@ -0,0 +1,11 @@ +{ + "packages": [ + "openssh-client", + "sshpass", + "build-essential", + "cmake", + "gdb", + "g++", + "libgtk-3-dev" + ] +} diff --git a/cmakeGTK3/.conf/id_rsa b/cmakeGTK3/.conf/id_rsa new file mode 100644 index 000000000..af98f44ff --- /dev/null +++ b/cmakeGTK3/.conf/id_rsa @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEAqpUaOa6i/TaSKwpdsHzLfGK95dDcFYpmYH5hUj0cBhVEVdl8 +JAG0MEDcZsjQHiBlfUiHmyU2iOWBoKUytpMnzYF6ggdZBv5hBMv3RcTlnNijxzxg +KvbjTm3LqAY8uu4SF9I8oDXVOn7xwZYgiC7s3XRGOP6TowSVEHsLB+cehWs4Y5io +3BngOlcOYZtVrh+i3A7xSHWP7n2IetJEo5C425oaOCZXUJT2egau6ODmvBItZjpG +mNdwVwrEI2H3o+LLI9tieNfyFcUFPNDRXbku1V0mXU9VjZ7WFihZXob11XNCEkY7 +Bg3SpzTntSRn9hZD7i3xDU9MSJz90rnn56ID1wIDAQABAoIBACI239i7/3Mcc/rw +DFSu4z2irIYg+1PSu7AVCT4uhaVutJMnmS+7q8GV8N8o3h18z/5uAs0KjMKuje6D +1AUsxOoCU2krQh8V/K2yn3k+AfQQu+DlakCT3onHmfassZeo0rY2c/SKd6dQ+Pqk +Owg1qUrN3Jvn7ALhk2iH1XGTWNrXj44AxVVhK3zADd/688stubo+mhj1vLJvk3IJ +j/cb9UtCnWDZ6U6E4C+5tfXqzrqbtlrWnIBe0qAwYI6+f4bSQxnNa42wNUh0v0mX +tiY9wnHEmE7nCQNQ8sBeBLEJm3xmFRhABNA+iAglsjfeBIbPNpy7rXty412CmHp0 +mLG0RskCgYEA4t4Ca3EDq/scg7fiplLjhk2AtsZumkYT/N+42x4VlioKfoaivLKf +6mjWUSr+c7Aq0Ssx9GdOFU0epNGbuvymCGBhq6v27SADMJTP2Dmg83FpcV6opOUM +SBz1tnrL9j74Eo9jGdnBjgxHOl4biO+uCjCZxcLoVjsfPpGnCeNSpFUCgYEAwHzM +GfiBR9wl+7cVrtP4YQgmzyZ6YCnqkfFasVAe6cN/0if5sqQRn3Fg3YFrP9GlKkkn +EMvow56nTWUmpx4KG4yanrocEYIsA4uv4kwyFOC/YD+67SQpgTEOjD0seDJoOgpz +ekkxNjMro8RJCK+DrV17qk3/dGY4b3u2M66P03sCgYEAhHCcswJX5WeD/vUzkGtl +PfsywADZgqCUfJRSg0Bt06sZU0Hf8Q7KQnsPWnUh9IGMjW2NDSPdtpu93vQq2J8z +gkJZ4nFShp2gnxTQvWbvKg80QiXDh/fbEqItY2kOduPNyHACp42y6+0JC+7yXh+l +13cF3ihpoCWFmO5IuIIHtb0CgYEAk5acwEUEi17HWOuWmog4591iNG8iYd2B2Akh +Ktdt/HtD5JV2JX0bbg924CA9ZZ+Pbo7Mf1p5zJQ3X2Zxbq3fviPe4ll88AfJS6at +Y2xc8hkpY9k5sF6L3F0K9IhrMnYj6GzfAiJgs1gk29rCzQAWjLUi/v/zIQLHvuMy +Xwo3iUUCgYEAo/27Qkb5nOdL8sJwFggDrdB1pPrxXN20KmYCJF1P9wPDhnj1fJ7+ +0Z/56XYzPA2rQx0vf5idvoGQ3KZS7QkOClLtcyevH3b38fnmAqv+dPLRHmrSd+3G +BspdMlr3rwZK8RKwXjDzLYpwSvjmf7PTGTPO3C7WTzg+m0U9RbSJKi4= +-----END RSA PRIVATE KEY----- diff --git a/cmakeGTK3/.conf/id_rsa.pub b/cmakeGTK3/.conf/id_rsa.pub new file mode 100644 index 000000000..86f8fe63f --- /dev/null +++ b/cmakeGTK3/.conf/id_rsa.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqlRo5rqL9NpIrCl2wfMt8Yr3l0NwVimZgfmFSPRwGFURV2XwkAbQwQNxmyNAeIGV9SIebJTaI5YGgpTK2kyfNgXqCB1kG/mEEy/dFxOWc2KPHPGAq9uNObcuoBjy67hIX0jygNdU6fvHBliCILuzddEY4/pOjBJUQewsH5x6FazhjmKjcGeA6Vw5hm1WuH6LcDvFIdY/ufYh60kSjkLjbmho4JldQlPZ6Bq7o4Oa8Ei1mOkaY13BXCsQjYfej4ssj22J41/IVxQU80NFduS7VXSZdT1WNntYWKFlehvXVc0ISRjsGDdKnNOe1JGf2FkPuLfENT0xInP3SuefnogPX \ No newline at end of file diff --git a/cmakeGTK3/.conf/update.json b/cmakeGTK3/.conf/update.json new file mode 100644 index 000000000..eeb61a7be --- /dev/null +++ b/cmakeGTK3/.conf/update.json @@ -0,0 +1,10 @@ +[ + { + "source": "CMakeLists.txt", + "target": "CMakeLists.txt" + }, + { + "source": ".vscode/c_cpp_properties.json", + "target": ".vscode/c_cpp_properties.json" + } +] diff --git a/cmakeGTK3/.doc/README.md b/cmakeGTK3/.doc/README.md new file mode 100644 index 000000000..982360355 --- /dev/null +++ b/cmakeGTK3/.doc/README.md @@ -0,0 +1,19 @@ +# 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. + +This C++ GTK 3 template uses `cmake` and `make` to compile the code, with tasks named `build-configure-\${architecture}` (creates the destination directory for the future compiled code and generates the Makefile, using `cmake`) and `build-debug-\${architecture}` (compiles the code). It also uses an SDK container to cross-compile the code. This container image is built using the `Dockerfile.sdk` file, and the tasks that build the containers are named `build-container-image-sdk-\${architecture}`. + +The compiled code is then copied into the container, in the `torizon_app_root` (which is automatically passed to the `APP_ROOT` variable in the `Dockerfiles`) directory defined at `settings.json`, through the Docker `COPY` command. + +The task that has the entire pipeline of executed tasks, from the first step to the last step before the debugging, is the `deploy-torizon-\${architecture}` task. + +Finally, remote debugging is performed by attaching to the GDB on the running container on the device using a [VSCode feature called Pipe Transport](https://code.visualstudio.com/docs/cpp/pipe-transport). For local debugging, the [VSCode method for C/C++ Debugging](https://code.visualstudio.com/docs/cpp/launch-json-reference) is used. The tasks that perform the debugging are those present in the `launch.json` file. + +The source code of the template is a simple GTK 3 Hello World (Hello Torizon, actually) in C++, using CMake as build system. + +## About GTK 3 + +To learn or use GTK 3, you must refer to the official [GTK 3 Documentation](https://docs.gtk.org/gtk3/index.html). diff --git a/cmakeGTK3/.dockerignore b/cmakeGTK3/.dockerignore new file mode 100644 index 000000000..91ac1b8f8 --- /dev/null +++ b/cmakeGTK3/.dockerignore @@ -0,0 +1 @@ +credentials.zip diff --git a/cmakeGTK3/.gitignore b/cmakeGTK3/.gitignore new file mode 100644 index 000000000..a3b9b74c6 --- /dev/null +++ b/cmakeGTK3/.gitignore @@ -0,0 +1,84 @@ + +# Created by https://www.gitignore.io/api/c,c++,cmake + +### C ### +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +### C++ ### +# Prerequisites + +# Compiled Object files +*.slo + +# Precompiled Headers + +# Compiled Dynamic libraries + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai + +# End of https://www.gitignore.io/api/c,c++,cmake + +credentials.zip +*.lock.yml + +#Build directories +build-* + +.conf/.depok +.conf/.docok \ No newline at end of file diff --git a/cmakeGTK3/.vscode/c_cpp_properties.json b/cmakeGTK3/.vscode/c_cpp_properties.json new file mode 100644 index 000000000..370affed6 --- /dev/null +++ b/cmakeGTK3/.vscode/c_cpp_properties.json @@ -0,0 +1,16 @@ +{ + "configurations": [ + { + "name": "__change__", + "includePath": [ + "${workspaceFolder}/includes/**", + "/usr/include/**" + ], + "intelliSenseMode": "linux-gcc-x64", + "compilerPath": "/usr/bin/gcc", + "cStandard": "gnu17", + "cppStandard": "gnu++17" + } + ], + "version": 4 +} diff --git a/cmakeGTK3/.vscode/extensions.json b/cmakeGTK3/.vscode/extensions.json new file mode 100644 index 000000000..7b0e65b66 --- /dev/null +++ b/cmakeGTK3/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "ms-vscode.cpptools", + "twxs.cmake" + ] +} diff --git a/cmakeGTK3/.vscode/launch.json b/cmakeGTK3/.vscode/launch.json new file mode 100644 index 000000000..b7a6c9111 --- /dev/null +++ b/cmakeGTK3/.vscode/launch.json @@ -0,0 +1,171 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Local AMD64", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/build-local/bin/__change__", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceRoot}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set Disassembly Flavor to Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ], + "preLaunchTask": "build-debug-local" + }, + { + "name": "Torizon AMD64", + "type": "cppdbg", + "request": "launch", + "program": "${config:torizon_app_root}/__change__", + "args": [], + "stopAtEntry": false, + "cwd": "${config:torizon_app_root}", + "environment": [], + "externalConsole": false, + "internalConsoleOptions": "openOnSessionStart", + "logging": { + "engineLogging": false, // set this to true for a detailed log on the debug console + }, + "sourceFileMap": { + "${config:torizon_app_root}": "${workspaceFolder}" + }, + "pipeTransport": { + "debuggerPath": "/usr/bin/gdb", + "pipeProgram": "ssh", + "pipeArgs": [ + "-T", + "-q", + "-p", + "${config:torizon_debug_ssh_port}", + "-o", + "StrictHostKeyChecking=no", + "-o", + "UserKnownHostsFile /dev/null", + "${config:torizon_run_as}@${config:torizon_ip}" // user@device + ] + }, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set Disassembly Flavor to Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ], + "preLaunchTask": "deploy-torizon-amd64" + }, + { + "name": "Torizon ARMv7", + "type": "cppdbg", + "request": "launch", + "program": "${config:torizon_app_root}/__change__", + "args": [], + "stopAtEntry": false, + "cwd": "${config:torizon_app_root}", + "environment": [], + "externalConsole": false, + "internalConsoleOptions": "openOnSessionStart", + "logging": { + "engineLogging": false, // set this to true for a detailed log on the debug console + }, + "sourceFileMap": { + "${config:torizon_app_root}": "${workspaceFolder}" + }, + "pipeTransport": { + "debuggerPath": "/usr/bin/gdb", + "pipeProgram": "ssh", + "pipeArgs": [ + "-T", + "-q", + "-p", + "${config:torizon_debug_ssh_port}", + "-o", + "StrictHostKeyChecking=no", + "-o", + "UserKnownHostsFile /dev/null", + "${config:torizon_run_as}@${config:torizon_ip}" // user@device + ] + }, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set Disassembly Flavor to Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ], + "preLaunchTask": "deploy-torizon-arm" + }, + { + "name": "Torizon ARMv8", + "type": "cppdbg", + "request": "launch", + "program": "${config:torizon_app_root}/__change__", + "args": [], + "stopAtEntry": false, + "cwd": "${config:torizon_app_root}", + "environment": [], + "externalConsole": false, + "internalConsoleOptions": "openOnSessionStart", + "logging": { + "engineLogging": false, // set this to true for a detailed log on the debug console + }, + "sourceFileMap": { + "${config:torizon_app_root}": "${workspaceFolder}" + }, + "pipeTransport": { + "debuggerPath": "/usr/bin/gdb", + "pipeProgram": "ssh", + "pipeArgs": [ + "-T", + "-q", + "-p", + "${config:torizon_debug_ssh_port}", + "-o", + "StrictHostKeyChecking=no", + "-o", + "UserKnownHostsFile /dev/null", + "${config:torizon_run_as}@${config:torizon_ip}" // user@device + ] + }, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set Disassembly Flavor to Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ], + "preLaunchTask": "deploy-torizon-arm64" + }, + ] +} diff --git a/cmakeGTK3/.vscode/settings.json b/cmakeGTK3/.vscode/settings.json new file mode 100644 index 000000000..bc3850cc5 --- /dev/null +++ b/cmakeGTK3/.vscode/settings.json @@ -0,0 +1,21 @@ +{ + "torizon_psswd": "", + "torizon_login": "", + "torizon_ip": "", + "torizon_ssh_port": "", + "host_ip": "", + "torizon_workspace": "${workspaceFolder}", + "torizon_debug_ssh_port": "2230", + "torizon_debug_port1": "2232", + "torizon_debug_port2": "2233", + "torizon_debug_port3": "", + "torizon_gpu": "", + "torizon_arch": "", + "wait_sync": "1", + "torizon_run_as": "torizon", + "torizon_app_root": "/home/torizon/app", + "tcb.packageName": "__change__", + "tcb.version": "3.11.0", + "torizon.gpuPrefixRC": true, + "terminal.integrated.defaultProfile.linux": "bash" +} diff --git a/cmakeGTK3/.vscode/tasks.json b/cmakeGTK3/.vscode/tasks.json new file mode 100644 index 000000000..e6606d45d --- /dev/null +++ b/cmakeGTK3/.vscode/tasks.json @@ -0,0 +1,528 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build-configure-local", + "hide": true, + "command": "cmake", + "type": "shell", + "args": [ + "-DCMAKE_BUILD_TYPE=Debug", + "-B${workspaceFolder}/build-local" + ], + "problemMatcher": [ + "$gcc" + ], + "icon": { + "id": "tools", + "color": "terminal.ansiYellow" + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "group": "build-execution" + } + }, + { + "label": "build-configure-arm", + "hide": true, + "command": "DOCKER_HOST=", + "type": "shell", + "args": [ + "docker", + "run", + "--rm", + "-v", + "${workspaceFolder}:${config:torizon_app_root}", + "cross-toolchain-arm-__container__", + "cmake", + "-DCMAKE_BUILD_TYPE=Debug", + "-DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++", + "-DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc", + "-Bbuild-arm" + ], + "problemMatcher": [ + "$gcc" + ], + "dependsOrder": "sequence", + "dependsOn": [ + "build-container-image-sdk-arm" + ], + "icon": { + "id": "tools", + "color": "terminal.ansiYellow" + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "group": "build-execution" + } + }, + { + "label": "build-configure-arm64", + "hide": true, + "command": "DOCKER_HOST=", + "type": "shell", + "args": [ + "docker", + "run", + "--rm", + "-v", + "${workspaceFolder}:${config:torizon_app_root}", + "cross-toolchain-arm64-__container__", + "cmake", + "-DCMAKE_BUILD_TYPE=Debug", + "-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++", + "-DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc", + "-Bbuild-arm64" + ], + "problemMatcher": [ + "$gcc" + ], + "dependsOrder": "sequence", + "dependsOn": [ + "build-container-image-sdk-arm64" + ], + "icon": { + "id": "tools", + "color": "terminal.ansiYellow" + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "group": "build-execution" + } + }, + { + "label": "build-debug-local", + "detail": "Build a debug version of the application for amd64 using\nthe toolchain installed in the host.", + "command": "cmake", + "type": "shell", + "args": [ + "--build", + "${workspaceFolder}/build-local" + ], + "problemMatcher": [ + "$gcc" + ], + "dependsOrder": "sequence", + "dependsOn": [ + "build-configure-local" + ], + "icon": { + "id": "tools", + "color": "terminal.ansiYellow" + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "group": "build-execution" + } + }, + { + "label": "build-debug-arm64", + "detail": "Build a debug version of the application for arm64 using\nthe toolchain from the SDK container.", + "command": "DOCKER_HOST=", + "type": "shell", + "args": [ + "docker", + "run", + "--rm", + "-v", + "${workspaceFolder}:${config:torizon_app_root}", + "cross-toolchain-arm64-__container__", + "cmake", + "--build", + "build-arm64" + ], + "problemMatcher": [ + "$gcc" + ], + "dependsOrder": "sequence", + "dependsOn": [ + "build-configure-arm64" + ], + "icon": { + "id": "tools", + "color": "terminal.ansiYellow" + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "group": "build-execution" + } + }, + { + "label": "deploy-torizon-arm64", + "detail": "", + "hide": true, + "command": "rsync", + "type": "process", + "args": [ + "-P", + "-av", + "-e", + "ssh -p ${config:torizon_debug_ssh_port} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null", + "${workspaceFolder}/build-arm64/bin/", + "${config:torizon_run_as}@${config:torizon_ip}:${config:torizon_app_root}" + ], + "dependsOn": [ + "validate-settings", + "validate-arch-arm64", + "copy-docker-compose", + "pre-cleanup", + "build-debug-arm64", + "build-container-torizon-debug-arm64", + "push-container-torizon-debug-arm64", + "pull-container-torizon-debug-arm64", + "run-container-torizon-debug-arm64" + ], + "dependsOrder": "sequence", + "problemMatcher": "$msCompile", + "icon": { + "id": "debug-alt", + "color": "terminal.ansiYellow" + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "group": "build-execution" + } + }, + { + "label": "build-debug-arm", + "detail": "Build a debug version of the application for armhf using\nthe toolchain from the SDK container.", + "command": "DOCKER_HOST=", + "type": "shell", + "args": [ + "docker", + "run", + "--rm", + "-v", + "${workspaceFolder}:${config:torizon_app_root}", + "cross-toolchain-arm-__container__", + "cmake", + "--build", + "build-arm" + ], + "problemMatcher": [ + "$gcc" + ], + "dependsOrder": "sequence", + "dependsOn": [ + "build-configure-arm" + ], + "icon": { + "id": "tools", + "color": "terminal.ansiYellow" + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "group": "build-execution" + } + }, + { + "label": "deploy-torizon-arm", + "detail": "", + "hide": true, + "command": "rsync", + "type": "process", + "args": [ + "-P", + "-av", + "-e", + "ssh -p ${config:torizon_debug_ssh_port} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null", + "${workspaceFolder}/build-arm/bin/", + "${config:torizon_run_as}@${config:torizon_ip}:${config:torizon_app_root}" + ], + "dependsOn": [ + "validate-settings", + "validate-arch-arm", + "copy-docker-compose", + "pre-cleanup", + "build-debug-arm", + "build-container-torizon-debug-arm", + "push-container-torizon-debug-arm", + "pull-container-torizon-debug-arm", + "run-container-torizon-debug-arm" + ], + "dependsOrder": "sequence", + "problemMatcher": "$msCompile", + "icon": { + "id": "debug-alt", + "color": "terminal.ansiYellow" + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "group": "build-execution" + } + }, + { + "label": "clean-local", + "detail": "Clean the local application build directory.", + "command": "cmake", + "type": "shell", + "args": [ + "--build", + "build-local", + "--target", + "clean" + ], + "problemMatcher": [ + "$gcc" + ], + "icon": { + "id": "trash", + "color": "terminal.ansiYellow" + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "group": "build-execution" + } + }, + { + "label": "clean-arm", + "detail": "Clean the build folder for armhf using the\ncontainer SDK toolchain.", + "command": "DOCKER_HOST=", + "type": "shell", + "args": [ + "docker", + "run", + "--rm", + "-v", + "${workspaceFolder}:${config:torizon_app_root}", + "cross-toolchain-arm-__container__", + "cmake", + "--build", + "build-arm", + "--target", + "clean" + ], + "problemMatcher": [ + "$gcc" + ], + "dependsOrder": "sequence", + "dependsOn": [ + "build-container-image-sdk-arm" + ], + "icon": { + "id": "trash", + "color": "terminal.ansiYellow" + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "group": "build-execution" + } + }, + { + "label": "clean-arm64", + "detail": "Clean the build folder for arm64 using the\ncontainer SDK toolchain.", + "command": "DOCKER_HOST=", + "type": "shell", + "args": [ + "docker", + "run", + "--rm", + "-v", + "${workspaceFolder}:${config:torizon_app_root}", + "cross-toolchain-arm64-__container__", + "cmake", + "--build", + "build-arm64", + "--target", + "clean" + ], + "problemMatcher": [ + "$gcc" + ], + "dependsOrder": "sequence", + "dependsOn": [ + "build-container-image-sdk-arm64" + ], + "icon": { + "id": "trash", + "color": "terminal.ansiYellow" + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "group": "build-execution" + } + }, + { + "label": "build-configure-amd64", + "hide": true, + "command": "DOCKER_HOST=", + "type": "shell", + "args": [ + "docker", + "run", + "--rm", + "-v", + "${workspaceFolder}:${config:torizon_app_root}", + "cross-toolchain-amd64-__container__", + "cmake", + "-DCMAKE_BUILD_TYPE=Debug", + "-DCMAKE_CXX_COMPILER=x86_64-linux-gnu-g++", + "-DCMAKE_C_COMPILER=x86_64-linux-gnu-gcc", + "-Bbuild-amd64" + ], + "problemMatcher": [ + "$gcc" + ], + "dependsOrder": "sequence", + "dependsOn": [ + "build-container-image-sdk-amd64" + ], + "icon": { + "id": "tools", + "color": "terminal.ansiYellow" + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "group": "build-execution" + } + }, + { + "label": "build-debug-amd64", + "detail": "Build a debug version of the application for amd64 using\nthe toolchain from the SDK container.", + "command": "DOCKER_HOST=", + "type": "shell", + "args": [ + "docker", + "run", + "--rm", + "-v", + "${workspaceFolder}:${config:torizon_app_root}", + "cross-toolchain-amd64-__container__", + "cmake", + "--build", + "build-amd64" + ], + "problemMatcher": [ + "$gcc" + ], + "dependsOrder": "sequence", + "dependsOn": [ + "build-configure-amd64" + ], + "icon": { + "id": "tools", + "color": "terminal.ansiYellow" + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "group": "build-execution" + } + }, + { + "label": "deploy-torizon-amd64", + "detail": "", + "hide": true, + "command": "rsync", + "type": "process", + "args": [ + "-P", + "-av", + "-e", + "ssh -p ${config:torizon_debug_ssh_port} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null", + "${workspaceFolder}/build-amd64/bin/", + "${config:torizon_run_as}@${config:torizon_ip}:${config:torizon_app_root}" + ], + "dependsOn": [ + "validate-settings", + "validate-arch-amd64", + "copy-docker-compose", + "pre-cleanup", + "build-debug-amd64", + "build-container-torizon-debug-amd64", + "push-container-torizon-debug-amd64", + "pull-container-torizon-debug-amd64", + "run-container-torizon-debug-amd64" + ], + "dependsOrder": "sequence", + "problemMatcher": "$msCompile", + "icon": { + "id": "debug-alt", + "color": "terminal.ansiYellow" + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "group": "build-execution" + } + }, + { + "label": "clean-amd64", + "detail": "Clean the build folder for amd64 using the\ncontainer SDK toolchain.", + "command": "DOCKER_HOST=", + "type": "shell", + "args": [ + "docker", + "run", + "--rm", + "-v", + "${workspaceFolder}:${config:torizon_app_root}", + "cross-toolchain-amd64-__container__", + "cmake", + "--build", + "build-amd64", + "--target", + "clean" + ], + "problemMatcher": [ + "$gcc" + ], + "dependsOrder": "sequence", + "dependsOn": [ + "build-container-image-sdk-arm64" + ], + "icon": { + "id": "trash", + "color": "terminal.ansiYellow" + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "shared", + "group": "build-execution" + } + }, + ], +"inputs": [] +} diff --git a/cmakeGTK3/CMakeLists.txt b/cmakeGTK3/CMakeLists.txt new file mode 100644 index 000000000..36a2d0156 --- /dev/null +++ b/cmakeGTK3/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.0.0) + +project(__change__ VERSION 1.0 LANGUAGES CXX C) + +# Use the package PkgConfig to detect GTK+ headers/library files +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK3 REQUIRED gtk+-3.0) + +# Setup CMake to use GTK+, tell the compiler where to look for headers +# and to the linker where to look for libraries +include_directories(${GTK3_INCLUDE_DIRS}) +link_directories(${GTK3_LIBRARY_DIRS}) + +# Add other flags to the compiler +add_definitions(${GTK3_CFLAGS_OTHER}) + +add_executable(__change__ src/main.cpp) +target_link_libraries(__change__ ${GTK3_LIBRARIES}) + +set(CMAKE_SYSTEM_NAME Linux) + +set_target_properties(__change__ PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "bin" + ARCHIVE_OUTPUT_DIRECTORY "lib" + LIBRARY_OUTPUT_DIRECTORY "lib" +) diff --git a/cmakeGTK3/Dockerfile b/cmakeGTK3/Dockerfile new file mode 100644 index 000000000..bf6c03805 --- /dev/null +++ b/cmakeGTK3/Dockerfile @@ -0,0 +1,91 @@ +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 --platform=linux/${IMAGE_ARCH} torizon/wayland-gtk3${GPU}:${BASE_VERSION} AS build + +ARG APP_ROOT +ARG GPU +ARG IMAGE_ARCH + +# __deps__ +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 -q -y install \ + build-essential \ + cmake \ + libgtk-3-dev \ +# DO NOT REMOVE THIS LABEL: this is used for VS Code automation + # __torizon_packages_build_start__ + # __torizon_packages_build_end__ +# DO NOT REMOVE THIS LABEL: this is used for VS Code automation + && \ + apt-get clean && apt-get autoremove && \ + rm -rf /var/lib/apt/lists/* +# __deps__ + +COPY . ${APP_ROOT} +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} && \ + cmake -DCMAKE_BUILD_TYPE=Release -Bbuild-${IMAGE_ARCH} && \ + cmake --build build-${IMAGE_ARCH} + +# BUILD ------------------------------------------------------------------------ + + +## +# Deploy Step +## +FROM --platform=linux/${IMAGE_ARCH} torizon/wayland-gtk3${GPU}:${BASE_VERSION} AS deploy + +ARG IMAGE_ARCH +ARG GPU +ARG APP_ROOT + +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__ +# DO NOT REMOVE THIS LABEL: this is used for VS Code automation + && apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/* + +USER torizon + +# Copy the application compiled in the build step to the $APP_ROOT directory +# path inside the container, where $APP_ROOT is the torizon_app_root +# configuration defined in settings.json +COPY --from=build ${APP_ROOT}/build-${IMAGE_ARCH}/bin ${APP_ROOT} + +# "cd" (enter) into the APP_ROOT directory +WORKDIR ${APP_ROOT} + +# Command executed in runtime when the container starts +CMD ["./__change__"] + +# DEPLOY ----------------------------------------------------------------------- diff --git a/cmakeGTK3/Dockerfile.debug b/cmakeGTK3/Dockerfile.debug new file mode 100644 index 000000000..63e4f221d --- /dev/null +++ b/cmakeGTK3/Dockerfile.debug @@ -0,0 +1,100 @@ +# ARGUMENTS -------------------------------------------------------------------- +## +# Board architecture +## +ARG IMAGE_ARCH= + + + +## +# Base container version +## +ARG BASE_VERSION=4 + +## +# Debug port +## +ARG DEBUG_SSH_PORT= + +## +# Run as +## +ARG SSHUSERNAME= + +## +# Board GPU vendor prefix +## +ARG GPU= + +## +# Application root directory inside the container +## +ARG APP_ROOT= + +# BUILD ------------------------------------------------------------------------ +## +# Deploy Step +## +FROM --platform=linux/${IMAGE_ARCH} \ + 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 +EXPOSE ${DEBUG_SSH_PORT} + +# Make sure we don't get notifications we can't answer during building. +ENV DEBIAN_FRONTEND="noninteractive" + +# your regular RUN statements here +# Install required packages +RUN apt-get -q -y update && \ + apt-get -q -y install \ + openssl \ + openssh-server \ + rsync \ + file \ + curl \ + gdb && \ + apt-get clean && apt-get autoremove && \ + rm -rf /var/lib/apt/lists/* + +# automate for torizonPackages.json +RUN apt-get -q -y update && \ + apt-get -q -y install \ + libgtk-3-0 \ +# DO NOT REMOVE THIS LABEL: this is used for VS Code automation + # __torizon_packages_dev_start__ + # __torizon_packages_dev_end__ +# DO NOT REMOVE THIS LABEL: this is used for VS Code automation + && \ + apt-get clean && apt-get autoremove && \ + rm -rf /var/lib/apt/lists/* + +# ⚠️ DEBUG PURPOSES ONLY!! +# THIS CONFIGURES AN INSECURE SSH CONNECTION + +# create folders needed for the different components +# configures SSH access to the container and sets environment by default +RUN mkdir /var/run/sshd && \ + sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' \ + -i /etc/pam.d/sshd && \ + if test $SSHUSERNAME != root ; \ + then mkdir -p /home/$SSHUSERNAME/.ssh ; \ + else mkdir -p /root/.ssh ; fi && \ + echo "PermitUserEnvironment yes" >> /etc/ssh/sshd_config && \ + echo "PermitRootLogin yes" >> /etc/ssh/sshd_config && \ + echo "Port ${DEBUG_SSH_PORT}" >> /etc/ssh/sshd_config && \ + echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config && \ + echo "PermitEmptyPasswords yes" >> /etc/ssh/sshd_config && \ + su -c "env" $SSHUSERNAME > /etc/environment && \ + echo "$SSHUSERNAME:" | chpasswd -e + +RUN rm -r /etc/ssh/ssh*key && \ + dpkg-reconfigure openssh-server + +CMD [ "/usr/sbin/sshd", "-D" ] diff --git a/cmakeGTK3/Dockerfile.sdk b/cmakeGTK3/Dockerfile.sdk new file mode 100644 index 000000000..153cc738c --- /dev/null +++ b/cmakeGTK3/Dockerfile.sdk @@ -0,0 +1,52 @@ +# ARGUMENTS -------------------------------------------------------------------- + ARG BASE_VERSION=4 + + ## + # Board architecture + ## + ARG IMAGE_ARCH= + + ## + # Board GPU vendor prefix + ## + ARG GPU= + +## +# Application root directory inside the container +## +ARG APP_ROOT= + + +# BUILD ------------------------------------------------------------------------ +FROM --platform=linux/${IMAGE_ARCH} torizon/wayland-gtk3${GPU}:${BASE_VERSION} + +ARG APP_ROOT +ARG GPU +ARG IMAGE_ARCH + +# __deps__ +RUN apt-get -q -y update && \ + apt-get -q -y install \ + build-essential \ + cmake \ + libgtk-3-dev \ + # ADD YOUR PACKAGES HERE + && \ + apt-get clean && apt-get autoremove && \ + rm -rf /var/lib/apt/lists/* +# __deps__ + +# automate for torizonPackages.json +RUN apt-get -q -y update && \ + apt-get -q -y install \ +# DO NOT REMOVE THIS LABEL: this is used for VS Code automation + # __torizon_packages_build_start__ + # __torizon_packages_build_end__ +# DO NOT REMOVE THIS LABEL: this is used for VS Code automation + && \ + apt-get clean && apt-get autoremove && \ + rm -rf /var/lib/apt/lists/* + +USER torizon +WORKDIR ${APP_ROOT} + diff --git a/cmakeGTK3/docker-compose.yml b/cmakeGTK3/docker-compose.yml new file mode 100644 index 000000000..4f0aa10a0 --- /dev/null +++ b/cmakeGTK3/docker-compose.yml @@ -0,0 +1,89 @@ +version: "3.9" +services: + __container__-debug: + build: + context: . + dockerfile: Dockerfile.debug + image: ${LOCAL_REGISTRY}:5002/__container__-debug:${TAG} + ports: + # SSH debug + - ${DEBUG_SSH_PORT}:${DEBUG_SSH_PORT} + # gdbserver + - ${DEBUG_PORT1}:${DEBUG_PORT1} + volumes: + - type: bind + source: /tmp + target: /tmp + - type: bind + source: /dev + target: /dev + device_cgroup_rules: + # ... for tty + - "c 4:* rmw" + # to allow the use of DMA heap + - "c 253:* rmw" + # ... for /dev/input devices + - "c 13:* rmw" + - "c 199:* rmw" + # ... for /dev/dri devices + - "c 226:* rmw" + depends_on: [ + weston + ] + + __container__: + build: + context: . + dockerfile: Dockerfile + image: ${DOCKER_LOGIN}/__container__:${TAG} + volumes: + - type: bind + source: /tmp + target: /tmp + - type: bind + source: /dev + target: /dev + device_cgroup_rules: + # ... for tty + - "c 4:* rmw" + # to allow the use of DMA heap + - "c 253:* rmw" + # ... for /dev/input devices + - "c 13:* rmw" + - "c 199:* rmw" + # ... for /dev/dri devices + - "c 226:* rmw" + depends_on: [ + weston + ] + + weston: + image: torizon/weston${GPU}:4 + environment: + - ACCEPT_FSL_EULA=1 + # Required to get udev events from host udevd via netlink + network_mode: host + volumes: + - type: bind + source: /tmp + target: /tmp + - type: bind + source: /dev + target: /dev + - type: bind + source: /run/udev + target: /run/udev + cap_add: + - CAP_SYS_TTY_CONFIG + # Add device access rights through cgroup... + device_cgroup_rules: + # ... for tty + - "c 4:* rmw" + # to allow the use of DMA heap + - "c 253:* rmw" + # ... for /dev/input devices + - "c 13:* rmw" + - "c 199:* rmw" + - "c 10:223 rmw" + # ... for /dev/dri devices + - "c 226:* rmw" diff --git a/cmakeGTK3/includes/.ok b/cmakeGTK3/includes/.ok new file mode 100644 index 000000000..e69de29bb diff --git a/cmakeGTK3/src/main.cpp b/cmakeGTK3/src/main.cpp new file mode 100644 index 000000000..f76259e6b --- /dev/null +++ b/cmakeGTK3/src/main.cpp @@ -0,0 +1,48 @@ +// Example based on https://www.gtk.org/docs/getting-started/hello-world +// Adapted to GTK 3 + +#include +#include + +static void +print_hello(GtkWidget *widget, + gpointer data) +{ + g_print("Hello Torizon World\n"); +} + +static void +activate(GtkApplication *app, + gpointer user_data) +{ + GtkWidget *window; + GtkWidget *button; + + window = gtk_application_window_new(app); + gtk_window_set_title(GTK_WINDOW(window), "Hello Torizon"); + gtk_window_set_default_size(GTK_WINDOW(window), 640, 480); + gtk_window_fullscreen(GTK_WINDOW(window)); + + button = gtk_button_new_with_label("Hello Torizon"); + g_signal_connect(button, "clicked", G_CALLBACK(print_hello), NULL); + gtk_container_add(GTK_CONTAINER(window), button); + + gtk_widget_show_all(window); +} + +int main(int argc, + char **argv) +{ + GtkApplication *app; + int status; + + app = gtk_application_new("org.gtk.example", G_APPLICATION_FLAGS_NONE); + g_signal_connect(app, "activate", G_CALLBACK(activate), NULL); + + std::cout << "Hello Torizon!" << std::endl; + + status = g_application_run(G_APPLICATION(app), argc, argv); + g_object_unref(app); + + return status; +} diff --git a/templates.json b/templates.json index 0d6a96ab7..179021234 100644 --- a/templates.json +++ b/templates.json @@ -416,6 +416,28 @@ "successDebugMessage": "Hello Torizon!" } }, + { + "img": "gtk3.png", + "folder": "cmakeGTK3", + "description": "C++ CMake GTK 3 Application", + "runtime": "GTK 3", + "language": "C++", + "debugSSHPort": "2230", + "multiContainer": true, + "support": "Community", + "deprecated": false, + "tests" : { + "debuggers": { + "local": ["Local AMD64"], + "arm": ["Torizon ARMv7"], + "arm64": ["Torizon ARMv8"] + }, + "debuggerConsole": "cppdbg", + "mainFile": "src/main.cpp", + "mainFileBreakpointLine": 42, + "successDebugMessage": "Hello Torizon!" + } + }, { "img": "tcb.png", "folder": "tcb",