-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathYY-Thunks.lua
More file actions
48 lines (41 loc) · 1.69 KB
/
YY-Thunks.lua
File metadata and controls
48 lines (41 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
target("YY-Thunks")
set_kind("phony")
before_build("windows", function (target)
local function find_in_file()
for _, dir in ipairs(os.dirs("$(projectdir)/*")) do
name = dir:match(".*\\(.*)")
if name:find("YY%-Thunks") then
return dir .. [[\]]
end
end
end
local function find_in_reg()
return vformat("$(reg HKEY_CURRENT_USER\\Code\\YY-Thunks;Root)")
end
local YY_Thunks_Root = find_in_file() or find_in_reg()
if #YY_Thunks_Root == 0 then
return
end
local WindowsTargetPlatformMinVersion = "5.1.2600.0"
cprint("${color.warning}YY-Thunks Path : %s", YY_Thunks_Root)
cprint("${color.warning}WindowsTargetPlatformMinVersion : %s", WindowsTargetPlatformMinVersion)
import("core.tool.toolchain")
local msvc = toolchain.load("msvc")
local runenvs = msvc:runenvs()
local arch = target:arch()
local archpath = "Win32"
if arch ~= "x86" then
archpath = arch
end
cprint("${color.warning}Platform : %s", archpath)
local libpath = YY_Thunks_Root .. [[Lib\]] .. WindowsTargetPlatformMinVersion .. [[\]] .. archpath .. ";"
runenvs.LIB = libpath .. runenvs.LIB
if target:kind() == "shared" then
target:add("ldflags", "/ENTRY:DllMainCRTStartupForYY_Thunks", {force = true})
end
if archpath == "x86" then
target:add("ldflags", "/SUBSYSTEM:WINDOWS,5.01", {force = true})
else
target:add("ldflags", "/SUBSYSTEM:WINDOWS,5.02", {force = true})
end
end)