Skip to content

Commit fbb8b89

Browse files
committed
meson add mingw build support
1 parent d981699 commit fbb8b89

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

meson.build

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ else
3737
endif
3838

3939
cc = meson.get_compiler('c')
40+
if plat == 'win' and cc.get_id() != 'msvc' and get_option('win_force_msvc')
41+
error('Tried to compile with a non-msvc compiler when msvc is forced')
42+
endif
43+
4044
fs = import('fs')
4145

4246
py = import('python').find_installation(pure: false)
@@ -55,7 +59,6 @@ pg_lib_dirs = []
5559
sdl_image_extra_links = []
5660
if (
5761
plat == 'win'
58-
and cc.get_argument_syntax() == 'msvc'
5962
and host_machine.cpu_family().startswith('x86')
6063
)
6164
# yes, this is a bit ugly and hardcoded but it is what it is
@@ -105,12 +108,12 @@ if (
105108
'libpng',
106109
output: 'libpng16-16.lib',
107110
input: [libpng_def, sdl_image_lib_dir / 'libpng16-16.dll'],
108-
command: [
111+
command: cc.get_argument_syntax() == 'msvc' ? [
109112
'lib',
110113
'/def:' + libpng_def,
111114
'/machine:' + arch_suffix,
112115
'/out:@OUTPUT@',
113-
]
116+
] : ['dlltool', '-k', '--output-lib', '@OUTPUT@', '--def', libpng_def]
114117
)
115118

116119
# SDL2_mixer
@@ -139,6 +142,19 @@ if (
139142
pg_lib_dirs += common_lib_dir
140143
dlls += [common_lib_dir / 'freetype.dll', common_lib_dir / 'portmidi.dll']
141144

145+
# clean unneeded file that causes build issues
146+
unneeded_file = common_lib_dir / 'libportmidi.dll.a'
147+
if fs.exists(unneeded_file)
148+
run_command(
149+
[
150+
find_program('python3', 'python'),
151+
'-c',
152+
'import os; os.remove("@0@")'.format(unneeded_file),
153+
],
154+
check: true,
155+
)
156+
endif
157+
142158
# put dlls in root of install
143159
install_data(dlls, install_dir: pg_dir)
144160
else

meson_options.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ option('stripped', type: 'boolean', value: 'false')
2929
# Controls whether to compile with -Werror (or its msvc equivalent). The default
3030
# behaviour is to not do this by default
3131
option('error_on_warns', type: 'boolean', value: 'false')
32+
33+
# Controls whether to error on windows when a non msvc compiler is used. The
34+
# default behaviour is to not (and hence, the build can make use of something
35+
# like mingw). This option is ignored on other platforms.
36+
option('win_force_msvc', type: 'boolean', value: 'false')

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ build-backend = 'mesonpy'
5656
# setup = ["-Derror_on_warns=true"]
5757

5858
[tool.cibuildwheel.config-settings]
59-
setup-args = "-Derror_on_warns=true"
59+
setup-args = ["-Derror_on_warns=true", "-Dwin_force_msvc=true"]

0 commit comments

Comments
 (0)