Skip to content

Commit cbafee8

Browse files
committed
Add premake option to allow debugging module with executable
Works great paired up with --autoinstall
1 parent 5349fb0 commit cbafee8

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

premake/generator.lua

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,72 @@ function CreateProject(config)
404404
postbuildcommands({"{COPY} \"%{cfg.buildtarget.abspath}\" \"" .. binDir .. "\""})
405405
end
406406

407+
local debug_path = _OPTIONS["debug-path"]
408+
if debug_path ~= nil then
409+
local client_args = {"-steam", "-game", "garrysmod"}
410+
local server_args = {
411+
"-console",
412+
"-game", "garrysmod",
413+
"-ip", "localhost",
414+
"-port", "27015",
415+
"+gamemode", "sandbox",
416+
"+map", "gm_construct",
417+
"+maxplayers", "16"
418+
}
419+
local args = is_server and server_args or client_args
420+
421+
if PROJECT_GENERATOR_VERSION < 3 then
422+
filter({"system:windows", "platforms:x86"})
423+
debugcommand(path.join(debug_path, is_server and "srcds.exe" or "hl2.exe"))
424+
debugdir(debug_path)
425+
debugargs(args)
426+
427+
filter({"system:linux", "platforms:x86"})
428+
debugcommand(path.join(debug_path, is_server and "srcds_linux" or "hl2_linux"))
429+
debugdir(debug_path)
430+
debugargs(args)
431+
debugenvs({"LD_LIBRARY_PATH=\".:bin:garrysmod/bin:$LD_LIBRARY_PATH\""})
432+
433+
if not is_server then
434+
filter({"system:macosx", "platforms:x86"})
435+
debugcommand(path.join(debug_path, "hl2_osx"))
436+
debugdir(debug_path)
437+
debugargs(args)
438+
end
439+
else
440+
filter({"system:windows", "platforms:x86"})
441+
debugcommand(path.join(debug_path, is_server and "srcds.exe" or "bin/gmod.exe"))
442+
debugdir(debug_path)
443+
debugargs(args)
444+
445+
filter({"system:windows", "platforms:x86_64"})
446+
debugcommand(path.join(debug_path, is_server and "srcds_win64.exe" or "bin/win64/gmod.exe"))
447+
debugdir(debug_path)
448+
debugargs(args)
449+
450+
if is_server then
451+
filter({"system:linux", "platforms:x86"})
452+
debugcommand(path.join(debug_path, "bin/linux32/srcds"))
453+
debugdir(debug_path)
454+
debugargs(args)
455+
debugenvs({"LD_LIBRARY_PATH=\".:bin/linux32:$LD_LIBRARY_PATH\""})
456+
end
457+
458+
filter({"system:linux", "platforms:x86_64"})
459+
debugcommand(path.join(debug_path, is_server and "bin/linux64/srcds" or "bin/linux64/gmod"))
460+
debugdir(debug_path)
461+
debugargs(args)
462+
debugenvs({"LD_LIBRARY_PATH=\".:bin/linux64:$LD_LIBRARY_PATH\""})
463+
464+
if not is_server then
465+
filter({"system:macosx", "platforms:x86_64"})
466+
debugcommand(path.join(debug_path, "GarrysMod_Signed.app/Contents/MacOS/gmod"))
467+
debugdir(debug_path)
468+
debugargs(args)
469+
end
470+
end
471+
end
472+
407473
IncludeHelpers()
408474

409475
filter({})

premake/options.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,9 @@ newoption({
6666
description = "Number of parallel jobs to run on the 'lint' command",
6767
value = "4"
6868
})
69+
70+
newoption({
71+
trigger = "debug-path",
72+
description = "Root path to the game client or server to debug with",
73+
value = "/home/you/garrysmod"
74+
})

0 commit comments

Comments
 (0)