-
Notifications
You must be signed in to change notification settings - Fork 43
/
examples_building_lua.dox
202 lines (148 loc) · 4.43 KB
/
examples_building_lua.dox
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*! \page examples_building_lua Examples: Building Lua
\section examples_building_lua_setup Building Lua (5.4)
In this example, we are going to quickly build Lua using Jam.
First, download Lua from http://lua.org/. Expand it into a directory, and change to the expanded Lua directory's <tt>src/</tt> folder.
\code
[lua] cd src
[lua/src]
\endcode
\subsection examples_building_lua_quick Building without a Jamfile
\code
# Build the Lua executable by globbing all *.c file but removing luac.c from the list.
# Both lua.c and luac.c provide main() functions, and we only want one.
[lua/src] jam lua *[email protected]
# Clean the Lua executable and intermediates. As there is no Jamfile.jam in the directory,
# the same wildcard file hint used in the build above must be provided to the clean target.
[lua/src] jam clean:lua *[email protected]
\endcode
<hr>
\subsection examples_building_lua_jamfile_static Building a statically-linked Lua with a Jamfile
In this example, we'll create a Jamfile to build both Lua and LuaC using Jam.
Create a <tt>Jamfile.jam</tt> with the following contents:
\code
# Annoyingly, because "lua" is a keyword in Jam, "lua" must be quoted as the target name for C.Application.
# Also annoyingly, luac.c must be removed from the list with a recursive wildcard.
# This will be fixed in the future.
# Provide the build instructions for the lua target.
C.ExcludeFromBuild "lua" : luac.c ;
C.OutputPath "lua" : . ;
C.Application "lua" : *.c@-**/luac.c ;
# or replace both lines with:
# C.Application "lua" : *.c@-**/luac.c ;
# Provide the build instructions for the luac target.
C.ExcludeFromBuild luac : lua.c ;
C.OutputPath luac : . ;
C.Application luac : *.c ;
# or replace both lines with:
# C.Application luac : *.c@-**/lua.c ;
\endcode
From the command-line, build Lua with:
\code
# Build both lua and luac.
[lua/src] jam
# Build both lua and luac.
[lua/src] jam all
# Build just lua.
[lua/src] jam lua
# Build just luac.
[lua/src] jam luac
\endcode
After the build is complete, a <tt>lua.exe</tt> (and, possibly, <tt>luac.exe</tt>) will exist in the <tt>lua/src</tt> directory. Additionally, build intermediates can be found in the <tt>lua/src/.build/</tt> directory.
Clean Lua with:
\code
# Clean everything.
[~/lua/src] jam clean
# OR clean just the lua target.
[~/lua/src] jam clean:lua
# OR clean just the luac target.
[~/lua/src] jam clean:luac
\endcode
<hr>
\subsection examples_building_lua_jamfile_static Building a dynamically-linked Lua 5.4 with a Jamfile
In this example, we'll create a Jamfile to build Lua 5.4 using Jam.
Create a <tt>lua/src/Jamfile.jam</tt> with the following contents:
\code
# List out the source files individually for this example.
# A wildcard such as this could have been used:
# *@-**/lua.c@-**/luac.c
local LUA54_SRCS =
lapi.c
lapi.h
lauxlib.c
lauxlib.h
lbaselib.c
lcode.c
lcode.h
lcorolib.c
lctype.c
lctype.h
ldblib.c
ldebug.c
ldebug.h
ldo.c
ldo.h
ldump.c
lfunc.c
lfunc.h
lgc.c
lgc.h
linit.c
liolib.c
llex.c
llex.h
llimits.h
lmathlib.c
lmem.c
lmem.h
loadlib.c
lobject.c
lobject.h
lopcodes.c
lopcodes.h
loslib.c
lparser.c
lparser.h
lstate.c
lstate.h
lstring.c
lstring.h
lstrlib.c
ltable.c
ltable.h
ltablib.c
ltm.c
ltm.h
lua.h
lua.hpp
luaconf.h
lualib.h
lundump.c
lundump.h
lutf8lib.c
lvm.c
lvm.h
lzio.c
lzio.h
;
# Tell Lua's code to export the appropriate functions to the DLL.
C.Defines lua54 : LUA_BUILD_AS_DLL ;
# Write lua54.dll into the current directory.
C.OutputPath lua54 : . ;
C.Library lua54 : $(LUA54_SRCS) : shared ;
# Build lua.exe into the current directory.
C.OutputPath "lua" : . ;
# Link against the target lua54.
C.LinkLibraries "lua" : lua54 ;
C.Application "lua" : lua.c ;
\endcode
From the command-line, build Lua with:
\code
[lua/src] jam
\endcode
After the build is complete, a <tt>lua.exe</tt> and <tt>lua54.dll</tt> (or your platform equivalent) will reside in the <tt>lua/src</tt> directory. Build intermediates can be found in the <tt>lua/src/.build/</tt> directory.
Clean Lua with:
\code
# Clean everything.
[lua/src] jam clean
\endcode
*/