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

Xmake Improvements #494

Merged
merged 9 commits into from
May 17, 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
50 changes: 10 additions & 40 deletions UE4SS/proxy_generator/proxy/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,6 @@ option("ue4ssProxyPath")
set_default("C:\\Windows\\System32\\dwmapi.dll")
set_description("Set path for a dll to generate the proxy for")

target("proxy_files")
set_kind("binary")
add_deps("proxy_generator")

set_policy("build.across_targets_in_parallel", false)

on_build(function (target)
local proxy_generator = path.join(os.projectdir(), target:dep("proxy_generator"):targetfile())
local output_path = path.join(os.projectdir(), target:autogendir())
local file = get_config("ue4ssProxyPath")

os.mkdir(output_path)

os.execv(proxy_generator, {file, output_path})
end)

on_link(function () end)

after_clean(function (target)
os.rm(target:autogendir())
end)

target("proxy")
set_kind("shared")
add_options("ue4ssProxyPath")
Expand All @@ -33,30 +11,22 @@ target("proxy")

set_policy("build.across_targets_in_parallel", false)

add_deps("File", "proxy_files")
add_deps("File", "proxy_generator")

add_files("proxy.rc")

on_load(function (target)
import("target_helpers", { rootdir = get_config("scriptsRoot") })
local filename = target_helpers.get_path_filename(get_config("ue4ssProxyPath"))
target:set("basename", filename)
end)
-- Set the name of the target file to be the base file name of the proxy dll ("dwmapi").
set_basename(path.basename(get_config("ue4ssProxyPath")))

after_load(function (target)
local projectRoot = get_config("ue4ssRoot")

local scriptsRoot = get_config("scriptsRoot")
import("target_helpers", { rootdir = scriptsRoot })
import("build_configs", { rootdir = scriptsRoot })

build_configs:config(target)
build_configs:set_output_dir(target)

local output_path = path.join(os.projectdir(), target:dep("proxy_files"):autogendir())
local proxy_name = target_helpers.get_path_filename(get_config("ue4ssProxyPath"))

local output_path = path.join(target:dep("proxy_generator"):autogendir())
local proxy_name = path.basename(target:targetfile())
target:add("files", path.join(output_path, "dllmain.cpp"), { always_added = true })
target:add("files", path.join(output_path, proxy_name .. ".asm"), { rule = "asm", always_added = true })
target:add("files", path.join(output_path, proxy_name .. ".def"), { always_added = true })
end)

on_install(function(target)
os.mkdir(target:installdir())
os.cp(target:targetfile(), target:installdir())
end)
15 changes: 15 additions & 0 deletions UE4SS/proxy_generator/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,19 @@ target(projectName)
add_deps("File", "Constructs")
add_links("imagehlp")

after_build(function(target)
local proxy_exe = target:targetfile()
local output_path = target:autogendir()
import("core.base.task")
-- The second arg of task.run is used if we plan on calling `xmake proxy_files`.
-- The proxy_files task is not exposed to the CLI, so we pass an empty second arg.
task.run("proxy_files", {}, proxy_exe, output_path)
end)

-- Define a task that executes the proxy_generator exe with the provided arguments
task("proxy_files")
on_run(function (proxy_gen_exe, output_path)
os.mkdir(output_path)
os.execv(proxy_gen_exe, {get_config("ue4ssProxyPath"), output_path})
end)
includes("proxy")
55 changes: 31 additions & 24 deletions UE4SS/xmake.lua
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
includes("proxy_generator")

add_requires("imgui v1.89", { debug = is_mode_debug(), configs = { win32 = true, dx11 = true, opengl3 = true, glfw_opengl3 = true, runtimes = get_mode_runtimes() } })
add_requires("ImGuiTextEdit v1.0", { debug = is_mode_debug(), configs = { runtimes = get_mode_runtimes() } })
add_requires("IconFontCppHeaders v1.0", { debug = is_mode_debug(), configs = { runtimes = get_mode_runtimes() } })
add_requires("glfw 3.3.9", { debug = is_mode_debug(), configs = { runtimes = get_mode_runtimes() } })
add_requires("opengl", { debug = is_mode_debug(), configs = { runtimes = get_mode_runtimes() } })
add_requires("imgui v1.89", { debug = is_mode_debug(), configs = { win32 = true, dx11 = true, opengl3 = true, glfw_opengl3 = true , runtimes = get_mode_runtimes()} } )
add_requires("ImGuiTextEdit v1.0", { debug = is_mode_debug(), configs = {runtimes = get_mode_runtimes()} })
add_requires("IconFontCppHeaders v1.0", { debug = is_mode_debug(), configs = {runtimes = get_mode_runtimes()}})
add_requires("glfw 3.3.9", { debug = is_mode_debug() , configs = {runtimes = get_mode_runtimes()}})
add_requires("opengl", { debug = is_mode_debug(), configs = {runtimes = get_mode_runtimes()} })

option("ue4ssBetaIsStarted")
set_default(true)
set_showmenu(true)
-- Sets the possible options to only be true or false.
set_values(true, false)

set_description("Have beta releases started for the current major version")

option("ue4ssIsBeta")
set_default(true)
set_showmenu(true)
-- Sets the possible options to only be true or false.
set_values(true, false)

set_description("Is this a beta release")
Expand All @@ -42,9 +44,8 @@ target(projectName)
set_languages("cxx20")
set_exceptions("cxx")
set_default(true)

add_rules("ue4ss.defines.exports")
add_options("ue4ssBetaIsStarted", "ue4ssIsBeta")

add_includedirs("include", { public = true })
add_includedirs("generated_include", { public = true })
add_headerfiles("include/**.hpp")
Expand All @@ -60,6 +61,7 @@ target(projectName)
"ScopedTimer", "Profiler", "patternsleuth_bind",
"glad", { public = true }
)

add_packages("imgui", "ImGuiTextEdit", "IconFontCppHeaders", "glfw", "opengl", { public = true })

add_packages("glaze", "polyhook_2", { public = true })
Expand All @@ -68,18 +70,6 @@ target(projectName)

after_load(function (target)
local projectRoot = get_config("ue4ssRoot")

local scriptsRoot = get_config("scriptsRoot")
import("build_configs", { rootdir = scriptsRoot })
import("target_helpers", { rootdir = scriptsRoot })

print("Project: " .. projectName .. " (SHARED)")

build_configs:set_output_dir(target)
build_configs:export_deps(target)

target:add("defines", target_helpers.project_name_to_exports_define(projectName))

local version_string = io.readfile(path.join(target:scriptdir(), "generated_src/version.cache"))
local version = parse_version_string(version_string)

Expand All @@ -92,11 +82,28 @@ target(projectName)
target:add("defines", "UE4SS_LIB_BETA_STARTED=" .. (get_config("ue4ssBetaIsStarted") and "1" or "0"), { public = true })
target:add("defines", "UE4SS_LIB_IS_BETA=" .. (get_config("ue4ssIsBeta") and "1" or "0"), { public = true })

local git_dir = path.join(projectRoot, ".git")
local outdata, _ = os.iorunv("git", {"--git-dir=" .. git_dir, "--work-tree=" .. projectRoot, "rev-parse", "--short", "HEAD"})
local commit_hash = outdata:gsub("%s+$", "")
target:add("defines", "UE4SS_LIB_BUILD_GITSHA=\"" .. commit_hash .. "\"", { public = true })

-- Attempt to get the latest git commit from the UE4SS root directory.
-- We have to be explicit about running it in the root UE4SS directory
-- in the case where RE-UE4SS is submoduled in another git repo.

import("lib.detect.find_tool")
local git = assert(find_tool("git"), "git not found!")

-- init arguments
local argv = {"rev-parse", "--short", "HEAD"}
local lastcommit = os.iorunv(git.program, argv, {curdir = get_config("ue4ssRoot")})
if lastcommit then
lastcommit = lastcommit:trim()
end

target:add("defines", "UE4SS_LIB_BUILD_GITSHA=\"" .. lastcommit .. "\"", { public = true })
target:add("defines", "UE4SS_CONFIGURATION=\"" .. get_config("mode") .. "\"", { public = true })
end)

on_install(function(target)
os.mkdir(target:installdir())
os.cp(target:targetfile(), target:installdir())
if target:symbolfile() then
os.cp(target:symbolfile(), target:installdir())
end
end)
2 changes: 1 addition & 1 deletion UVTD/xmake.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local projectName = "UVTD"

add_requires("raw_pdb", { debug = is_mode_debug(), configs = { runtimes = get_mode_runtimes() } })
add_requires("raw_pdb", { debug = is_mode_debug(), configs = {runtimes = get_mode_runtimes()} })

target(projectName)
set_kind("binary")
Expand Down
13 changes: 2 additions & 11 deletions deps/first/ASMHelper/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,12 @@ target(projectName)
set_kind("static")
set_languages("cxx20")
set_exceptions("cxx")
set_values("ue4ssDep", true)
add_rules("ue4ss.dependency")

add_includedirs("include", { public = true })
add_headerfiles("include/**.hpp")

add_files("src/**.cpp")

add_deps("File", "DynamicOutput", "Constructs")
add_packages("zydis")

on_load(function (target)
import("target_helpers", { rootdir = get_config("scriptsRoot") })

print("Project: " .. projectName .. " (STATIC)")

target:add("defines", target_helpers.project_name_to_exports_define(projectName))
target:add("defines", target_helpers.project_name_to_build_static_define(projectName))
end)
add_packages("zydis")
2 changes: 1 addition & 1 deletion deps/first/ArgsParser/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ target(projectName)
set_kind("binary")
set_languages("cxx20")
set_exceptions("cxx")
set_values("ue4ssDep", true)
add_rules("ue4ss.dependency")

add_includedirs("include", { public = true })
add_headerfiles("include/**.hpp")
Expand Down
8 changes: 2 additions & 6 deletions deps/first/Constructs/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ target(projectName)
set_kind("headeronly")
set_languages("cxx20")
set_exceptions("cxx")
set_values("ue4ssDep", true)
add_rules("ue4ss.dependency")

add_includedirs("include", { public = true })
add_headerfiles("include/**.hpp")

on_load(function ()
print("Project: " .. projectName .. " (HEADER-ONLY)")
end)
add_headerfiles("include/**.hpp")
13 changes: 2 additions & 11 deletions deps/first/DynamicOutput/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,11 @@ target(projectName)
set_kind("static")
set_languages("cxx20")
set_exceptions("cxx")
set_values("ue4ssDep", true)
add_rules("ue4ss.dependency")

add_includedirs("include", { public = true })
add_headerfiles("include/**.hpp")

add_files("src/**.cpp")

add_deps("File")

on_load(function (target)
import("target_helpers", { rootdir = get_config("scriptsRoot") })

print("Project: " .. projectName .. " (STATIC)")

target:add("defines", target_helpers.project_name_to_exports_define(projectName))
target:add("defines", target_helpers.project_name_to_build_static_define(projectName))
end)
add_deps("File")
14 changes: 2 additions & 12 deletions deps/first/File/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,9 @@ target(projectName)
set_kind("static")
set_languages("cxx20")
set_exceptions("cxx")
set_values("ue4ssDep", true)
add_rules("ue4ss.dependency")

add_includedirs("include", { public = true })
add_headerfiles("include/**.hpp")

add_files("src/**.cpp")


on_load(function (target)
import("target_helpers", { rootdir = get_config("scriptsRoot") })

print("Project: " .. projectName .. " (STATIC)")

target:add("defines", target_helpers.project_name_to_exports_define(projectName))
target:add("defines", target_helpers.project_name_to_build_static_define(projectName))
end)
add_files("src/**.cpp")
8 changes: 2 additions & 6 deletions deps/first/Function/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ target(projectName)
set_kind("headeronly")
set_languages("cxx20")
set_exceptions("cxx")
set_values("ue4ssDep", true)
add_rules("ue4ss.dependency")

add_includedirs("include", { public = true })
add_headerfiles("include/**.hpp")

on_load(function (target)
print("Project: " .. projectName .. " (HEADER-ONLY)")
end)
add_headerfiles("include/**.hpp")
8 changes: 2 additions & 6 deletions deps/first/Helpers/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ target(projectName)
set_kind("headeronly")
set_languages("cxx20")
set_exceptions("cxx")
set_values("ue4ssDep", true)
add_rules("ue4ss.dependency")

add_includedirs("include", { public = true })
add_headerfiles("include/**.hpp")

on_load(function (target)
print("Project: " .. projectName .. " (HEADER-ONLY)")
end)
add_headerfiles("include/**.hpp")
13 changes: 2 additions & 11 deletions deps/first/IniParser/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ target(projectName)
set_kind("static")
set_languages("cxx20")
set_exceptions("cxx")
set_values("ue4ssDep", true)
add_rules("ue4ss.dependency")

add_includedirs("include", { public = true })
add_headerfiles("include/**.hpp")
Expand All @@ -13,13 +13,4 @@ target(projectName)
"src/Ini.cpp", "src/Value.cpp", "src/TokenParser.cpp"
)

add_deps("File", "Helpers", "ParserBase")

on_load(function (target)
import("target_helpers", { rootdir = get_config("scriptsRoot") })

print("Project: " .. projectName .. " (STATIC)")

target:add("defines", target_helpers.project_name_to_exports_define(projectName))
target:add("defines", target_helpers.project_name_to_build_static_define(projectName))
end)
add_deps("File", "Helpers", "ParserBase")
13 changes: 2 additions & 11 deletions deps/first/Input/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,9 @@ target(projectName)
set_kind("static")
set_languages("cxx20")
set_exceptions("cxx")
set_values("ue4ssDep", true)
add_rules("ue4ss.dependency")

add_includedirs("include", { public = true })
add_headerfiles("include/**.hpp")

add_files("src/**.cpp")

on_load(function (target)
import("target_helpers", { rootdir = get_config("scriptsRoot") })

print("Project: " .. projectName .. " (STATIC)")

target:add("defines", target_helpers.project_name_to_exports_define(projectName))
target:add("defines", target_helpers.project_name_to_build_static_define(projectName))
end)
add_files("src/**.cpp")
Loading