@@ -9,37 +9,29 @@ add_rules("c.unity_build")
9
9
add_cxflags (" /bigobj" , " /MP" , " /EHsc" )
10
10
add_defines (" UNICODE" , " _UNICODE" , " _CRT_SECURE_NO_WARNINGS" )
11
11
12
- local vsRuntime = " MD"
13
-
14
12
if is_mode (" debug" ) then
15
- add_defines (" CET_DEBUG" )
16
- set_symbols (" debug" )
17
13
set_optimize (" none" )
18
14
set_warnings (" all" )
19
15
set_policy (" build.optimization.lto" , false )
20
-
21
- vsRuntime = vsRuntime .. " d"
22
16
elseif is_mode (" releasedbg" ) then
23
- add_defines (" CET_DEBUG" )
24
- set_symbols (" debug" )
25
17
set_optimize (" fastest" )
26
18
set_warnings (" all" )
27
19
set_policy (" build.optimization.lto" , true )
28
-
29
- vsRuntime = vsRuntime .. " d"
30
20
elseif is_mode (" release" ) then
31
- add_defines (" NDEBUG" )
32
- set_symbols (" debug" )
33
21
set_strip (" all" )
34
22
set_optimize (" fastest" )
35
- set_runtimes (" MD" )
36
23
set_warnings (" all" , " error" )
37
24
set_policy (" build.optimization.lto" , true )
38
25
end
39
26
40
- set_runtimes (vsRuntime );
27
+ set_symbols (" debug" )
28
+ set_runtimes (is_mode (" release" ) and " MD" or " MDd" );
41
29
42
- add_requireconfs (" **" , { configs = { debug = is_mode (" debug" ), lto = not is_mode (" debug" ), shared = false , vs_runtime = vsRuntime } })
30
+ add_requireconfs (" **" , { configs = {
31
+ -- debug = is_mode("debug"), -- This seems to cause compilation issues recently and probably has little benefit anyway
32
+ lto = not is_mode (" debug" ),
33
+ shared = false ,
34
+ vs_runtime = is_mode (" release" ) and " MD" or " MDd" } })
43
35
44
36
add_requires (" spdlog 1.11.0" )
45
37
add_requires (" nlohmann_json" )
@@ -67,14 +59,74 @@ target("cyber_engine_tweaks")
67
59
add_defines (" WIN32_LEAN_AND_MEAN" , " NOMINMAX" , " WINVER=0x0601" , " SOL_ALL_SAFETIES_ON" , " SOL_LUAJIT=1" , " SOL_EXCEPTIONS_SAFE_PROPAGATION" , " SPDLOG_WCHAR_TO_UTF8_SUPPORT" , " SPDLOG_WCHAR_FILENAMES" , " SPDLOG_WCHAR_SUPPORT" , " IMGUI_USER_CONFIG=\" " .. imguiUserConfig .. " \" " ) -- WINVER=0x0601 == Windows 7xmake
68
60
set_pcxxheader (" src/stdafx.h" )
69
61
set_kind (" shared" )
70
- set_filename (" cyber_engine_tweaks.asi" )
71
- add_files (" src/**.cpp" )
72
- add_headerfiles (" src/**.h" , " build/CETVersion.h" )
62
+
63
+ set_configdir (path.join (" src" , " config" ))
64
+ add_configfiles (" src/xmake/**.in" )
65
+
66
+ add_files (" src/**.cpp" , " src/**.rc" )
67
+ add_headerfiles (" src/**.h" )
73
68
add_includedirs (" src/" , " build/" )
74
69
add_syslinks (" User32" , " Version" , " d3d11" , " dxgi" )
75
70
add_packages (" spdlog" , " nlohmann_json" , " minhook" , " hopscotch-map" , " imgui" , " mem" , " sol2" , " tiltedcore" , " sqlite3" , " openrestry-luajit" , " xbyak" , " stb" )
76
71
add_deps (" RED4ext.SDK" )
77
- add_configfiles (" src/CETVersion.h.in" )
72
+
73
+ -- Set up basic config variables.
74
+ -- Required for us to set up something here first to be able to access and modify "configvars"
75
+ -- in `on_load`, there seems to be no way to do this otherwise at the moment.
76
+ set_configvar (" CET_PRODUCT_NAME" , " Cyber Engine Tweaks" )
77
+
78
+ on_load (function (target )
79
+ -- Set filename based on project name
80
+ target :set (" basename" , target :name ())
81
+ target :set (" extension" , " .asi" )
82
+
83
+ -- Get a list of existing target config variables.
84
+ local configVars = target :get (" configvar" )
85
+
86
+ -- Set up other basic config variables.
87
+ configVars .CET_CURRENT_YEAR = tonumber (os.date (" %Y" ))
88
+ configVars .CET_GROUP_NAME = configVars .CET_PRODUCT_NAME .. " Team"
89
+ configVars .CET_FILE_NAME = target :filename ();
90
+
91
+ -- Set up build type.
92
+ if is_mode (" release" ) then
93
+ configVars .CET_DEBUG_BUILD = 0
94
+ else
95
+ configVars .CET_DEBUG_BUILD = 1
96
+ target :add (" defines" , " CET_DEBUG" )
97
+ end
98
+
99
+ -- Emulate GIT_<XXX> XMake Git builtins so we can parse them ourselves.
100
+ -- Unable to use and access builtins unfortunately. This is taken directly from XMake source.
101
+ configVars .CET_GIT_TAG = os .iorun (" git describe --tags" ):gsub (" %s" , " " )
102
+ configVars .CET_GIT_TAG_LONG = os .iorun (" git describe --tags --long" ):gsub (" %s" , " " )
103
+ configVars .CET_GIT_BRANCH = os .iorun (" git rev-parse --abbrev-ref HEAD" ):gsub (" %s" , " " )
104
+ configVars .CET_GIT_COMMIT = os .iorun (" git rev-parse --short HEAD" ):gsub (" %s" , " " )
105
+ configVars .CET_GIT_COMMIT_LONG = os .iorun (" git rev-parse HEAD" ):gsub (" %s" , " " )
106
+ configVars .CET_GIT_COMMIT_DATE = os .iorun (" git log -1 --date=format:%Y%m%d%H%M%S --format=%ad" ):gsub (" %s" , " " )
107
+
108
+ -- Split tag so we can easily extract version from it.
109
+ local splitGitTag = configVars .CET_GIT_TAG :split (" %." )
110
+ assert (# splitGitTag == 3 )
111
+
112
+ -- Setup version variables.
113
+ configVars .CET_VERSION_MAJOR = tonumber (splitGitTag [1 ]:match (" %d+" ))
114
+ configVars .CET_VERSION_MINOR = tonumber (splitGitTag [2 ]:match (" %d+" ))
115
+ configVars .CET_VERSION_PATCH = tonumber (splitGitTag [3 ]:match (" %d+" ))
116
+ configVars .CET_VERSION_SIMPLE = format (
117
+ " %d.%d.%d" ,
118
+ configVars .CET_VERSION_MAJOR ,
119
+ configVars .CET_VERSION_MINOR ,
120
+ configVars .CET_VERSION_PATCH )
121
+ configVars .CET_VERSION_FULL = format (
122
+ " %s [%s]" ,
123
+ configVars .CET_GIT_TAG ,
124
+ configVars .CET_GIT_BRANCH )
125
+ configVars .CET_VERSION = configVars .CET_VERSION_FULL
126
+
127
+ -- Push new list to target.
128
+ target :add (" configvar" , configVars )
129
+ end )
78
130
79
131
on_package (function (target )
80
132
import (" net.http" )
0 commit comments