Skip to content

Commit 06453a8

Browse files
committed
libs: Make Lua a submodule and reuse the FreeType engine submodule.
1 parent 516986c commit 06453a8

File tree

5 files changed

+110
-25
lines changed

5 files changed

+110
-25
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@
1010
[submodule "libs/glm"]
1111
path = libs/glm
1212
url = https://github.com/Unvanquished/glm.git
13+
[submodule "libs/lua"]
14+
path = libs/lua
15+
url = https://github.com/Unvanquished/lua.git

CMakeLists.txt

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -87,29 +87,6 @@ if ((BUILD_GAME_NATIVE_DLL OR BUILD_GAME_NATIVE_EXE OR NACL) AND (BUILD_CGAME OR
8787
set(BUILDING_ANY_GAMELOGIC 1)
8888
endif()
8989

90-
#########################################
91-
# Externally built library dependencies #
92-
#########################################
93-
if (NACL)
94-
set(FREETYPE_LIBRARY ${DEPS_DIR}/pnacl_deps/lib/libfreetype.a)
95-
set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY} ${DEPS_DIR}/pnacl_deps/lib/libpng16.a)
96-
set(FREETYPE_INCLUDE_DIRS ${DEPS_DIR}/pnacl_deps/include/freetype2)
97-
set(LUA_INCLUDE_DIR ${DEPS_DIR}/pnacl_deps/include)
98-
set(LUA_LIBRARY ${DEPS_DIR}/pnacl_deps/lib/liblua.a)
99-
elseif (BUILDING_ANY_GAMELOGIC)
100-
find_package(Lua REQUIRED)
101-
102-
if (BUILD_CGAME)
103-
# Freetype (RmlUi dependency)
104-
find_package(Freetype REQUIRED)
105-
if (APPLE OR WIN32)
106-
find_package(ZLIB REQUIRED)
107-
set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARIES} ${ZLIB_LIBRARIES})
108-
endif()
109-
endif()
110-
endif()
111-
include_directories(${LUA_INCLUDE_DIR})
112-
11390
##################################
11491
# Libraries we build from source #
11592
##################################
@@ -122,13 +99,28 @@ set(NACL_VM_INHERITED_OPTIONS ${NACL_VM_INHERITED_OPTIONS} RC_MAX_LAYERS RC_MAX_
12299

123100
if (BUILDING_ANY_GAMELOGIC)
124101
if (BUILD_CGAME)
125-
# Freetype
102+
# Freetype (RmlUi dependency), already found for a native game when the client is built.
103+
if (NACL)
104+
include(${DAEMON_DIR}/freetype.cmake)
105+
elseif (NOT BUILD_CLIENT)
106+
prefer_package(Freetype ${DAEMON_DIR}/freetype.cmake)
107+
108+
if (Freetype_FOUND AND (APPLE OR WIN32))
109+
find_package(ZLIB REQUIRED)
110+
set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARIES} ${ZLIB_LIBRARIES})
111+
endif()
112+
endif()
113+
126114
include_directories(${FREETYPE_INCLUDE_DIRS})
127115

128116
# RmlUi
129117
include(${CMAKE_CURRENT_SOURCE_DIR}/rmlui.cmake)
130118
endif()
131119

120+
# Lua
121+
prefer_package(Lua ${CMAKE_CURRENT_SOURCE_DIR}/lua.cmake)
122+
include_directories(${LUA_INCLUDE_DIR})
123+
132124
# Fastlz
133125
add_library(srclibs-fastlz EXCLUDE_FROM_ALL ${FASTLZLIST})
134126
set_target_properties(srclibs-fastlz PROPERTIES POSITION_INDEPENDENT_CODE ${GAME_PIE} FOLDER "libs")

libs/lua

Submodule lua added at 1ab3208

lua.cmake

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
set(LUA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs/lua)
2+
3+
set(LUA_INCLUDE_DIR ${LUA_DIR})
4+
5+
set(LUA_SRC_FILES
6+
${LUA_DIR}/lapi.c
7+
${LUA_DIR}/lapi.h
8+
${LUA_DIR}/lauxlib.c
9+
${LUA_DIR}/lauxlib.h
10+
${LUA_DIR}/lbaselib.c
11+
${LUA_DIR}/lcode.c
12+
${LUA_DIR}/lcode.h
13+
${LUA_DIR}/lcorolib.c
14+
${LUA_DIR}/lctype.c
15+
${LUA_DIR}/lctype.h
16+
${LUA_DIR}/ldblib.c
17+
${LUA_DIR}/ldebug.c
18+
${LUA_DIR}/ldebug.h
19+
${LUA_DIR}/ldo.c
20+
${LUA_DIR}/ldo.h
21+
${LUA_DIR}/ldump.c
22+
${LUA_DIR}/lfunc.c
23+
${LUA_DIR}/lfunc.h
24+
${LUA_DIR}/lgc.c
25+
${LUA_DIR}/lgc.h
26+
${LUA_DIR}/linit.c
27+
${LUA_DIR}/liolib.c
28+
${LUA_DIR}/ljumptab.h
29+
${LUA_DIR}/llex.c
30+
${LUA_DIR}/llex.h
31+
${LUA_DIR}/llimits.h
32+
${LUA_DIR}/lmathlib.c
33+
${LUA_DIR}/lmem.c
34+
${LUA_DIR}/lmem.h
35+
${LUA_DIR}/loadlib.c
36+
${LUA_DIR}/lobject.c
37+
${LUA_DIR}/lobject.h
38+
${LUA_DIR}/lopcodes.c
39+
${LUA_DIR}/lopcodes.h
40+
${LUA_DIR}/lopnames.h
41+
${LUA_DIR}/loslib.c
42+
${LUA_DIR}/lparser.c
43+
${LUA_DIR}/lparser.h
44+
${LUA_DIR}/lprefix.h
45+
${LUA_DIR}/lstate.c
46+
${LUA_DIR}/lstate.h
47+
${LUA_DIR}/lstring.c
48+
${LUA_DIR}/lstring.h
49+
${LUA_DIR}/lstrlib.c
50+
${LUA_DIR}/ltable.c
51+
${LUA_DIR}/ltable.h
52+
${LUA_DIR}/ltablib.c
53+
# ${LUA_DIR}/ltests.c
54+
# ${LUA_DIR}/ltests.h
55+
${LUA_DIR}/ltm.c
56+
${LUA_DIR}/ltm.h
57+
# ${LUA_DIR}/lua.c
58+
${LUA_DIR}/luaconf.h
59+
${LUA_DIR}/lua.h
60+
${LUA_DIR}/lualib.h
61+
${LUA_DIR}/lundump.c
62+
${LUA_DIR}/lundump.h
63+
${LUA_DIR}/lutf8lib.c
64+
${LUA_DIR}/lvm.c
65+
${LUA_DIR}/lvm.h
66+
${LUA_DIR}/lzio.c
67+
${LUA_DIR}/lzio.h
68+
# ${LUA_DIR}/onelua.c
69+
)
70+
71+
set(LUA_LIBRARY srclibs-lua)
72+
73+
add_library(${LUA_LIBRARY} STATIC ${LUA_SRC_FILES})
74+
75+
unset(LUA_DEFINITIONS)
76+
77+
if (NACL AND USE_NACL_SAIGO)
78+
# Workaround for this Saigo Clang internal error:
79+
# > fatal error: error in backend: Cannot select: t21: ch = brind t20, t19
80+
# > error: Not enough scratch registers when expanding indirect jump.
81+
# See: https://github.com/Unvanquished/Unvanquished/pull/3195#issuecomment-2484530883
82+
list(APPEND LUA_DEFINITIONS LUA_USE_JUMPTABLE=0)
83+
endif()
84+
85+
set_target_properties(${LUA_LIBRARY} PROPERTIES
86+
POSITION_INDEPENDENT_CODE ${GAME_PIE}
87+
COMPILE_DEFINITIONS "${LUA_DEFINITIONS}"
88+
FOLDER "libs"
89+
)

0 commit comments

Comments
 (0)