Skip to content

Commit

Permalink
impl(core): staging linux
Browse files Browse the repository at this point in the history
  • Loading branch information
shdwmtr committed Jun 14, 2024
1 parent ba41834 commit 9f75b5b
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 38 deletions.
56 changes: 46 additions & 10 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,81 @@ name: Build Millennium (Linux)

on:
workflow_dispatch:

push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:

- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true

- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: python 3.11.8 build libraries
path: D:/a/Millennium/Millennium/build/python

- name: (Generator) Integrate VS2022
uses: microsoft/setup-msbuild@v2
with:
vs-version: '17'
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"

- name: (Generator) Install CMake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.21.1'
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"

- name: (Dependency) Install vcpkg
run: |
# clone vcpkg to
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
# bootstrap and install vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg integrate install
.\vendor\vcpkg\bootstrap-vcpkg.bat
.\vendor\vcpkg\vcpkg integrate install
shell: pwsh
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"

- name: (Generator) Configure CMake
run: |
cmake --preset=actions-linux -DGITHUB_ACTION_BUILD=ON
cmake --preset=linux -G "Unix Makefiles" -DGITHUB_ACTION_BUILD=ON
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"

- name: Build Millennium
run: |
cmake --build build --config Release
mkdir ./build/artifacts
cmake --build build
# Move the python311.dll binary to the release directory
# move D:\a\Millennium\Millennium\Python-3.11.8\PCbuild\win32\python311.dll D:\a\Millennium\Millennium\build\Release\python311.dll
# copy D:\a\Millennium\Millennium\Python-3.11.8\PCbuild\win32\python311.dll D:/a/Millennium/Millennium/build/artifacts/python311.dll
# copy D:\a\Millennium\Millennium\build\Release\user32.dll D:/a/Millennium/Millennium/build/artifacts/user32.dll
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"

- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: millennium
path: D:/a/Millennium/Millennium/build/Release
path: D:/a/Millennium/Millennium/build/artifacts
4 changes: 2 additions & 2 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ jobs:
# set vs variables for cache generation
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
# generate cache for x86/win32 with vs
# - actions-windows-x86 @ CMakeUserPresets.json
# - windows @ CMakeUserPresets.json
# - GITHUB_ACTION_BUILD (boolean) is a macro to help set include paths in CMakeLists.txt
cmake --preset=actions-windows-x86 -G "Visual Studio 17 2022" -A Win32 -DGITHUB_ACTION_BUILD=ON
cmake --preset=windows -G "Visual Studio 17 2022" -A Win32 -DGITHUB_ACTION_BUILD=ON
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"

Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ include_directories(
if(WIN32)
include_directories(${CMAKE_SOURCE_DIR}/vendor/python/include)
elseif(UNIX)
find_package(PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
find_package(Python3 COMPONENTS Development REQUIRED)
include_directories(${PYTHON3_INCLUDE_DIRS})
endif()

set(SOURCE_FILES
Expand Down Expand Up @@ -156,6 +156,6 @@ elseif(UNIX)
Boxer
cpr::cpr
git2
${Python_LIBRARIES}
Python3::Python
)
endif()
28 changes: 14 additions & 14 deletions CMakeUserPresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@
"version": 2,
"configurePresets": [
{
"name": "x86",
"generator": "Ninja",
"name": "default",
"binaryDir": "${sourceDir}/build",
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "./vendor/vcpkg/scripts/buildsystems/vcpkg.cmake",
"VCPKG_TARGET_TRIPLET": "x86-windows-static"
"CMAKE_TOOLCHAIN_FILE": "./vendor/vcpkg/scripts/buildsystems/vcpkg.cmake"
}
},
{
"name": "actions-windows-x86",
"inherits": "x86",
"displayName": "GitHub Actions Windows Build",
"description": "Default build for GitHub Actions",
"name": "windows",
"inherits": "default",
"generator": "Ninja",
"displayName": "Windows Build (x86/Win32)",
"description": "Default build Windows NT",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "D:/a/Millennium/Millennium/vcpkg/scripts/buildsystems/vcpkg.cmake"
"VCPKG_TARGET_TRIPLET": "x86-windows-static"
}
},
{
"name": "actions-linux",
"inherits": "x86",
"displayName": "GitHub Actions Windows Build",
"description": "Default build for GitHub Actions",
"name": "linux",
"inherits": "default",
"generator": "Unix Makefiles",
"displayName": "Linux Build (x86)",
"description": "Default build for Linux",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "D:/a/Millennium/Millennium/vcpkg/scripts/buildsystems/vcpkg.cmake"
"VCPKG_TARGET_TRIPLET": "x64-linux"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/core/co_initialize/co_stub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void StartPluginBackend(PyObject* global_dict)
Py_DECREF(pluginComponentInstance);
}

const void CoInitializer::BackendStartCallback(SettingsStore::PluginTypeSchema& plugin) {
const void CoInitializer::BackendStartCallback(SettingsStore::PluginTypeSchema plugin) {

const std::string backendMainModule = plugin.backendAbsoluteDirectory.generic_string();

Expand Down
2 changes: 1 addition & 1 deletion src/core/co_initialize/co_stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace CoInitializer
{
const void InjectFrontendShims(void);
const void ReInjectFrontendShims(void);
const void BackendStartCallback(SettingsStore::PluginTypeSchema& plugin);
const void BackendStartCallback(SettingsStore::PluginTypeSchema plugin);
}
17 changes: 11 additions & 6 deletions src/core/loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ bool Sockets::PostGlobal(nlohmann::json data)

class CEFBrowser
{
std::unique_ptr<WebkitHandler> webKitHandler;
WebkitHandler webKitHandler;

public:

const void onMessage(websocketpp::client<websocketpp::config::asio_client>* c, websocketpp::connection_hdl hdl, websocketpp::config::asio_client::message_type::ptr msg)
{
const auto json = nlohmann::json::parse(msg->get_payload());
webKitHandler->DispatchSocketMessage(json);
webKitHandler.DispatchSocketMessage(json);
}

const void onConnect(websocketpp::client<websocketpp::config::asio_client>* client, websocketpp::connection_hdl handle)
Expand All @@ -62,10 +62,10 @@ class CEFBrowser
browserHandle = handle;

Logger.Log("successfully connected to steam!");
webKitHandler->SetupGlobalHooks();
webKitHandler.SetupGlobalHooks();
}

CEFBrowser() : webKitHandler(&WebkitHandler::get()) { }
CEFBrowser() : webKitHandler(WebkitHandler::get()) { }
};

class SharedJSContext
Expand Down Expand Up @@ -165,7 +165,12 @@ const void PluginLoader::StartBackEnds()
continue;
}

std::function<void(SettingsStore::PluginTypeSchema&)> cb = std::bind(CoInitializer::BackendStartCallback, std::placeholders::_1);
std::thread(std::bind(&PythonManager::CreatePythonInstance, &manager, std::ref(plugin), cb)).detach();
std::function<void(SettingsStore::PluginTypeSchema)> cb = std::bind(CoInitializer::BackendStartCallback, std::placeholders::_1);

std::thread(
[&manager, &plugin, cb]() {
manager.CreatePythonInstance(plugin, cb);
}
).detach();
}
}
6 changes: 5 additions & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"dependencies": [
"libgit2",
"cpr"
"cpr",
{
"name": "python3",
"platform": "linux"
}
]
}

0 comments on commit 9f75b5b

Please sign in to comment.