-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpremake5.lua
More file actions
142 lines (124 loc) · 5.2 KB
/
Copy pathpremake5.lua
File metadata and controls
142 lines (124 loc) · 5.2 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
-- Allow CI to override via --generator-version=3 for x86-64-support-sourcesdk branch
newoption({
trigger = "generator-version",
description = "garrysmod_common PROJECT_GENERATOR_VERSION (2 = default, 3 = x86-64-support-sourcesdk)",
value = "2"
})
PROJECT_GENERATOR_VERSION = tonumber(_OPTIONS["generator-version"]) or 2
newoption({
trigger = "gmcommon",
description = "Sets the path to the garrysmod_common (https://github.com/danielga/garrysmod_common) directory",
value = "../garrysmod_common"
})
newoption({
trigger = "with-vulkan",
description = "Enable the Vulkan GPU backend (off by default; CPU-only build)"
})
local WITH_VULKAN = _OPTIONS["with-vulkan"] ~= nil
local gmcommon = assert(_OPTIONS.gmcommon or os.getenv("GARRYSMOD_COMMON"),
"you didn't provide a path to your garrysmod_common (https://github.com/danielga/garrysmod_common) directory")
include(gmcommon)
local module_name = WITH_VULKAN and "auris-gpu" or "auris"
CreateWorkspace({name = module_name, abi_compatible = false, path = "projects/" .. os.target() .. "/" .. _ACTION})
CreateProject({serverside = true, source_path = "source", manual_files = false})
warnings("Default")
IncludeSDKCommon()
IncludeSDKTier0()
IncludeSDKTier1()
IncludeSteamAPI()
IncludeDetouring()
IncludeScanning()
IncludeHelpersExtended()
-- whisper.cpp vendor files
includedirs({
"vendor/whisper.cpp/include",
"vendor/whisper.cpp/ggml/include",
"vendor/whisper.cpp/ggml/src",
"vendor/whisper.cpp/ggml/src/ggml-cpu",
})
files({
"vendor/whisper.cpp/src/whisper.cpp",
"vendor/whisper.cpp/ggml/src/*.c",
"vendor/whisper.cpp/ggml/src/*.cpp",
"vendor/whisper.cpp/ggml/src/ggml-cpu/*.c",
"vendor/whisper.cpp/ggml/src/ggml-cpu/*.cpp",
"vendor/whisper.cpp/ggml/src/ggml-cpu/arch/x86/*.c",
"vendor/whisper.cpp/ggml/src/ggml-cpu/arch/x86/*.cpp",
})
local versionFile = io.open("VERSION", "r")
local aurisVersion = versionFile and versionFile:read("*l") or "unknown"
if versionFile then versionFile:close() end
defines({
"AURIS_VERSION=\"" .. aurisVersion .. "\"",
"GGML_USE_CPU",
"WHISPER_VERSION=\"1.0.0\"",
"GGML_VERSION=\"1.0.0\"",
"GGML_COMMIT=\"local\"",
"NDEBUG",
})
-- Optimization for whisper.cpp — flags split by toolset
optimize("Speed")
vectorextensions("AVX2")
filter("toolset:msc*")
flags({"NoBufferSecurityCheck"})
buildoptions({"/fp:fast", "/Ox", "/GL", "/arch:AVX2"})
linkoptions({"/LTCG"})
filter("toolset:gcc or clang")
defines({"_GNU_SOURCE"})
-- -ffast-math enables -ffinite-math-only which ggml explicitly forbids
-- (vec.h line 1069 #errors on __FINITE_MATH_ONLY__). Use the safe subset instead.
-- -fno-stack-protector omitted: EDRs (CrowdSec, VirusTotal) flag binaries built without
-- stack protection as exploit-facilitating, triggering false CVE-2023-4911 detections.
buildoptions({"-fno-math-errno", "-funsafe-math-optimizations", "-fno-rounding-math", "-fno-signaling-nans", "-O3", "-flto", "-mavx2", "-mfma", "-mf16c"})
linkoptions({"-flto"})
-- 32-bit x86 Linux: force SSE2 scalar FP to match x86_64 behavior.
-- Without this GCC uses x87 (80-bit extended precision) for scalar floats,
-- causing whisper softmax/logit values to diverge from every other platform.
filter("toolset:gcc or clang", "platforms:x86", "system:linux")
buildoptions({"-mfpmath=sse", "-msse2"})
filter({})
-- Opus for decoding steam voice
includedirs({"vendor/opus/include"})
filter("platforms:x86")
libdirs({path.getabsolute("vendor/opus/lib32")})
filter("platforms:x86_64")
libdirs({path.getabsolute("vendor/opus/lib64")})
filter({})
links({"opus"})
-- Vulkan GPU backend (opt-in via --with-vulkan)
-- Without this flag the module is CPU-only and has no libvulkan dep,
-- so it loads on headless dedis with no Vulkan loader installed.
if WITH_VULKAN then
local vulkan_sdk = os.getenv("VULKAN_SDK") or "C:/VulkanSDK/1.4.341.1"
defines({"GGML_USE_VULKAN"})
includedirs({
"vendor/whisper.cpp/ggml/src/ggml-vulkan",
})
files({
"vendor/whisper.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp",
"vendor/whisper.cpp/ggml/src/ggml-vulkan/ggml-vulkan-shaders.cpp",
})
-- Windows: Vulkan SDK headers + import lib
filter("system:windows")
includedirs({vulkan_sdk .. "/Include"})
links({"vulkan-1"})
-- premake does not support compound filter keys — split into separate filters
filter({"system:windows", "platforms:x86"})
libdirs({path.getabsolute("vendor/vulkan/lib32")})
-- x86 stdcall decorates symbols with @N but the import lib has
-- undecorated names. Map the 3 directly-linked Vulkan symbols.
linkoptions({
"/ALTERNATENAME:_vkCmdCopyBuffer@28=_vkCmdCopyBuffer",
"/ALTERNATENAME:_vkGetPhysicalDeviceFeatures2@8=_vkGetPhysicalDeviceFeatures2",
"/ALTERNATENAME:_vkGetInstanceProcAddr@8=_vkGetInstanceProcAddr",
})
filter({"system:windows", "platforms:x86_64"})
libdirs({vulkan_sdk .. "/Lib"})
-- Linux: system Vulkan loader
-- VULKAN_HPP_TYPESAFE_CONVERSION enables implicit vk:: <-> Vk* handle conversions
-- that ggml-vulkan.cpp relies on when mixing C and C++ Vulkan APIs.
filter("system:linux")
defines({"VULKAN_HPP_TYPESAFE_CONVERSION=1"})
links({"vulkan"})
filter({})
end