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

Electron vite #91

Merged
merged 5 commits into from
Jun 4, 2024
Merged
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
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

32 changes: 0 additions & 32 deletions .eslintrc.cjs

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ jobs:
- name: Install dependencies
run: |
npm -g i cmake-js
npm run build-backend
npm run build:backend
npm install

- name: Run eslint
run: npm run lint

- name: Build
run: npm run package
run: npm run build
37 changes: 21 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,29 @@ jobs:
npm install

- name: Package app
if: matrix.os == 'windows-2019'
shell: bash
run: npm run build:win

- name: Package app
if: matrix.os == 'macos-latest'
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: npm run make -- --arch ${{ matrix.arch }}
run: npm run build:mac -- --${{ matrix.arch }}

- name: Package app
if: matrix.os == 'ubuntu-latest'
shell: bash
run: npm run build:linux -- --${{ matrix.arch }}

- name: Rename installer to human friendly name
if: matrix.os == 'macos-latest' && matrix.arch == 'arm64'
run: |
cd out/make
cd dist/
dmg_file=$(find . -name "*.dmg" -type f)
new_dmg_file=$(echo $dmg_file | sed 's/arm64/apple-silicon/')
mv $dmg_file $new_dmg_file
Expand All @@ -147,35 +158,29 @@ jobs:
repository: pierr3/TrackAudio
token: ${{ secrets.GITHUB_TOKEN }}

- name: Make AppImage
if: matrix.os == 'ubuntu-latest'
run: |
chmod +x ./scripts/make_appimage.sh
cp ./scripts/make_appimage.sh ./
./make_appimage.sh ${{ matrix.arch }} ${{ steps.relinfo.outputs.release }}

- name: Upload artifacts
uses: softprops/action-gh-release@v2
if: matrix.os == 'windows-2019'
with:
tag_name: ${{ steps.relinfo.outputs.release }}
files: |
out/make/**/*.exe
out/make/**/*.zip
dist/*.exe
dist/*.zip

- name: Upload artifacts
uses: softprops/action-gh-release@v2
if: matrix.os == 'macos-latest'
with:
tag_name: ${{ steps.relinfo.outputs.release }}
files: "out/make/**/*.dmg"
files: "dist/*.dmg"

- name: Upload artifacts
uses: softprops/action-gh-release@v2
if: matrix.os == 'ubuntu-latest'
with:
tag_name: ${{ steps.relinfo.outputs.release }}
files: |
out/make/**/*.deb
*.AppImage
*.zsync
dist/*.deb
dist/*.AppImage
dist/*.zsync
dist/*.snap
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,8 @@ typings/
out/

backend/build

dist/

backend/prebuilds

build/
# Sentry Config File
.sentryclirc

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "backend/vcpkg"]
path = backend/vcpkg
url = https://github.com/microsoft/vcpkg.git
[submodule "backend/extern/afv-native"]
path = backend/extern/afv-native
url = https://github.com/pierr3/afv-native.git
36 changes: 0 additions & 36 deletions .vscode/launch.json

This file was deleted.

41 changes: 7 additions & 34 deletions backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_definitions(-DCPPHTTPLIB_OPENSSL_SUPPORT=1)
add_definitions(-DNAPI_VERSION=7)
set(AFV_STATIC 1)

include_directories(${CMAKE_SOURCE_DIR}/extern/afv-native/include)
add_subdirectory(extern/afv-native)
include_directories(extern/afv-native/include)

if(MSVC)
add_compile_options(
Expand Down Expand Up @@ -67,25 +69,6 @@ if (UNIX AND NOT APPLE)
endif()
endif()

# Declare the content to be downloaded
FetchContent_Declare(
afv_native
URL https://github.com/pierr3/afv-native/releases/download/v${afv_native_VERSION}/libafv-v${afv_native_VERSION}-${CMAKE_SYSTEM_NAME}-${afv_native_ARCHITECTURE}.zip
)

# Get the download directory
FetchContent_GetProperties(afv-native)
if(NOT afv_native_POPULATED)
FetchContent_Populate(afv_native)
set(afv_native_SOURCE_DIR ${afv_native_SOURCE_DIR})
endif()

message(STATUS "afv_native_SOURCE_DIR: ${afv_native_SOURCE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${afv_native_SOURCE_DIR}")

# Now that the content has been downloaded, we can use find_package
find_package(afv_native REQUIRED)

# Find the required packages
find_package(Threads REQUIRED)
find_package(httplib CONFIG REQUIRED)
Expand All @@ -96,7 +79,7 @@ find_package(Poco COMPONENTS Foundation Util REQUIRED)
find_package(semver CONFIG REQUIRED)
find_package(restinio CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(quill CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_package(platform_folders CONFIG REQUIRED)
find_package(SFML COMPONENTS system window graphics CONFIG REQUIRED)
find_path(SIMPLEINI_INCLUDE_DIRS "SimpleIni.h")
Expand All @@ -121,7 +104,7 @@ target_link_libraries(trackaudio-afv PRIVATE
semver::semver
restinio::restinio
nlohmann_json::nlohmann_json
quill::quill
spdlog::spdlog
sago::platform_folders
sfml-system sfml-graphics sfml-window
${CMAKE_JS_LIB})
Expand All @@ -132,24 +115,14 @@ set_target_properties(trackaudio-afv
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)

if (UNIX)
add_custom_command(TARGET trackaudio-afv POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:afv_native>
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>)
endif()

if (WIN32)
add_custom_command(TARGET trackaudio-afv POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:trackaudio-afv> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>
COMMAND_EXPAND_LISTS
)

file(GLOB DLL_FILES "${afv_native_SOURCE_DIR}/lib/*.dll")
foreach(DLL_FILE ${DLL_FILES})
add_custom_command(TARGET trackaudio-afv POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${DLL_FILE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>
COMMAND_EXPAND_LISTS
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:afv_native> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>
COMMAND_EXPAND_LISTS
)
endforeach()
endif()
1 change: 1 addition & 0 deletions backend/extern/afv-native
Submodule afv-native added at 21379e
10 changes: 4 additions & 6 deletions backend/include/Helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#include "RadioSimulation.h"
#include "Shared.hpp"

#include "spdlog/spdlog.h"
#include <cmath>
#include <mutex>
#include <quill/Quill.h>
#include <sago/platform_folders.h>
#include <string>

Expand Down Expand Up @@ -62,12 +62,11 @@ class NapiHelpers {
return;
}

std::lock_guard<std::mutex> lock(_mutex);
std::lock_guard<std::mutex> lock(_callElectronMutex);

callbackRef->NonBlockingCall(
[eventName, data, data2](Napi::Env env, Napi::Function jsCallback) {
LOG_TRACE_L1(quill::get_logger("trackaudio_logger"),
"Event name: {}, data: {}, data2: {}", eventName, data, data2);
SPDLOG_TRACE("Event name: {}, data: {}, data2: {}", eventName, data, data2);
jsCallback.Call({ Napi::String::New(env, eventName), Napi::String::New(env, data),
Napi::String::New(env, data2) });
});
Expand All @@ -78,6 +77,5 @@ class NapiHelpers {
callElectron("error", message);
}

protected:
inline static std::mutex _mutex;
inline static std::mutex _callElectronMutex;
};
1 change: 0 additions & 1 deletion backend/include/InputHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <SFML/Window/Keyboard.hpp>
#include <atomic>
#include <mutex>
#include <quill/Quill.h>
#include <string>

#include <Shared.hpp>
Expand Down
2 changes: 0 additions & 2 deletions backend/include/RemoteData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include <absl/strings/str_split.h>
#include <cstddef>
#include <mutex>
#include <quill/Quill.h>
#include <quill/detail/LogMacros.h>
#include <string>

#define WIN32_LEAN_AND_MEAN
Expand Down
18 changes: 7 additions & 11 deletions backend/include/Shared.hpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
#pragma once
#include "afv-native/afv_native.h"
#include "afv-native/atcClientWrapper.h"
#include "spdlog/spdlog.h"
#include <SimpleIni.h>
#include <filesystem>
#include <memory>
#include <napi.h>
#include <quill/Logger.h>
#include <quill/Quill.h>
#include <sago/platform_folders.h>
#include <semver.hpp>
#include <string>

#define TRACK_LOG_INFO(fmt, ...) \
LOG_INFO(quill::get_logger("trackaudio_logger"), fmt, ##__VA_ARGS__)
#define TRACK_LOG_WARNING(fmt, ...) \
LOG_WARNING(quill::get_logger("trackaudio_logger"), fmt, ##__VA_ARGS__)
#define TRACK_LOG_ERROR(fmt, ...) \
LOG_ERROR(quill::get_logger("trackaudio_logger"), fmt, ##__VA_ARGS__)
#define TRACK_LOG_CRITICAL(fmt, ...) \
LOG_CRITICAL(quill::get_logger("trackaudio_logger"), fmt, ##__VA_ARGS__)
#define TRACK_LOG_INFO(fmt, ...) spdlog::info(fmt, ##__VA_ARGS__);
#define TRACK_LOG_WARNING(fmt, ...) spdlog::warn(fmt, ##__VA_ARGS__);
#define TRACK_LOG_ERROR(fmt, ...) spdlog::error(fmt, ##__VA_ARGS__);
#define TRACK_LOG_CRITICAL(fmt, ...) spdlog::critical(fmt, ##__VA_ARGS__);

#define TIMER_CALLBACK_INTERVAL_SEC 15
#define SLURPER_BASE_URL "https://slurper.vatsim.net"
Expand Down
1 change: 0 additions & 1 deletion backend/include/sdk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <absl/strings/str_join.h>
#include <mutex>
#include <nlohmann/json_fwd.hpp>
#include <quill/Quill.h>
#include <set>

using sdk::types::WebsocketMessage;
Expand Down
3 changes: 2 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"runtime": "electron"
},
"files": [
"build/Release/**",
"build/Release/trackaudio-afv.node",
"build/Release/*.dll",
"js/bindings.js",
"types/index.d.ts"
],
Expand Down
Loading
Loading