forked from Ancurio/mkxp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeson.build
198 lines (166 loc) · 6.01 KB
/
meson.build
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
project('mkxp-z', 'c', 'cpp', 'objc', 'objcpp', version: '1.3.0', meson_version: '>=0.47.0', default_options: ['cpp_std=c++11', 'buildtype=release', 'warning_level=0'])
minimum_macos_version = get_option('macos_min_version')
xxd = find_program('xxd', native: true)
objfw = find_program('objfw-config', native: true)
host_system = host_machine.system()
compilers = {'cpp': meson.get_compiler('cpp'), 'objc': meson.get_compiler('objc'), 'objcpp': meson.get_compiler('objcpp')}
if compilers['objc'].get_id() != 'clang' or compilers['objcpp'].get_id() != 'clang' or compilers['cpp'].get_id() != 'clang'
error('This program must be built with Clang! ( export CC=clang OBJC=clang CXX=clang++ OBJCXX=clang++ )')
endif
global_sources = []
global_dependencies = []
global_include_dirs = []
global_args = []
global_link_args = []
sizeof = {'void*': compilers['cpp'].sizeof('void*'),
'long': compilers['cpp'].sizeof('long')
}
win64 = (sizeof['void*'] != sizeof['long'])
# ====================
# Ext libs
# ====================
# STEAMWORKS
steamworks = false
steamworks_path = get_option('steamworks_path')
if steamworks_path != ''
libname = 'steam_api'
if host_system == 'linux'
if sizeof['void*'] == 4
bindir = 'linux32'
else
bindir = 'linux64'
endif
elif host_system == 'windows'
if win64 == true
bindir = 'win64'
libname += '64'
else
bindir = ''
endif
else
bindir = 'osx'
endif
steam_libpath = steamworks_path + '/redistributable_bin/' + bindir
steamlib = compilers['cpp'].find_library(libname, required: false, dirs: [steam_libpath])
if steamlib.found() == true
global_include_dirs += include_directories('steamshim')
global_args += '-DHAVE_STEAMSHIM'
global_sources += 'steamshim/steamshim_child.c'
steamworks = true
endif
endif
# BOOST UNORDERED
global_include_dirs += include_directories('boost-unordered')
# ====================
# Main source
# ====================
# Suppress warnings
global_args += ['-Wno-non-virtual-dtor', '-Wno-reorder', '-Wno-uninitialized', '-Wno-unknown-pragmas', '-Wno-unknown-warning-option']
if compilers['objc'].get_id() == 'clang'
global_args += ['-Wno-undefined-var-template', '-Wno-delete-non-abstract-non-virtual-dtor']
endif
if host_system == 'windows'
global_args += '-Wno-unknown-attributes'
endif
# Decide whether or not to use MiniFFI
miniffi = get_option('use_miniffi')
if miniffi == true
if win64 != true
miniffi = true
global_args += '-DUSE_MINIFFI'
else
warning('64-bit MiniFFI is only supported on Linux and macOS.')
warning('To use MiniFFI/Win32API on Windows, target 32-bit.')
miniffi = false
endif
endif
# Defines
if get_option('workdir_current')
global_args += '-DWORKDIR_CURRENT'
endif
if get_option('independent_appimage')
global_args += '-DINDEPENDENT_APPIMAGE'
endif
if get_option('easypoke') == true and miniffi == true
global_args += '-DEASY_POKE'
endif
if not get_option('console')
global_args += '-DNO_CONSOLE'
endif
if get_option('mk')
global_args += '-DMARIN'
endif
build_static = false
if get_option('static_executable') == true and host_system == 'windows'
build_static = true
endif
# This MUST be disabled if building for macOS >= 10.15
if get_option('threaded_gl_init')
global_args += '-DTHREADED_GLINIT'
endif
# Objectify our C
global_args += run_command(objfw,'--cppflags').stdout().split()
add_project_arguments(run_command(objfw,'--objcflags').stdout().split(), language:['objc','objcpp'])
add_project_link_arguments(run_command(objfw,'--libs','--ldflags').stdout().split(), language:['objc','objcpp'])
# Make sure to use ARC
add_project_arguments(run_command(objfw,'--arc').stdout().split(), language:['objc','objcpp'])
if host_system != 'darwin'
add_project_arguments('-fobjc-runtime=objfw', language:['objc','objcpp'])
endif
# (Fix cquery thinking ObjC headers are C++ headers in VSCode)
add_project_arguments('-ObjC', language:'objc')
add_project_arguments('-ObjC++', language:'objcpp')
subdir('src')
subdir('binding')
subdir('shader')
subdir('assets')
subdir('scripts')
global_include_dirs += include_directories('src', 'binding')
if host_system == 'windows'
subdir('windows')
global_sources += windows_resources
global_include_dirs += include_directories('windows')
elif host_system == 'darwin'
subdir('macos')
add_project_arguments('-stdlib=libc++', language: ['cpp','objcpp'])
add_project_arguments('-std=c++11', language: 'objcpp') # Meson's cpp_std doesn't work on ObjC for some reason
add_project_arguments('-mmacosx-version-min='+minimum_macos_version, language: ['cpp', 'objc', 'objcpp'])
add_project_link_arguments('-mmacosx-version-min='+minimum_macos_version, language: ['cpp', 'objc', 'objcpp'])
else
subdir('linux')
add_project_arguments('-std=c++11', language: 'objcpp')
endif
exe_name = meson.project_name()
if steamworks == true
exe_name = meson.project_name() + '_rt'
la = ''
if build_static == true
la = '-static'
endif
shim_args = ['-DGAME_LAUNCH_NAME="' + exe_name + '"']
if get_option('steam_appid') != ''
shim_args += '-DSTEAM_APPID=' + get_option('steam_appid')
endif
if get_option('console') == true
shim_args += '-DSTEAMSHIM_DEBUG'
endif
executable(meson.project_name(),
sources: files('steamshim/steamshim_parent.cpp'),
dependencies: steamlib,
include_directories: (steamworks_path + '/public'),
cpp_args: shim_args,
link_args: la.split(),
gui_app: (get_option('console') == false),
install: (host_system != 'windows'))
endif
executable(exe_name,
sources: global_sources,
dependencies: global_dependencies,
include_directories: global_include_dirs,
link_args: global_link_args,
cpp_args: global_args,
objc_args: global_args,
objcpp_args: global_args,
gui_app: (get_option('console') == false),
install: (host_system != 'windows')
)