Skip to content

Commit

Permalink
fix: Revert "refactor: Fadec rewrite using Cpp framework (#8547)" (#8621
Browse files Browse the repository at this point in the history
)

* Revert "fix(fadec): flex temp unit conversion (#8617)"

This reverts commit 8f3494b.

* Revert "refactor: Fadec rewrite using Cpp framework (#8547)"

This reverts commit 85d0414.
  • Loading branch information
frankkopp authored Apr 12, 2024
1 parent 8f3494b commit 229258a
Show file tree
Hide file tree
Showing 72 changed files with 6,432 additions and 6,587 deletions.
1 change: 0 additions & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
1. [FWC] Implement non-cancellable master warning for overspeed and gear not down - @tracernz (Mike)
1. [EFB] Checklist restructure to add more capabilities and use json configs - @frankkopp (Frank Kopp)
1. [FLIGHTMODEL] Landing lights or RAT extended now have drag - @Crocket63 (crocket)
1. [FADEC] Fadec rewrite/cleanup/commenting using cpp framework - @frankkopp (Frank Kopp)

## 0.11.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ background_color = 0,0,0

htmlgauge00 = WasmInstrument/WasmInstrument.html?wasm_module=systems.wasm&wasm_gauge=systems,0,0,1,1
htmlgauge01 = WasmInstrument/WasmInstrument.html?wasm_module=fbw.wasm&wasm_gauge=fbw,0,0,1,1
htmlgauge02 = WasmInstrument/WasmInstrument.html?wasm_module=fadec-a32nx.wasm&wasm_gauge=Gauge_Fadec,0,0,1,1
htmlgauge02 = WasmInstrument/WasmInstrument.html?wasm_module=fadec.wasm&wasm_gauge=FadecGauge,0,0,1,1
htmlgauge03 = WasmInstrument/WasmInstrument.html?wasm_module=extra-backend-a32nx.wasm&wasm_gauge=Gauge_Extra_Backend,0,0,1,1

[VCockpit18]
Expand Down
5 changes: 2 additions & 3 deletions fbw-a32nx/src/wasm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ set(OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../out/flybywire-aircraft-a3
add_definitions(-DA32NX)

add_subdirectory(extra-backend-a32nx)
add_subdirectory(fadec_a32nx)

# these are only here to allow CMake compatible IDEs (JetBrains' Clion for example) to show systax
# highlighting and allow code navigation
# FIXME: remove the if-clause as soon as all components are using CMake
if (WIN32)
add_subdirectory(fadec_a320)
add_subdirectory(fbw_a320)
endif ()
26 changes: 26 additions & 0 deletions fbw-a32nx/src/wasm/fadec_a320/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This CMakeLists.txt file is used only for syntax highlighting and navigating
# through the code in an IDE. It is not used for building the project.

cmake_minimum_required(VERSION 3.19)

project(flybywire-a32nx-fadec)

set(CMAKE_CXX_STANDARD 20)
set(MSFS_SDK "C:\\MSFS SDK")

set(CMAKE_CXX_FLAGS "-c -g -DDEBUG -Wno-unused-command-line-argument -Wno-ignored-attributes -Wno-macro-redefined --sysroot \"${MSFS_SDK}/WASM/wasi-sysroot\" -target wasm32-unknown-wasi -flto -D_MSFS_WASM=1 -D__wasi__ -D_LIBCPP_HAS_NO_THREADS -D_WINDLL -D_MBCS -mthread-model single -fno-exceptions -fms-extensions")

include_directories("${MSFS_SDK}/WASM/include")
include_directories("${MSFS_SDK}/WASM/wasi-sysroot/include")
include_directories("${MSFS_SDK}/SimConnect SDK/include")

include_directories(
./src
${FBW_ROOT}/fbw-common/src/wasm/fadec_common/src
${FBW_ROOT}/fbw-common/src/wasm/fbw_common/src
${FBW_ROOT}/fbw-common/src/wasm/fbw_common/src/inih
)

add_executable(flybywire-a32nx-fadec
./src/FadecGauge.cpp
)
9 changes: 9 additions & 0 deletions fbw-a32nx/src/wasm/fadec_a320/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Engine & FADEC - A32NX/ A380X Build Options

By default, the FADEC code will be built for the A32NX aircraft. To build for the A380X, you will have to edit the build.sh file accordingly:

A380X Option:
Line 44: "${DIR}/a380_fadec/src/FadecGauge.cpp"

To go back to the A32NX Option:
Line 44: "${DIR}/a320_fadec/src/FadecGauge.cpp"
75 changes: 75 additions & 0 deletions fbw-a32nx/src/wasm/fadec_a320/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash

# Copyright (c) 2021-2023 FlyByWire Simulations
#
# SPDX-License-Identifier: GPL-3.0

# get directory of this script relative to root
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
COMMON_DIR="${DIR}/../../../../fbw-common/src/wasm"
OUTPUT="${DIR}/../../../out/flybywire-aircraft-a320-neo/SimObjects/AirPlanes/FlyByWire_A320_NEO/panel/fadec.wasm"

if [ "$1" == "--debug" ]; then
WASMLD_ARGS=""
CLANG_ARGS="-g"
else
WASMLD_ARGS="-O2 --lto-O2 --strip-debug"
CLANG_ARGS="-flto -O2 -DNDEBUG"
fi

set -e

# create temporary folder for o files
mkdir -p "${DIR}/obj"
pushd "${DIR}/obj"

# compile c++ code for the A32NX
clang++ \
-c \
${CLANG_ARGS} \
-std=c++20 \
-Wno-unused-command-line-argument \
-Wno-ignored-attributes \
-Wno-macro-redefined \
--sysroot "${MSFS_SDK}/WASM/wasi-sysroot" \
-target wasm32-unknown-wasi \
-D_MSFS_WASM=1 \
-D__wasi__ \
-D_LIBCPP_HAS_NO_THREADS \
-D_WINDLL \
-D_MBCS \
-mthread-model single \
-fno-exceptions \
-fms-extensions \
-fvisibility=hidden \
-I "${MSFS_SDK}/WASM/include" \
-I "${MSFS_SDK}/SimConnect SDK/include" \
-I "${COMMON_DIR}/fadec_common/src" \
-I "${COMMON_DIR}/fbw_common/src/inih" \
-I "${DIR}/common" \
"${DIR}/src/FadecGauge.cpp"

# restore directory
popd

wasm-ld \
--no-entry \
--allow-undefined \
-L "${MSFS_SDK}/WASM/wasi-sysroot/lib/wasm32-wasi" \
-lc "${MSFS_SDK}/WASM/wasi-sysroot/lib/wasm32-wasi/libclang_rt.builtins-wasm32.a" \
--export __wasm_call_ctors \
${WASMLD_ARGS} \
--export-dynamic \
--export malloc \
--export free \
--export __wasm_call_ctors \
--export mallinfo \
--export mchunkit_begin \
--export mchunkit_next \
--export get_pages_state \
--export mark_decommit_pages \
--export-table \
--gc-sections \
-lc++ -lc++abi \
${DIR}/obj/*.o \
-o $OUTPUT
Loading

0 comments on commit 229258a

Please sign in to comment.