-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpremake5.lua
More file actions
150 lines (132 loc) · 5.84 KB
/
Copy pathpremake5.lua
File metadata and controls
150 lines (132 loc) · 5.84 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
newoption {
trigger = "with-version",
value = "STRING",
description = "Current version",
}
workspace "FC2JackalFix"
configurations { "Release", "Debug" }
architecture "x86"
location "build"
cppdialect "C++latest"
kind "SharedLib"
language "C++"
targetdir "bin/%{cfg.buildcfg}"
targetextension ".asi"
buildoptions { "/dxifcInlineFunctions-" }
defines { "rsc_CompanyName=\"FC2JackalFix\"" }
defines { "rsc_LegalCopyright=\"MIT license\""}
defines { "rsc_InternalName=\"%{prj.name}\"", "rsc_ProductName=\"%{prj.name}\"", "rsc_OriginalFilename=\"%{cfg.buildtarget.name}\"" }
defines { "rsc_FileDescription=\"Far Cry 2 Jackal Fix\"" }
defines { "rsc_UpdateUrl=\"https://github.com/TGP482/FC2JackalFix\"" }
local major = os.date("%d")
local minor = os.date("%m")
local build = os.date("%Y")
local revision = os.date("%H") .. os.date("%M")
if _OPTIONS["with-version"] then
local t = {}
for i in _OPTIONS["with-version"]:gmatch("([^.]+)") do
t[#t + 1], _ = i:gsub("%D+", "")
end
while #t < 4 do t[#t + 1] = 0 end
major = math.min(tonumber(t[1]), 255)
minor = math.min(tonumber(t[2]), 255)
build = math.min(tonumber(t[3]), 65535)
revision = math.min(tonumber(t[4]), 65535)
end
-- -- Local builds show DEV, CI releases use the actual version
local nRelease = 2
local szVersion = _OPTIONS["with-version"] and ("V" .. major) or ("V" .. nRelease .. " DEV")
local githash = ""
local f = io.popen("git rev-parse --short HEAD")
if f then
githash = f:read("*a"):gsub("%s+", "")
f:close()
end
local productVersion = major .. "." .. minor .. "." .. build .. "." .. revision
if githash ~= "" then
productVersion = productVersion .. "-" .. githash
end
defines { "rsc_FileVersion_MAJOR=" .. major }
defines { "rsc_FileVersion_MINOR=" .. minor }
defines { "rsc_FileVersion_BUILD=" .. build }
defines { "rsc_FileVersion_REVISION=" .. revision }
defines { "rsc_FileVersion=\"" .. major .. "." .. minor .. "." .. build .. "\"" }
defines { "rsc_ProductVersion=\"" .. productVersion .. "\"" }
defines { "rsc_GitSHA1=\"" .. githash .. "\"" }
defines { "rsc_GitSHA1W=L\"" .. githash .. "\"" }
defines { "rsc_Version=\"" .. szVersion .. "\"" }
defines { "rsc_VersionW=L\"" .. szVersion .. "\"" }
defines { "_CRT_SECURE_NO_WARNINGS" }
includedirs { "source" }
includedirs { "source/includes" }
files { "source/**.h", "source/**.hpp", "source/**.cpp", "source/**.hxx", "source/**.ixx" }
files { "source/resources/Versioninfo.rc" }
includedirs { "external/hooking" }
includedirs { "external/injector/include" }
includedirs { "external/injector/safetyhook/include" }
includedirs { "external/injector/zydis" }
includedirs { "external/inireader" }
files { "external/hooking/Hooking.Patterns.h", "external/hooking/Hooking.Patterns.cpp" }
-- Listed one by one rather than globbed. Wildcards over the submodules produced a project with
-- no safetyhook or zydis sources in it at all, which compiles fine and only fails at link time
-- once something actually calls safetyhook. Explicit paths are the form known to work here.
-- os.linux.cpp is skipped; it is #if'd out on Windows anyway.
files { "external/injector/safetyhook/include/safetyhook.hpp" }
files {
"external/injector/safetyhook/src/allocator.cpp",
"external/injector/safetyhook/src/easy.cpp",
"external/injector/safetyhook/src/inline_hook.cpp",
"external/injector/safetyhook/src/mid_hook.cpp",
"external/injector/safetyhook/src/os.windows.cpp",
"external/injector/safetyhook/src/utility.cpp",
"external/injector/safetyhook/src/vmt_hook.cpp",
}
files { "external/injector/zydis/Zydis.h", "external/injector/zydis/Zydis.c" }
files { "data/bin/plugins/*.ini" }
links { "winmm" } -- timeBeginPeriod, for loadingscreen.ixx
characterset ("Unicode")
pbcommands = {
"for %%P in (\"!JFDIR!.\") do set \"JFDIR=%%~fP\"",
-- Parentheses keep both SET commands inside the FOR loop body.
"for %%S in (\"$(TargetPath)\") do (set \"JFSRC=%%~fS\" & set \"JFNAME=%%~nxS\")",
"set \"JFDST=!JFDIR!\\!JFNAME!\"",
-- No game install found, skip
"if not exist \"!JFDIR!\\\" goto :JFDONE",
"if /I \"!JFSRC!\"==\"!JFDST!\" goto :JFDONE",
-- Loud on failure. The game holds the asi open while it runs, so the copy silently did
-- nothing and the build still reported success, leaving the previous asi in place. That is
-- what a fix that works one run and not the next looks like.
"copy /y \"!JFSRC!\" \"!JFDST!\" >nul || (echo FC2JackalFix: could not replace \"!JFDST!\", close the game and build again & endlocal & exit /b 1)",
":JFDONE",
"endlocal",
"exit /b 0" }
function setpaths (gamepath, exepath, pluginspath)
pluginspath = pluginspath or "plugins/"
if (gamepath) then
-- Keep deployment variables local to this build step
local cmdcopy = {
"setlocal EnableExtensions EnableDelayedExpansion",
"set \"JFDIR=" .. (gamepath .. pluginspath):gsub("([^/\\])$", "%1/") .. "\"",
}
for _, cmd in ipairs(pbcommands) do
table.insert(cmdcopy, cmd)
end
postbuildcommands (cmdcopy)
debugdir (gamepath)
if (exepath) then
debugcommand (gamepath .. exepath)
dir, file = exepath:match'(.*/)(.*)'
debugdir (gamepath .. (dir or ""))
end
end
targetdir ("bin")
end
filter "configurations:Debug"
defines { "DEBUG" }
symbols "On"
filter "configurations:Release"
defines { "NDEBUG" }
optimize "On"
staticruntime "On"
project "FC2JackalFix"
setpaths("E:/Games/SteamLibrary/steamapps/common/Far Cry 2/", "bin/FarCry2.exe", "bin/plugins/")