From 516de511a87c15068e83b7644ff61fd7dda2fd04 Mon Sep 17 00:00:00 2001 From: OEOTYAN Date: Wed, 24 Apr 2024 15:19:32 +0800 Subject: [PATCH] refactor: refactoring fakeSymbol --- repository/packages/l/llvm-prebuilt/xmake.lua | 15 ----------- src/pe_editor/PeEditor.cpp | 25 ++++++++----------- xmake-requires.lock | 21 ++++++++-------- xmake.lua | 7 +++--- 4 files changed, 25 insertions(+), 43 deletions(-) delete mode 100644 repository/packages/l/llvm-prebuilt/xmake.lua diff --git a/repository/packages/l/llvm-prebuilt/xmake.lua b/repository/packages/l/llvm-prebuilt/xmake.lua deleted file mode 100644 index d612443..0000000 --- a/repository/packages/l/llvm-prebuilt/xmake.lua +++ /dev/null @@ -1,15 +0,0 @@ -package("llvm-prebuilt") - set_homepage("https://llvm.org/") - set_description("The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.") - set_license("Apache-2.0") - - add_urls("https://github.com/awakecoding/llvm-prebuilt/releases/download/v2023.1.0/clang+llvm-14.0.6-x86_64-windows.tar.xz") - - add_versions("14.0.6", "9eeed63df75e90a3b1e67ad574c954d8c215e879881e891b4e1c83df09d68056") - - on_install("windows", function (package) - if not is_arch("x64") then - raise("only x64 supported") - end - os.mv("*", package:installdir()) - end) diff --git a/src/pe_editor/PeEditor.cpp b/src/pe_editor/PeEditor.cpp index 3114212..c44a96f 100644 --- a/src/pe_editor/PeEditor.cpp +++ b/src/pe_editor/PeEditor.cpp @@ -155,23 +155,20 @@ int generateLibFile() { std::vector VarExports; std::ranges::for_each(filteredSymbols, [&](const PdbSymbol& symbol) { llvm::object::COFFShortExport record; - record.Name = symbol.name; - if (!symbol.isFunction) { - VarExports.push_back(record); - return; - } - ApiExports.push_back(record); - auto fakeSymbol = pe_editor::FakeSymbol::getFakeSymbol(symbol.name); - if (fakeSymbol.has_value()) { - record.Name = fakeSymbol.value(); - ApiExports.push_back(record); + if (auto fakeSymbol = pe_editor::FakeSymbol::getFakeSymbol(symbol.name); fakeSymbol) { + record.Name = *fakeSymbol; + } else { + record.Name = symbol.name; } - - fakeSymbol = pe_editor::FakeSymbol::getFakeSymbol(symbol.name, true); - if (fakeSymbol.has_value()) { - record.Name = fakeSymbol.value(); + if (!symbol.isFunction) { + VarExports.push_back(record); + } else { ApiExports.push_back(record); + if (auto removeVirtual = pe_editor::FakeSymbol::getFakeSymbol(symbol.name, true); removeVirtual) { + record.Name = *removeVirtual; + ApiExports.push_back(record); + } } }); diff --git a/xmake-requires.lock b/xmake-requires.lock index 369a47b..0191439 100644 --- a/xmake-requires.lock +++ b/xmake-requires.lock @@ -6,15 +6,15 @@ ["cmake#31fecfc4"] = { repo = { branch = "master", - commit = "fa285a31269c7a407167ff2942d1e1da5b4bbd81", + commit = "ce583d1736cf4ea43cc0c137e0d45671a446dc4a", url = "https://github.com/xmake-io/xmake-repo.git" }, - version = "3.27.2-msvc1" + version = "3.23.1" }, ["ctre#31fecfc4"] = { repo = { branch = "master", - commit = "fde5c56447574e8a439233b846c6bf70177f99d4", + commit = "fa285a31269c7a407167ff2942d1e1da5b4bbd81", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "3.4.1" @@ -22,7 +22,7 @@ ["cxxopts#31fecfc4"] = { repo = { branch = "master", - commit = "fde5c56447574e8a439233b846c6bf70177f99d4", + commit = "ce583d1736cf4ea43cc0c137e0d45671a446dc4a", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "v3.0.0" @@ -42,15 +42,16 @@ }, version = "9.1.0" }, - ["llvm-prebuilt#31fecfc4"] = { + ["llvm-prebuilt 18.1.1#31fecfc4"] = { repo = { - url = "repository" + commit = "aebe837394493aceb38adc0858e59bbdf21d9ff0", + url = "https://github.com/LiteLDev/xmake-repo.git" }, - version = "14.0.6" + version = "18.1.1" }, ["pe_bliss#31fecfc4"] = { repo = { - commit = "056b609c01e7e36436c4029f600cf8131b9c6954", + commit = "aebe837394493aceb38adc0858e59bbdf21d9ff0", url = "https://github.com/LiteLDev/xmake-repo.git" }, version = "v1.0.0" @@ -58,7 +59,7 @@ ["raw_pdb#31fecfc4"] = { repo = { branch = "master", - commit = "fa285a31269c7a407167ff2942d1e1da5b4bbd81", + commit = "ce583d1736cf4ea43cc0c137e0d45671a446dc4a", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "2022.10.17" @@ -66,7 +67,7 @@ ["spdlog#31fecfc4"] = { repo = { branch = "master", - commit = "fde5c56447574e8a439233b846c6bf70177f99d4", + commit = "ce583d1736cf4ea43cc0c137e0d45671a446dc4a", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "v1.11.0" diff --git a/xmake.lua b/xmake.lua index 5f1975d..509adec 100644 --- a/xmake.lua +++ b/xmake.lua @@ -1,10 +1,9 @@ add_rules("mode.debug", "mode.release") set_policy("package.requires_lock", true) -add_repositories("local-repo repository") add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git") -add_requires("llvm-prebuilt") +add_requires("llvm-prebuilt 18.1.1") add_requires("raw_pdb") add_requires("cxxopts") add_requires("fmt") @@ -22,7 +21,7 @@ target("PeEditor") set_symbols("debug") add_files("src/**.cpp") add_includedirs("src") - add_cxflags("/utf-8") + add_cxflags("/utf-8", "/EHa") add_defines("UNICODE", "PE_EDITOR_VERSION=\"v3.4.1\"") - add_syslinks("user32", "comdlg32") + add_syslinks("wsock32", "comdlg32") add_packages("llvm-prebuilt", "raw_pdb", "pe_bliss", "cxxopts", "fmt", "spdlog", "ctre", "demangler")