diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 35fe6ce..257dd02 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -35,13 +35,13 @@ jobs: run: vstest.console.exe /Platform:x64 x64/Release/test.dll - name: Upload built plugin - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: built-plugin-windows path: Release/plugins/XPanel/64/* - name: Upload test logs - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: test_log path: x64/Release/test_log.txt @@ -50,7 +50,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-22.04, windows-latest] + os: [ubuntu-22.04, windows-latest, macos-latest] name: Build and Test (CMake, ${{ matrix.os }}) runs-on: ${{ matrix.os }} @@ -58,12 +58,17 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Install dependencies + - name: Install dependencies (Linux) if: matrix.os == 'ubuntu-22.04' run: | sudo apt-get update -qq && sudo apt-get install -y build-essential cmake liblua5.4-dev libudev-dev libhidapi-dev echo 'XPANEL_INSTALL_DEPS_FLAG=-DINSTALL_DEPS=ON' >> $GITHUB_ENV + - name: Install dependencies (macOS) + if: matrix.os == 'macos-latest' + run: | + brew install cmake lua hidapi + - name: Build run: | @@ -78,11 +83,18 @@ jobs: - name: Upload built plugin (Linux glibc 2.35) if: matrix.os == 'ubuntu-22.04' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: built-plugin-linux path: ${{ github.workspace }}/install/XPanel/64/* + - name: Upload built plugin (macOS) + if: matrix.os == 'macos-latest' + uses: actions/upload-artifact@v4 + with: + name: built-plugin-macos + path: ${{ github.workspace }}/install/XPanel/64/* + docs: name: Docs runs-on: ubuntu-latest @@ -94,7 +106,7 @@ jobs: working-directory: ./doc run: pandoc -f gfm -t pdf --pdf-engine weasyprint -c style.css -o documentation.pdf documentation.md - name: Upload docs - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: docs path: doc/documentation.pdf diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f368bd5..24fecaa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,6 +25,7 @@ jobs: TAG: v${{ inputs.release-version }} WINDOWS_RELEASE_PLUGIN_ZIP: xpanel_windows_v${{ inputs.release-version }}.zip LINUX_RELEASE_PLUGIN_ZIP: xpanel_linux_v${{ inputs.release-version }}_glibc2.35.zip + MACOS_RELEASE_PLUGIN_ZIP: xpanel_macos_v${{ inputs.release-version }}.zip SAMPLE_CONFIG_ZIP: sample_configs_v${{ inputs.release-version }}.zip steps: @@ -42,6 +43,12 @@ jobs: name: built-plugin-linux path: built-plugin-linux/plugins/XPanel/64/ + - name: Download built plugin (macOS) + uses: actions/download-artifact@v4.1.7 + with: + name: built-plugin-macos + path: built-plugin-macos/plugins/XPanel/64/ + - name: Download docs uses: actions/download-artifact@v4.1.7 with: @@ -57,16 +64,19 @@ jobs: run: | cp sample-config/board-config.ini built-plugin-windows/plugins/XPanel/64/ cp sample-config/board-config.ini built-plugin-linux/plugins/XPanel/64/ + cp sample-config/board-config.ini built-plugin-macos/plugins/XPanel/64/ - name: Copy FIP Fonts BMP run: | cp 3rdparty/FIP-SDK/fonts/fip-fonts.bmp built-plugin-windows/plugins/XPanel/64/ cp 3rdparty/FIP-SDK/fonts/fip-fonts.bmp built-plugin-linux/plugins/XPanel/64/ + cp 3rdparty/FIP-SDK/fonts/fip-fonts.bmp built-plugin-macos/plugins/XPanel/64/ - name: Copy Doc PDF run: | cp doc/documentation.pdf built-plugin-windows/plugins/XPanel/64/ cp doc/documentation.pdf built-plugin-linux/plugins/XPanel/64/ + cp doc/documentation.pdf built-plugin-macos/plugins/XPanel/64/ - name: Create release plugin zip (Windows) run: | @@ -78,6 +88,11 @@ jobs: cd built-plugin-linux zip -r ../${LINUX_RELEASE_PLUGIN_ZIP} . + - name: Create release plugin zip (macOS) + run: | + cd built-plugin-macos + zip -r ../${MACOS_RELEASE_PLUGIN_ZIP} . + - name: Create sample configs zip run: | cd sample-config @@ -92,4 +107,5 @@ jobs: ${TAG} \ ${WINDOWS_RELEASE_PLUGIN_ZIP} \ ${LINUX_RELEASE_PLUGIN_ZIP} \ + ${MACOS_RELEASE_PLUGIN_ZIP} \ ${SAMPLE_CONFIG_ZIP} diff --git a/README.md b/README.md index bc376bb..1bc686d 100644 --- a/README.md +++ b/README.md @@ -100,10 +100,37 @@ $ cmake --install build ## macOS -Dependencies: +### Prerequisites +First, install Homebrew (if not already installed): +```bash +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +``` + +After installation, add Homebrew to your PATH (the installer will show you the exact commands): +```bash +echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc +eval "$(/opt/homebrew/bin/brew shellenv)" ``` -brew install lua -brew install pkg-config + +### Build Instructions + +Check out the latest source file from [github](https://github.com/norberttak/XPanel) + +Install dependencies: +```bash +brew install cmake lua hidapi +``` + +Build using the provided script: +```bash +./build-macos.sh +``` + +Or build manually: +```bash +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/xpanel-install -S . -B build +cmake --build build --config Release +cmake --build build --target install ``` Copy or link the `/tmp/xpanel-install/XPanel` directory into the X-Plane plugin folder. diff --git a/build-macos.sh b/build-macos.sh new file mode 100755 index 0000000..c050b3c --- /dev/null +++ b/build-macos.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# XPanel macOS Build Script +# Builds the XPanel plugin for macOS + +set -e + +echo "Building XPanel for macOS..." + +# Check if we're on macOS +if [[ "$OSTYPE" != "darwin"* ]]; then + echo "Error: This script must be run on macOS" + exit 1 +fi + +# Install dependencies if needed +if ! command -v brew &> /dev/null; then + echo "Homebrew not found. Please install Homebrew first." + exit 1 +fi + +echo "Installing dependencies..." +brew install cmake lua hidapi + +# Create build directory +mkdir -p build +cd build + +# Configure CMake +echo "Configuring CMake..." +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$PWD/../install" .. + +# Build +echo "Building..." +cmake --build . --config Release + +# Install +echo "Installing..." +cmake --build . --target install + +echo "Build completed successfully!" +echo "Plugin installed in: $(cd .. && pwd)/install/XPanel/64/" \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6df96d4..55845cc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -47,10 +47,14 @@ if (UNIX AND NOT APPLE) include(FindPkgConfig) pkg_check_modules(libudev REQUIRED IMPORTED_TARGET libudev) find_library(HIDAPI_LIBRARY NAMES udev) - target_link_libraries(xpanel PkgConfig::libudev) + target_link_libraries(xpanel PRIVATE PkgConfig::libudev) +elseif (APPLE) + find_library(HIDAPI_LIBRARY IOKit) + find_library(COREFOUNDATION_LIBRARY CoreFoundation) + target_link_libraries(xpanel PRIVATE ${HIDAPI_LIBRARY} ${COREFOUNDATION_LIBRARY}) endif() -target_link_libraries(xpanel xpsdk::xpsdk Lua::Lua FIPSDK::FIPSDK) +target_link_libraries(xpanel PRIVATE xpsdk::xpsdk Lua::Lua FIPSDK::FIPSDK) set_target_properties(xpanel PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN TRUE) target_compile_definitions(xpanel PRIVATE PLUGIN_SIGNATURE="${PROJECT_NAME_LOWERCASE}" PLUGIN_VERSION="${PROJECT_VERSION}") diff --git a/src/core/Logger.h b/src/core/Logger.h index df1c5d4..8137b19 100644 --- a/src/core/Logger.h +++ b/src/core/Logger.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "XPLMUtilities.h" enum TLogLevel