aboutsummaryrefslogtreecommitdiff
path: root/cmake/Modules/FindLua.cmake
blob: be5d92d8c017779f024e44149b003a49b3fc9b0d (plain)
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
# Look for Lua library to use
# This selects LuaJIT by default

option(ENABLE_LUAJIT "Enable LuaJIT support" TRUE)
set(USE_LUAJIT FALSE)
option(REQUIRE_LUAJIT "Require LuaJIT support" FALSE)
if(REQUIRE_LUAJIT)
	set(ENABLE_LUAJIT TRUE)
endif()
if(ENABLE_LUAJIT)
	find_package(LuaJIT)
	if(LUAJIT_FOUND)
		set(USE_LUAJIT TRUE)
		message (STATUS "Using LuaJIT provided by system.")
	elseif(REQUIRE_LUAJIT)
		message(FATAL_ERROR "LuaJIT not found whereas REQUIRE_LUAJIT=\"TRUE\" is used.\n"
			"To continue, either install LuaJIT or do not use REQUIRE_LUAJIT=\"TRUE\".")
	endif()
else()
	message (STATUS "LuaJIT detection disabled! (ENABLE_LUAJIT=0)")
endif()

if(NOT USE_LUAJIT)
	message(STATUS "LuaJIT not found, using bundled Lua.")
	set(LUA_LIBRARY lua)
	set(LUA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/lua/src)
	add_subdirectory(lib/lua)
endif()
opt">= assert(loadfile(profiler_path .. "instrumentation.lua"))(profiler, sampler, get_bool_default) local reporter = dofile(profiler_path .. "reporter.lua") profiler.instrument = instrumentation.instrument --- -- Delayed registration of the /profiler chat command -- Is called later, after `core.register_chatcommand` was set up. -- function profiler.init_chatcommand() local instrument_profiler = get_bool_default("instrument.profiler", false) if instrument_profiler then instrumentation.init_chatcommand() end local param_usage = "print [filter] | dump [filter] | save [format [filter]] | reset" core.register_chatcommand("profiler", { description = "handle the profiler and profiling data", params = param_usage, privs = { server=true }, func = function(name, param) local command, arg0 = string.match(param, "([^ ]+) ?(.*)") local args = arg0 and string.split(arg0, " ") if command == "dump" then core.log("action", reporter.print(sampler.profile, arg0)) return true, "Statistics written to action log" elseif command == "print" then return true, reporter.print(sampler.profile, arg0) elseif command == "save" then return reporter.save(sampler.profile, args[1] or "txt", args[2]) elseif command == "reset" then sampler.reset() return true, "Statistics were reset" end return false, string.format( "Usage: %s\n" .. "Format can be one of txt, csv, lua, json, json_pretty (structures may be subject to change).", param_usage ) end }) if not instrument_profiler then instrumentation.init_chatcommand() end end sampler.init() instrumentation.init() return profiler