Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Linux and Mac Build / VScode #32

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ jobs:
uses: actions/checkout@v3

- name: Install dependencies
run: sudo apt-get update && sudo apt-get -y install -y make gcc g++ libgl-dev libglu1-mesa-dev libalut-dev libgtk-3-dev pkg-config
run: sudo apt-get update && sudo apt-get -y install -y ninja-build cmake gcc g++ libgl-dev libglu1-mesa-dev libalut-dev libgtk-3-dev pkg-config

- name: Build the project
run: |
cd src
make lin64
mkdir build
cd build
cmake -GNinja -DOUTPUT_DIR="../release/Aircraft/Extra Aircraft/NK_FPVSurfwing/plugins/INAV-X-Plane-HITL/64" ..
ninja

- name: Commit lin.xpl
run: |
Expand All @@ -79,12 +81,14 @@ jobs:
uses: actions/checkout@v3

- name: Install Dependencies
run: brew install make gtk+3 openal-soft
run: brew install ninja cmake gtk+3 openal-soft

- name: Build the project
run: |
cd src
make mac64
mkdir build
cd build
cmake -GNinja -DOUTPUT_DIR="../release/Aircraft/Extra Aircraft/NK_FPVSurfwing/plugins/INAV-X-Plane-HITL/64" ..
ninja

- name: Commit mac.xpl
run: |
Expand All @@ -108,4 +112,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: Aircraft
path: release/**
path: release/**
16 changes: 10 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ jobs:
uses: actions/checkout@v3

- name: Install dependencies
run: sudo apt-get update && sudo apt-get -y install -y make gcc g++ libgl-dev libglu1-mesa-dev libalut-dev libgtk-3-dev pkg-config
run: sudo apt-get update && sudo apt-get -y install -y ninja-build cmake gcc g++ libgl-dev libglu1-mesa-dev libalut-dev libgtk-3-dev pkg-config

- name: Build the project
run: |
cd src
make lin64
mkdir build
cd build
cmake -GNinja -DOUTPUT_DIR="../release/Aircraft/Extra Aircraft/NK_FPVSurfwing/plugins/INAV-X-Plane-HITL/64" ..
ninja

- name: Upload Artifacts
uses: actions/upload-artifact@v4
Expand All @@ -75,12 +77,14 @@ jobs:
uses: actions/checkout@v3

- name: Install Dependencies
run: brew install make gtk+3 openal-soft
run: brew install ninja cmake gtk+3 openal-soft

- name: Build the project
run: |
cd src
make mac64
mkdir build
cd build
cmake -GNinja -DOUTPUT_DIR="../release/Aircraft/Extra Aircraft/NK_FPVSurfwing/plugins/INAV-X-Plane-HITL/64" ..
ninja

- name: Upload Artifacts
uses: actions/upload-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/src/.vs/
/src/Debug/
/src/Build/
/debug/
/build/
33 changes: 33 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceRoot}",
"${workspaceFolder}/src/SDK/CHeaders/**"
],
"browse": {
"limitSymbolsToIncludedHeaders": false,
"path": [
"${workspaceRoot}/**"
]
},
"compilerPath": "/usr/bin/g++",
"intelliSenseMode": "gcc-x64",
"cStandard": "c11",
"cppStandard": "c++17",
"defines": [
"LIN",
"XPLM200",
"XPLM210",
"XPLM210",
"XPLM300",
"XPLM301",
"XPLM302",
"XPLM303"
],
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
23 changes: 23 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"configurations": [
{
"name": "(gdb) Attach to XPlane",
"type": "cppdbg",
"request": "attach",
// For Liunx, if you want to use VScode with Windows or Mac replace "lin.xpl" with "win.xpl" or "mac.xpl"
"program": "${config:xplane.folder}/Aircraft/NK_FPVSurfwing/plugins/INAV-X-Plane-HITL/64/lin.xpl",
"processId": "${command:pickProcess}",
// You may want to change the following two lines when using Windows or Mac
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"preLaunchTask": "Build Debug",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
]
}
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
// Set your X-PLane install folder to delply the plugin directly to X-Plane while debugging
"xplane.folder" : "/home/andi/.steam/steam/steamapps/common/X-Plane 11"
}
66 changes: 66 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"version": "2.0.0",
"tasks": [

{
"label": "CMAKE Build Debug",
"type": "shell",
"command": "mkdir -p debug && cd debug && cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DOUTPUT_DIR=\"${config:xplane.folder}/Aircraft/NK_FPVSurfwing/plugins/INAV-X-Plane-HITL/64\" ..",
"group": "build",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}"
}
},
{
"label": "CMAKE Build Release",
"type": "shell",
"command": "mkdir -p build && cd build && cmake -GNinja -DOUTPUT_DIR=\"${workspaceFolder}/release/Aircraft/Extra Aircraft/NK_FPVSurfwing/plugins/INAV-X-Plane-HITL/64\" ..",
"group": "build",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}"
}
},
{
"label": "Build Debug",
"type": "shell",
"command": "ninja",
"group": "build",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/debug"
}
},
{
"label": "Build Release",
"type": "shell",
"command": "ninja",
"group": "build",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/build"
}
},
{
"label": "Clean Release",
"type": "shell",
"command": "ninja clean",
"group": "build",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/build"
}
},
{
"label": "Clean Debug",
"type": "shell",
"command": "ninja clean",
"group": "build",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/debug"
}
}
]
}
140 changes: 140 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
cmake_minimum_required(VERSION 3.9)
project(plugin VERSION 1.5.0 DESCRIPTION "INAV-X-Plane-HITL-Plugin")

set(OUTPUT_DIR CACHE STRING "Full path to xplanes plugin directory")

set(CMAKE_OSX_DEPLOYMENT_TARGET "10.10" CACHE STRING "Minimum macOS version" FORCE)
set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for mac OS X" FORCE)

if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif ()

set(CMAKE_CXX_STANDARD 17)

set(PLUGIN_SRC_DIR ${CMAKE_SOURCE_DIR}/src)

set(PLUGIN_SOURCES
${PLUGIN_SRC_DIR}/main.cpp
${PLUGIN_SRC_DIR}/graph.cpp
${PLUGIN_SRC_DIR}/lodepng.cpp
${PLUGIN_SRC_DIR}/menu.cpp
${PLUGIN_SRC_DIR}/msp.cpp
${PLUGIN_SRC_DIR}/osd.cpp
${PLUGIN_SRC_DIR}/serialbase.cpp
${PLUGIN_SRC_DIR}/serial.cpp
${PLUGIN_SRC_DIR}/tcpserial.cpp
${PLUGIN_SRC_DIR}/simData.cpp
${PLUGIN_SRC_DIR}/stats.cpp
${PLUGIN_SRC_DIR}/util.cpp
${PLUGIN_SRC_DIR}/sound.cpp
${PLUGIN_SRC_DIR}/map.cpp
${PLUGIN_SRC_DIR}/fontbase.cpp
${PLUGIN_SRC_DIR}/fontanalog.cpp
${PLUGIN_SRC_DIR}/fontwalksnail.cpp
${PLUGIN_SRC_DIR}/fonthdzero.cpp
${PLUGIN_SRC_DIR}/fontwtfos.cpp
${PLUGIN_SRC_DIR}/ipinputwidget.cpp
)

include_directories(
"${PLUGIN_SRC_DIR}/SDK/CHeaders/Widgets"
"${PLUGIN_SRC_DIR}/SDK/CHeaders/Wrappers"
"${PLUGIN_SRC_DIR}/SDK/CHeaders/XPLM"
"${PLUGIN_SRC_DIR}/mINI"
"${PLUGIN_SRC_DIR}/OpenAL/include"
)

if (WIN32)
list(APPEND CMAKE_LIBRARY_PATH "${PLUGIN_SRC_DIR}/SDK/Libraries/Win")
elseif (APPLE)
list(APPEND CMAKE_FRAMEWORK_PATH "${PLUGIN_SRC_DIR}/SDK/Libraries/Mac")
elseif (UNIX)

endif ()

add_definitions(-DXPLM200=1 -DXPLM210=1 -DXPLM300=1 -DXPLM301=1 -DXPLM302=1 -DXPLM303=1)
add_definitions(-DAPL=$<BOOL:${APPLE}> -DIBM=$<BOOL:${WIN32}> -DLIN=$<AND:$<BOOL:${UNIX}>,$<NOT:$<BOOL:${APPLE}>>>)
add_compile_options(-fexceptions)
add_compile_options(-fvisibility=hidden)
add_compile_options(-Wall -Wpedantic -Wextra)
add_compile_options(-Wno-unused)

if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-O3 -fPIC)
endif ()

if (APPLE)
add_compile_options(-Wno-nested-anon-types)
add_compile_options(-Wno-unused-parameter)
add_compile_options(-Wno-deprecated-declarations)
endif()

add_library(plugin SHARED ${PLUGIN_SOURCES})

target_compile_features(plugin PUBLIC cxx_std_17)


if (APPLE)
target_compile_options(plugin PUBLIC -mmacosx-version-min=11.3)
target_link_libraries(plugin -mmacosx-version-min=11.3)
endif ()

set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
find_library(OPENAL_LIBRARY NAMES openal OpenAL OpenAL32)
find_library(GLUT_LIBRARY NAMES glut GLUT glut64)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET "gtk+-3.0")


if (WIN32 OR APPLE)
find_library(XPLM_LIBRARY NAMES XPLM XPLM_64.lib)
find_library(XPWIDGETS_LIBRARY NAMES XPWidgets XPWidgets_64.lib)
target_link_libraries(plugin ${XPLM_LIBRARY} ${XPWIDGETS_LIBRARY})
endif ()


if (UNIX)
find_library(DL_LIBRARY dl)
target_link_libraries(plugin ${DL_LIBRARY} PkgConfig::GTK)
endif ()

if (APPLE)
find_library(IOKIT_LIBRARY IOKit)
find_library(CORE_FOUNDATION_LIBRARY CoreFoundation)
find_library(GLUT_LIBRARY GLUT)
find_library(OpenGL_LIBRARY OpenGL)
find_library(Cocoa_LIBRARY Cocoa)
find_library(OpenAL_Library OpenAL)

target_link_libraries(plugin ${IOKIT_LIBRARY} ${CORE_FOUNDATION_LIBRARY} ${GLUT_LIBRARY})
target_link_libraries(plugin ${OpenGL_LIBRARY} ${Cocoa_LIBRARY} ${OpenAL_Library})
endif ()

if (WIN32)
target_link_libraries(plugin -static-libgcc -static-libstdc++ opengl32)
target_link_libraries(plugin -static)
elseif (APPLE)
target_link_libraries(plugin "-exported_symbols_list ${PLUGIN_SRC_DIR}/exports.sym_mac")
target_link_libraries(plugin "-framework XPLM -framework XPWidgets -ldl")
elseif (UNIX)
target_link_libraries(plugin -Wl,--version-script -Wl,${PLUGIN_SRC_DIR}/exports.txt)
endif ()

set_target_properties(plugin PROPERTIES PREFIX "")
if (WIN32)
set_target_properties(plugin PROPERTIES OUTPUT_NAME "win")
elseif (APPLE)
set_target_properties(plugin PROPERTIES OUTPUT_NAME "mac")
elseif (UNIX)
set_target_properties(plugin PROPERTIES OUTPUT_NAME "lin")
endif ()
set_target_properties(plugin PROPERTIES SUFFIX ".xpl")

if (NOT ${OUTPUT_DIR} STREQUAL "")
add_custom_command(TARGET plugin
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:plugin> ${OUTPUT_DIR}
)
endif()
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM ubuntu:focal

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update && apt-get install -y make gcc g++ libgl-dev libglu1-mesa-dev libalut-dev libgtk-3-dev pkg-config
RUN apt-get update && apt-get install -y ninja-build cmake gcc g++ libgl-dev libglu1-mesa-dev libalut-dev libgtk-3-dev pkg-config

VOLUME /trunk

Expand Down
Loading