From 7a018f84a022a185b6af7c725973e0d780e99537 Mon Sep 17 00:00:00 2001 From: hackermdch <58121864+hackermdch@users.noreply.github.com> Date: Sun, 22 Sep 2024 16:56:14 +0800 Subject: [PATCH] Initial commit --- .gclient | 13 ++++++ .github/workflows/workflow.yml | 81 ++++++++++++++++++++++++++++++++++ 0001-Update.patch | 73 ++++++++++++++++++++++++++++++ 0002-Update.patch | 26 +++++++++++ 4 files changed, 193 insertions(+) create mode 100644 .gclient create mode 100644 .github/workflows/workflow.yml create mode 100644 0001-Update.patch create mode 100644 0002-Update.patch diff --git a/.gclient b/.gclient new file mode 100644 index 0000000..754e5f3 --- /dev/null +++ b/.gclient @@ -0,0 +1,13 @@ +solutions = [ + { + "managed": False, + "name": "src/flutter", + "url": "https://github.com/PrimogemStudio/engine", + "custom_deps": {}, + "deps_file": "DEPS", + "safesync_url": "", + "custom_vars" : { + "download_android_deps" : False + }, + }, +] \ No newline at end of file diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..e2b24c2 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,81 @@ +name: Build +on: workflow_dispatch +jobs: + build: + strategy: + fail-fast: false + matrix: + include: + - os: windows-latest + name: Windows + cmd: | + git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git --depth 1 + $env:Path="$pwd/depot_tools;$env:Path" + $env:DEPOT_TOOLS_WIN_TOOLCHAIN=0 + $env:GYP_MSVS_OVERRIDE_PATH="C:\Program Files\Microsoft Visual Studio\2022\Enterprise" + $env:WINDOWSSDKDIR="C:\Program Files (x86)\Windows Kits\10" + gclient sync --no-history + cd src/flutter/third_party/dart + git apply ../../../../0001-Update.patch --ignore-space-change --ignore-whitespace + cd ../../.. + ./flutter/tools/gn --runtime-mode release --no-enable-unittests --disable-desktop-embeddings --no-prebuilt-dart-sdk --enable-vulkan + ninja -C out/host_release -j8 + cp ./out/host_release/flutter_minecraft.dll ../flutter_minecraft.dll + + - os: ubuntu-latest + name: Linux + cmd: | + git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git --depth 1 + export PATH=$(pwd)/depot_tools:$PATH + gclient sync --no-history + cd src + ./flutter/tools/gn --runtime-mode release --no-enable-unittests --disable-desktop-embeddings --enable-vulkan + ninja -C out/host_release -j8 + cp ./out/host_release/libflutter_minecraft.so ../libflutter_minecraft.so + + - os: macos-14 + name: MacOS + cmd: | + git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git --depth 1 + export PATH=$(pwd)/depot_tools:$PATH + gclient sync --no-history + cd src + cd flutter + git apply ../../0002-Update.patch + cd .. + ./flutter/tools/gn --runtime-mode release --no-enable-unittests --disable-desktop-embeddings --enable-vulkan + ninja -C out/host_release -j8 + cp ./out/host_release/libflutter_minecraft.dylib ../libflutter_minecraft.dylib + + name: Build ${{ matrix.name }} + runs-on: ${{ matrix.os }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Build + run: | + ${{ matrix.cmd }} + + - name: Upload Artifacts (Linux) + uses: actions/upload-artifact@v3 + if: matrix.os == 'ubuntu-latest' + with: + name: libs + path: ./libflutter_minecraft.so + + - name: Upload Artifacts (Windows) + uses: actions/upload-artifact@v3 + if: matrix.os == 'windows-latest' + with: + name: libs + path: ./flutter_minecraft.dll + + - name: Upload Artifacts (MacOS) + uses: actions/upload-artifact@v3 + if: matrix.os == 'macos-14' + with: + name: libs + path: ./libflutter_minecraft.dylib diff --git a/0001-Update.patch b/0001-Update.patch new file mode 100644 index 0000000..c117bcc --- /dev/null +++ b/0001-Update.patch @@ -0,0 +1,73 @@ +From e87bd2a1914f9ffb0bfa10c62fd63bf4dbed45d5 Mon Sep 17 00:00:00 2001 +From: hackermdch <58121864+hackermdch@users.noreply.github.com> +Date: Wed, 18 Sep 2024 01:19:40 +0800 +Subject: [PATCH] Update + +--- + runtime/vm/native_symbol_win.cc | 15 ++++++++------- + 1 file changed, 8 insertions(+), 7 deletions(-) + +diff --git a/runtime/vm/native_symbol_win.cc b/runtime/vm/native_symbol_win.cc +index 4541937f449..1159132d842 100644 +--- a/runtime/vm/native_symbol_win.cc ++++ b/runtime/vm/native_symbol_win.cc +@@ -16,6 +16,7 @@ namespace dart { + + static bool running_ = false; + static Mutex* lock_ = nullptr; ++static HANDLE handle_ = nullptr; + + void NativeSymbolResolver::Init() { + ASSERT(running_ == false); +@@ -28,13 +29,14 @@ void NativeSymbolResolver::Init() { + // when compiled in UWP. + #ifndef DART_TARGET_OS_WINDOWS_UWP + SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS); +- HANDLE hProcess = GetCurrentProcess(); +- if (!SymInitialize(hProcess, nullptr, TRUE)) { ++ DuplicateHandle(GetCurrentProcess(), GetCurrentProcess(), GetCurrentProcess(), ++ &handle_, 0, false, DUPLICATE_SAME_ACCESS); ++ ++ if (!SymInitialize(handle_, nullptr, TRUE)) { + DWORD error = GetLastError(); + OS::PrintErr("Failed to init NativeSymbolResolver (SymInitialize %" Pu32 + ")\n", + error); +- return; + } + #endif + } +@@ -46,13 +48,13 @@ void NativeSymbolResolver::Cleanup() { + } + running_ = false; + #ifndef DART_TARGET_OS_WINDOWS_UWP +- HANDLE hProcess = GetCurrentProcess(); +- if (!SymCleanup(hProcess)) { ++ if (!SymCleanup(handle_)) { + DWORD error = GetLastError(); + OS::PrintErr("Failed to shutdown NativeSymbolResolver (SymCleanup %" Pu32 + ")\n", + error); + } ++ CloseHandle(handle_); + #endif + } + +@@ -72,13 +74,12 @@ const char* NativeSymbolResolver::LookupSymbolName(uword pc, uword* start) { + *start = 0; + } + memset(&buffer[0], 0, sizeof(buffer)); +- HANDLE hProcess = GetCurrentProcess(); + DWORD64 address = static_cast(pc); + PSYMBOL_INFO pSymbol = reinterpret_cast(&buffer[0]); + pSymbol->SizeOfStruct = kSymbolInfoSize; + pSymbol->MaxNameLen = kMaxNameLength; + DWORD64 displacement; +- BOOL r = SymFromAddr(hProcess, address, &displacement, pSymbol); ++ BOOL r = SymFromAddr(handle_, address, &displacement, pSymbol); + if (r == FALSE) { + return nullptr; + } +-- +2.41.0.windows.1 + diff --git a/0002-Update.patch b/0002-Update.patch new file mode 100644 index 0000000..7608812 --- /dev/null +++ b/0002-Update.patch @@ -0,0 +1,26 @@ +From 2914ed92e81a19f17f6db3d67697acfaf51185d6 Mon Sep 17 00:00:00 2001 +From: hackermdch <58121864+hackermdch@users.noreply.github.com> +Date: Sun, 22 Sep 2024 10:03:07 +0800 +Subject: [PATCH] Update + +--- + shell/platform/minecraft/text_input_plugin.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/shell/platform/minecraft/text_input_plugin.cc b/shell/platform/minecraft/text_input_plugin.cc +index 4a8af55d1c..e0d1f692ea 100644 +--- a/shell/platform/minecraft/text_input_plugin.cc ++++ b/shell/platform/minecraft/text_input_plugin.cc +@@ -202,8 +202,8 @@ void TextInputPlugin::SendStateUpdate(const TextInputModel& model) { + editing_state.AddMember(kComposingExtentKey, -1, allocator); + editing_state.AddMember(kSelectionAffinityKey, kAffinityDownstream, + allocator); +- editing_state.AddMember(kSelectionBaseKey, selection.base(), allocator); +- editing_state.AddMember(kSelectionExtentKey, selection.extent(), allocator); ++ editing_state.AddMember(kSelectionBaseKey, (uint64_t)selection.base(), allocator); ++ editing_state.AddMember(kSelectionExtentKey, (uint64_t)selection.extent(), allocator); + editing_state.AddMember(kSelectionIsDirectionalKey, false, allocator); + editing_state.AddMember( + kTextKey, rapidjson::Value(model.GetText(), allocator).Move(), allocator); +-- +2.41.0.windows.1 \ No newline at end of file