blob: b7e0e301425a4b3cc5e728b8dc64a13695fa7770 (
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
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
add_library(script_api
INTERFACE
)
# Get script_window.hpp dependencies
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/script_window.hpp.in ENUM_LINES REGEX "@enum")
foreach(ENUM IN LISTS ENUM_LINES)
string(REGEX REPLACE ".* ([^ @]+)@.*" "\\1" FILE_PATTERN "${ENUM}")
file(GLOB FILENAMES "${FILE_PATTERN}")
list(APPEND DEPENDENCIES ${FILENAMES})
endforeach()
list(REMOVE_DUPLICATES DEPENDENCIES)
# Add a command to generate script_window.hpp
add_custom_command_timestamp(OUTPUT ${CMAKE_BINARY_DIR}/generated/script/api/script_window.hpp
COMMAND ${CMAKE_COMMAND}
-DGENERATE_SOURCE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/script_window.hpp.in
-DGENERATE_BINARY_FILE=${CMAKE_BINARY_DIR}/generated/script/api/script_window.hpp
-P ${CMAKE_SOURCE_DIR}/cmake/scripts/GenerateWidget.cmake
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/script_window.hpp.in
DEPENDS ${CMAKE_SOURCE_DIR}/cmake/scripts/GenerateWidget.cmake ${DEPENDENCIES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating script_window.hpp"
)
add_custom_target_timestamp(script_window
DEPENDS
${CMAKE_BINARY_DIR}/generated/script/api/script_window.hpp
)
target_include_directories(script_api
INTERFACE
${CMAKE_BINARY_DIR}/generated/script/api/
${CMAKE_CURRENT_SOURCE_DIR}
)
file(GLOB SCRIPT_API_FILES "script_*.hpp")
list(APPEND SCRIPT_API_FILES ${CMAKE_BINARY_DIR}/generated/script/api/script_window.hpp)
foreach(API "ai;AI" "game;GS" "template;Template")
list(GET API 0 APILC)
list(GET API 1 APIUC)
foreach(SCRIPT_API_FILE IN LISTS SCRIPT_API_FILES)
if("${SCRIPT_API_FILE}" MATCHES ".*script_controller.*")
continue()
endif()
get_filename_component(SCRIPT_API_FILE_NAME "${SCRIPT_API_FILE}" NAME)
string(REPLACE "script_" "${APILC}_" SCRIPT_API_FILE_NAME "${SCRIPT_API_FILE_NAME}")
set(SCRIPT_API_BINARY_FILE "${CMAKE_BINARY_DIR}/generated/script/api/${APILC}/${SCRIPT_API_FILE_NAME}.sq")
add_custom_command_timestamp(OUTPUT ${SCRIPT_API_BINARY_FILE}
COMMAND ${CMAKE_COMMAND}
-DSCRIPT_API_SOURCE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/squirrel_export.hpp.sq.in
-DSCRIPT_API_BINARY_FILE=${SCRIPT_API_BINARY_FILE}
-DSCRIPT_API_FILE=${SCRIPT_API_FILE}
-DAPIUC=${APIUC}
-DAPILC=${APILC}
-P ${CMAKE_SOURCE_DIR}/cmake/scripts/SquirrelExport.cmake
MAIN_DEPENDENCY ${SCRIPT_API_FILE}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/squirrel_export.hpp.sq.in
${CMAKE_SOURCE_DIR}/cmake/scripts/SquirrelExport.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating ${APILC}/${SCRIPT_API_FILE_NAME}.sq"
)
list(APPEND SCRIPT_${APIUC}_BINARY_FILES ${SCRIPT_API_BINARY_FILE})
endforeach()
add_custom_target_timestamp(script_${APILC}
DEPENDS
${SCRIPT_${APIUC}_BINARY_FILES}
)
add_dependencies(script_${APILC}
script_window
)
if(NOT "${APILC}" STREQUAL "template")
list(APPEND SCRIPT_${APIUC}_BINARY_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${APILC}/${APILC}_controller.hpp.sq")
set(INCLUDES_BINARY_FILE "${CMAKE_BINARY_DIR}/generated/script/api/${APILC}/${APILC}_includes.hpp")
add_custom_command_timestamp(OUTPUT ${INCLUDES_BINARY_FILE}
COMMAND ${CMAKE_COMMAND}
-DINCLUDES_SOURCE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/script_includes.hpp.in
-DINCLUDES_BINARY_FILE=${INCLUDES_BINARY_FILE}
-DAPIUC=${APIUC}
-DAPILC=${APILC}
-P ${CMAKE_SOURCE_DIR}/cmake/scripts/SquirrelIncludes.cmake
--
${SCRIPT_${APIUC}_BINARY_FILES}
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/script_includes.hpp.in
DEPENDS ${SCRIPT_${APIUC}_BINARY_FILES}
${CMAKE_SOURCE_DIR}/cmake/scripts/SquirrelIncludes.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating ${APILC}/${APILC}_includes.hpp"
)
add_custom_target_timestamp(script_${APILC}_includes
DEPENDS
${INCLUDES_BINARY_FILE}
)
add_dependencies(script_${APILC}_includes
script_${APILC}
)
add_dependencies(script_api
script_${APILC}_includes
)
# Documentation
if(DOXYGEN_EXECUTABLE)
add_custom_target(docs_${APILC}
${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/docs
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile_${APIUC}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating documentation for ${APILC} API"
)
add_dependencies(docs_${APILC}
find_version
script_window
)
add_dependencies(docs
docs_${APILC}
)
endif()
else()
add_dependencies(script_api
script_${APILC}
)
endif()
target_include_directories(script_api
INTERFACE
${CMAKE_BINARY_DIR}/generated/script
${CMAKE_BINARY_DIR}/generated/script/api/${APILC}
${CMAKE_CURRENT_SOURCE_DIR}/${APILC}
)
endforeach()
if(OPTION_TOOLS_ONLY)
return()
endif()
add_library(openttd::script_api ALIAS script_api)
add_files(
ai_changelog.hpp
game_changelog.hpp
script_accounting.hpp
script_admin.hpp
script_airport.hpp
script_base.hpp
script_basestation.hpp
script_bridge.hpp
script_bridgelist.hpp
script_cargo.hpp
script_cargolist.hpp
script_cargomonitor.hpp
script_client.hpp
script_clientlist.hpp
script_company.hpp
script_companymode.hpp
script_controller.hpp
script_date.hpp
script_depotlist.hpp
script_engine.hpp
script_enginelist.hpp
script_error.hpp
script_event.hpp
script_event_types.hpp
script_execmode.hpp
script_game.hpp
script_gamesettings.hpp
script_goal.hpp
script_group.hpp
script_grouplist.hpp
script_industry.hpp
script_industrylist.hpp
script_industrytype.hpp
script_industrytypelist.hpp
script_info_docs.hpp
script_infrastructure.hpp
script_list.hpp
script_log.hpp
script_map.hpp
script_marine.hpp
script_newgrf.hpp
script_news.hpp
script_object.hpp
script_objecttype.hpp
script_objecttypelist.hpp
script_order.hpp
script_priorityqueue.hpp
script_rail.hpp
script_railtypelist.hpp
script_road.hpp
script_roadtypelist.hpp
script_sign.hpp
script_signlist.hpp
script_station.hpp
script_stationlist.hpp
script_story_page.hpp
script_storypagelist.hpp
script_storypageelementlist.hpp
script_subsidy.hpp
script_subsidylist.hpp
script_testmode.hpp
script_text.hpp
script_tile.hpp
script_tilelist.hpp
script_town.hpp
script_townlist.hpp
script_tunnel.hpp
script_types.hpp
script_vehicle.hpp
script_vehiclelist.hpp
script_viewport.hpp
script_waypoint.hpp
script_waypointlist.hpp
script_accounting.cpp
script_admin.cpp
script_airport.cpp
script_base.cpp
script_basestation.cpp
script_bridge.cpp
script_bridgelist.cpp
script_cargo.cpp
script_cargolist.cpp
script_cargomonitor.cpp
script_client.cpp
script_clientlist.cpp
script_company.cpp
script_companymode.cpp
script_controller.cpp
script_date.cpp
script_depotlist.cpp
script_engine.cpp
script_enginelist.cpp
script_error.cpp
script_event.cpp
script_event_types.cpp
script_execmode.cpp
script_game.cpp
script_gamesettings.cpp
script_goal.cpp
script_group.cpp
script_grouplist.cpp
script_industry.cpp
script_industrylist.cpp
script_industrytype.cpp
script_industrytypelist.cpp
script_infrastructure.cpp
script_list.cpp
script_log.cpp
script_map.cpp
script_marine.cpp
script_newgrf.cpp
script_news.cpp
script_object.cpp
script_objecttype.cpp
script_objecttypelist.cpp
script_order.cpp
script_priorityqueue.cpp
script_rail.cpp
script_railtypelist.cpp
script_road.cpp
script_roadtypelist.cpp
script_sign.cpp
script_signlist.cpp
script_station.cpp
script_stationlist.cpp
script_story_page.cpp
script_storypagelist.cpp
script_storypageelementlist.cpp
script_subsidy.cpp
script_subsidylist.cpp
script_testmode.cpp
script_text.cpp
script_tile.cpp
script_tilelist.cpp
script_town.cpp
script_townlist.cpp
script_tunnel.cpp
script_vehicle.cpp
script_vehiclelist.cpp
script_viewport.cpp
script_waypoint.cpp
script_waypointlist.cpp
script_window.cpp
)
|