-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootstrap.lua
More file actions
executable file
·104 lines (89 loc) · 3.24 KB
/
bootstrap.lua
File metadata and controls
executable file
·104 lines (89 loc) · 3.24 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
#!/usr/bin/env -S lua
-- This script bootstrapps civ.lua.
-- Run this to test and build the initial civ command.
local sfmt = string.format
local io_open = io.open
local src = debug.getinfo(1).source
local D = src:match'@?(.*)bootstrap%.lua$'
print(sfmt('running bootstrap.lua in dir %q', D))
assert(not os.execute'ls lua*.core', 'lua.*core file found!')
assert(not MAIN, 'bootstrap.lua must not be used as a library')
MAIN = {}
NOLIB, BOOTSTRAP = true, true
LUA_SETUP = os.getenv'LUA_SETUP' or 'vt100'
local function preload(name, path)
package.loaded[name] = dofile(D..path)
end
-- LOGLEVEL = tonumber(os.getenv'LOGLEVEL') or 4
-- LOGFN = function(lvl, msg) if LOGLEVEL >= lvl then
-- io.stderr:write(sfmt('LOG(%s): %s\n', lvl, msg))
-- end end
print'[[load]]'
preload('metaty', 'lib/metaty/metaty.lua')
require'metaty'.setup()
preload('metaty.freeze', 'lib/metaty/freeze.lua')
-- needed for civtest and related tests
preload('shim', 'lib/shim/shim.lua')
preload('fmt', 'lib/fmt/fmt.lua')
preload('fmt.binary', 'lib/fmt/binary.lua')
preload('ds', 'lib/ds/ds.lua')
preload('ds.time', 'lib/ds/time.lua')
preload('ds.heap', 'lib/ds/heap.lua')
preload('ds.path', 'lib/ds/path.lua')
preload('ds.log', 'lib/ds/log.lua')
preload('ds.load', 'lib/ds/load.lua')
preload('ds.Iter', 'lib/ds/Iter.lua')
preload('ds.Grid', 'lib/ds/Grid.lua')
-- TODO: move out of ds/test.lua
preload('ds.utf8', 'lib/ds/utf8.lua')
preload('ds.LL', 'lib/ds/LL.lua')
preload('ds.IFile', 'lib/ds/IFile.lua')
preload('luk', 'lib/luk/luk.lua')
preload('lap', 'lib/lap/lap.lua')
preload('civix', 'lib/civix/civix.lua')
preload('lines', 'lib/lines/lines.lua')
preload('lines.diff', 'lib/lines/diff.lua')
preload('lines.Gap', 'lib/lines/Gap.lua')
preload('lines.Writer', 'lib/lines/Writer.lua')
preload('lines.U3File', 'lib/lines/U3File.lua')
preload('lines.futils', 'lib/lines/futils.lua')
preload('lines.File', 'lib/lines/File.lua')
preload('lines.EdFile', 'lib/lines/EdFile.lua')
preload('pod', 'lib/pod/pod.lua')
preload('lson', 'lib/lson/lson.lua')
preload('civtest', 'lib/civtest/civtest.lua')
preload('asciicolor', 'lib/asciicolor/asciicolor.lua')
preload('vt100', 'lib/vt100/vt100.lua')
preload('vt100.AcWriter', 'lib/vt100/AcWriter.lua')
preload('civ.core', 'cmd/civ/core.lua')
preload('civ.Worker', 'cmd/civ/Worker.lua')
preload('civ', 'cmd/civ/civ.lua')
-- Additional
preload('lson', 'lib/lson/lson.lua')
preload('ds.testing', 'lib/ds/testing/testing.lua')
preload('pod.testing', 'lib/pod/testing/testing.lua')
preload('lines.testing', 'lib/lines/testing/testing.lua')
require'vt100'.setup()
io.fmt:styled('notify', 'Running bootstrap.lua:', ' ');
io.fmt(G.arg); io.fmt:write'\n'
local core = require'civ.core'
local function bootTest()
print'[[test]]'
-- setup and run tests
local log = require'ds.log'
LOGFN = log.logFn; log.setLevel()
local L = D..'lib/'
for _, libtest in ipairs(dofile(L..'boot_tests.luk')) do
dofile(L..libtest)
end
dofile(D..'cmd/civ/test_civ.lua')
io.fmt:styled('notify', 'boot-test done', '\n')
io.fmt:flush()
end
local function main()
G.MAIN = nil; dofile(D..'cmd/civ/civ.lua')
end
if arg[1] == 'boot-test' then
return bootTest()
end
main()