From 5d189fe5a3cbbdaf506487ed7516df8cc466e2f8 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Sun, 12 Jan 2025 17:48:59 +0100 Subject: [PATCH] Add macOS simulator build to pipelines (#162) - GitHub actions changed to build simulator on macOS (it's broken, but at least we get a good code portability check for now!) - `Buildscripts/` shell scripts updated to use `/bin/sh` so it works on macOS too - Various includes fixed in various subprojects so the code is more portable --- .github/actions/build-simulator/action.yml | 6 +++++- .github/workflows/build-simulator.yml | 14 +++++++++++++- Boards/Simulator/Source/hal/SimulatorPower.h | 10 +++++----- Buildscripts/Flashing/flash.sh | 2 +- Buildscripts/build-and-release-all.sh | 2 +- Buildscripts/build.sh | 2 +- Buildscripts/release-sdk-current.sh | 2 +- Buildscripts/release-sdk.sh | 2 +- Buildscripts/release-simulator.sh | 2 +- Buildscripts/release.sh | 2 +- Buildscripts/runtests.sh | 2 +- CMakeLists.txt | 1 - Tactility/Source/app/files/FileUtils.cpp | 1 - Tactility/Source/app/files/View.cpp | 4 ++-- Tactility/Source/app/i2cscanner/I2cHelpers.cpp | 1 + Tactility/Source/lvgl/Init.cpp | 2 +- .../Source/lvgl/{Lvgl.cpp => LvglDisplay.cpp} | 2 +- Tactility/Source/lvgl/{Lvgl.h => LvglDisplay.h} | 0 TactilityCore/Source/Log.cpp | 1 + TactilityCore/Source/StringUtils.h | 2 +- 20 files changed, 38 insertions(+), 22 deletions(-) rename Tactility/Source/lvgl/{Lvgl.cpp => LvglDisplay.cpp} (91%) rename Tactility/Source/lvgl/{Lvgl.h => LvglDisplay.h} (100%) diff --git a/.github/actions/build-simulator/action.yml b/.github/actions/build-simulator/action.yml index fc1a590b..c7187385 100644 --- a/.github/actions/build-simulator/action.yml +++ b/.github/actions/build-simulator/action.yml @@ -7,6 +7,9 @@ inputs: platform_name: description: A descriptive name for the target platform (e.g. amd64, aarch64, etc.) required: true + publish: + description: A boolean that enables publishing of artifacts + required: true runs: using: "composite" @@ -16,7 +19,7 @@ runs: with: submodules: recursive - name: Install Linux Dependencies for SDL - if: ${{ inputs.platform_name }} == 'linux' + if: ${{ runner.os == 'Linux' }} shell: bash # See Libraries/SDL/docs/README-linux.md run: > @@ -45,6 +48,7 @@ runs: run: Buildscripts/release-simulator.sh buildsim release/Simulator-${{ inputs.os_name }}-${{ inputs.platform_name }} - name: 'Upload Artifact' uses: actions/upload-artifact@v4 + if: ${{ inputs.publish == 'true' }} with: name: Simulator-${{ inputs.os_name }}-${{ inputs.platform_name }} path: release/Simulator-${{ inputs.os_name }}-${{ inputs.platform_name }} diff --git a/.github/workflows/build-simulator.yml b/.github/workflows/build-simulator.yml index a8148aea..17304102 100644 --- a/.github/workflows/build-simulator.yml +++ b/.github/workflows/build-simulator.yml @@ -2,7 +2,7 @@ name: Build Simulator on: [push] jobs: - Build-Simulator: + Build-Simulator-Linux: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -11,3 +11,15 @@ jobs: with: os_name: linux platform_name: amd64 + publish: true + Build-Simulator-macOS: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - name: "Build" + uses: ./.github/actions/build-simulator + with: + os_name: macos + platform_name: aarch64 + # macOS simulator currently fails due to main thread requirement for rendering + publish: false diff --git a/Boards/Simulator/Source/hal/SimulatorPower.h b/Boards/Simulator/Source/hal/SimulatorPower.h index 3b4bc735..b12b1252 100644 --- a/Boards/Simulator/Source/hal/SimulatorPower.h +++ b/Boards/Simulator/Source/hal/SimulatorPower.h @@ -11,15 +11,15 @@ class SimulatorPower : public Power { public: - SimulatorPower() {} - ~SimulatorPower() {} + SimulatorPower() = default; + ~SimulatorPower() override = default; bool supportsMetric(MetricType type) const override; bool getMetric(Power::MetricType type, Power::MetricData& data) override; - bool supportsChargeControl() const { return true; } - bool isAllowedToCharge() const { return allowedToCharge; } - void setAllowedToCharge(bool canCharge) { allowedToCharge = canCharge; } + bool supportsChargeControl() const override { return true; } + bool isAllowedToCharge() const override { return allowedToCharge; } + void setAllowedToCharge(bool canCharge) override { allowedToCharge = canCharge; } }; std::shared_ptr simulatorPower(); diff --git a/Buildscripts/Flashing/flash.sh b/Buildscripts/Flashing/flash.sh index a9c26265..084a558f 100755 --- a/Buildscripts/Flashing/flash.sh +++ b/Buildscripts/Flashing/flash.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Usage: # flash.sh [port] diff --git a/Buildscripts/build-and-release-all.sh b/Buildscripts/build-and-release-all.sh index a7f257a8..f9b7615b 100755 --- a/Buildscripts/build-and-release-all.sh +++ b/Buildscripts/build-and-release-all.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh function build() { Buildscripts/build.sh $1 diff --git a/Buildscripts/build.sh b/Buildscripts/build.sh index 65f476c7..9f7b4af3 100755 --- a/Buildscripts/build.sh +++ b/Buildscripts/build.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # Usage: build.sh [boardname] diff --git a/Buildscripts/release-sdk-current.sh b/Buildscripts/release-sdk-current.sh index 761a8d85..7da78489 100755 --- a/Buildscripts/release-sdk-current.sh +++ b/Buildscripts/release-sdk-current.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # Description: Releases the current build files as an SDK in release/TactilitySDK diff --git a/Buildscripts/release-sdk.sh b/Buildscripts/release-sdk.sh index 4e6adc91..4dfc16e3 100755 --- a/Buildscripts/release-sdk.sh +++ b/Buildscripts/release-sdk.sh @@ -1,4 +1,4 @@ -#!/usr/bin/bash +#!/bin/sh # # Usage: release-sdk.sh [target_path] diff --git a/Buildscripts/release-simulator.sh b/Buildscripts/release-simulator.sh index b5f39e2c..0506bfcc 100755 --- a/Buildscripts/release-simulator.sh +++ b/Buildscripts/release-simulator.sh @@ -1,4 +1,4 @@ -#!/usr/bin/bash +#!/bin/sh # # Usage: release-simulator.sh [builddir] [target_path] diff --git a/Buildscripts/release.sh b/Buildscripts/release.sh index b9fd1783..85153d06 100755 --- a/Buildscripts/release.sh +++ b/Buildscripts/release.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # Usage: release.sh [boardname] diff --git a/Buildscripts/runtests.sh b/Buildscripts/runtests.sh index 8c544c58..fe1c03b4 100755 --- a/Buildscripts/runtests.sh +++ b/Buildscripts/runtests.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh cmake -S ./ -B build-sim cmake --build build-sim --target build-tests -j 14 diff --git a/CMakeLists.txt b/CMakeLists.txt index 53866833..41f88721 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,7 +70,6 @@ if (NOT DEFINED ENV{ESP_IDF_VERSION}) endif() if (NOT DEFINED ENV{ESP_IDF_VERSION}) - # FreeRTOS set(FREERTOS_CONFIG_FILE_DIRECTORY ${PROJECT_SOURCE_DIR}/Boards/Simulator/Source CACHE STRING "") set(FREERTOS_PORT GCC_POSIX CACHE STRING "") diff --git a/Tactility/Source/app/files/FileUtils.cpp b/Tactility/Source/app/files/FileUtils.cpp index c68f1c5e..28f1645e 100644 --- a/Tactility/Source/app/files/FileUtils.cpp +++ b/Tactility/Source/app/files/FileUtils.cpp @@ -1,7 +1,6 @@ #include "FileUtils.h" #include "TactilityCore.h" #include -#include #include namespace tt::app::files { diff --git a/Tactility/Source/app/files/View.cpp b/Tactility/Source/app/files/View.cpp index 8bbb0296..ec8c59d5 100644 --- a/Tactility/Source/app/files/View.cpp +++ b/Tactility/Source/app/files/View.cpp @@ -1,4 +1,3 @@ -#include #include "app/alertdialog/AlertDialog.h" #include "app/imageviewer/ImageViewer.h" #include "app/inputdialog/InputDialog.h" @@ -11,7 +10,8 @@ #include "Tactility.h" #include "View.h" #include "StringUtils.h" -#include +#include +#include #define TAG "files_app" diff --git a/Tactility/Source/app/i2cscanner/I2cHelpers.cpp b/Tactility/Source/app/i2cscanner/I2cHelpers.cpp index 6f4efb68..bd57f706 100644 --- a/Tactility/Source/app/i2cscanner/I2cHelpers.cpp +++ b/Tactility/Source/app/i2cscanner/I2cHelpers.cpp @@ -3,6 +3,7 @@ #include "StringUtils.h" #include #include +#include namespace tt::app::i2cscanner { diff --git a/Tactility/Source/lvgl/Init.cpp b/Tactility/Source/lvgl/Init.cpp index a52bc167..eac0d536 100644 --- a/Tactility/Source/lvgl/Init.cpp +++ b/Tactility/Source/lvgl/Init.cpp @@ -5,7 +5,7 @@ #include "hal/Touch.h" #include "hal/Keyboard.h" #include "lvgl/LvglKeypad.h" -#include "lvgl/Lvgl.h" +#include "lvgl/LvglDisplay.h" #include "kernel/SystemEvents.h" namespace tt::lvgl { diff --git a/Tactility/Source/lvgl/Lvgl.cpp b/Tactility/Source/lvgl/LvglDisplay.cpp similarity index 91% rename from Tactility/Source/lvgl/Lvgl.cpp rename to Tactility/Source/lvgl/LvglDisplay.cpp index ed7fd746..8605603f 100644 --- a/Tactility/Source/lvgl/Lvgl.cpp +++ b/Tactility/Source/lvgl/LvglDisplay.cpp @@ -1,4 +1,4 @@ -#include "lvgl/Lvgl.h" +#include "lvgl/LvglDisplay.h" #include "Check.h" namespace tt::lvgl { diff --git a/Tactility/Source/lvgl/Lvgl.h b/Tactility/Source/lvgl/LvglDisplay.h similarity index 100% rename from Tactility/Source/lvgl/Lvgl.h rename to Tactility/Source/lvgl/LvglDisplay.h diff --git a/TactilityCore/Source/Log.cpp b/TactilityCore/Source/Log.cpp index 6b8f54bd..05a51e04 100644 --- a/TactilityCore/Source/Log.cpp +++ b/TactilityCore/Source/Log.cpp @@ -1,5 +1,6 @@ #include "Mutex.h" #include +#include namespace tt { diff --git a/TactilityCore/Source/StringUtils.h b/TactilityCore/Source/StringUtils.h index df5b43d7..a11be649 100644 --- a/TactilityCore/Source/StringUtils.h +++ b/TactilityCore/Source/StringUtils.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include