This repository has been archived by the owner on Dec 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconf.lua
84 lines (70 loc) · 2.38 KB
/
conf.lua
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
----
-- Copyright (C) 2018 by Fabian Mueller <[email protected]>
-- SPDX-License-Identifier: GPL-2.0+
----
-- @file
-- Executed by the love2d engine before all other files.
-- used to configure the moonscript search pathes and loading moonscript.
-- At last we register our config function here which is later called for
-- seting up the engine's parameters.
-- todo reenable jit after the segmentation fault is fixed
-- todo add link to bug report here
jit.off()
-- this is the bare minimum to load the next file
local shared_path = {
"wesnoth",
"wesnoth/shared",
"wesnoth/shared/lib",
"wesnoth/shared/lib/moonscript",
"wesnoth/shared/lib/Penlight/lua"
}
local setRequirePath = require'wesnoth.shared.setRequirePath'
setRequirePath(shared_path)
-- Copy the lualibs (only lpeg for now) into the savedir.
-- This makes sure love2d can find it without relying on os specific mechanisms.
-- This is espacially needed when running in fuse mode, since libs can't be loaded
-- from within zip files.
local system = require'love.system'
local osString = system.getOS()
local srcPath, dstPath
if osString == 'OS X' then
srcPath = 'wesnoth/shared/lib/macosx/lpeg.so'
dstPath = 'lib/lpeg.so'
end
if osString == 'Windows' then
srcPath = 'wesnoth/shared/lib/windows/lpeg.dll'
dstPath = 'lib/lpeg.dll'
end
if osString == 'Linux' then
srcPath = 'wesnoth/shared/lib/linux/lpeg.so'
dstPath = 'lib/lpeg.so'
end
local filesystem = require'love.filesystem'
-- todo take from a global
filesystem.setIdentity('wesnoth')
if not filesystem.getInfo(dstPath) then
local success
success = filesystem.createDirectory('lib')
if not success then
print('could not create lib dir')
end
local container = 'data'
local data, error = filesystem.read(container, srcPath)
if not data then
print(error)
else
local message
success, message = filesystem.write(dstPath, data)
if not success then
print(message)
end
end
end
-- First set the lua searchpath of love to our needs, then require moonscript,
-- which registers its own loader (for files with the .moon extension)
-- with the luapathes rewriten for moonscript.
filesystem.setCRequirePath('lib/??')
require"moonscript"
-- Register the love.conf function after requireing moonscript,
-- since the function's file could already miss a lua counterpart.
require"client.conf"