Skip to content

Commit

Permalink
meson add mingw build support
Browse files Browse the repository at this point in the history
  • Loading branch information
ankith26 committed Nov 23, 2023
1 parent d981699 commit fbb8b89
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
22 changes: 19 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ else
endif

cc = meson.get_compiler('c')
if plat == 'win' and cc.get_id() != 'msvc' and get_option('win_force_msvc')
error('Tried to compile with a non-msvc compiler when msvc is forced')
endif

fs = import('fs')

py = import('python').find_installation(pure: false)
Expand All @@ -55,7 +59,6 @@ pg_lib_dirs = []
sdl_image_extra_links = []
if (
plat == 'win'
and cc.get_argument_syntax() == 'msvc'
and host_machine.cpu_family().startswith('x86')
)
# yes, this is a bit ugly and hardcoded but it is what it is
Expand Down Expand Up @@ -105,12 +108,12 @@ if (
'libpng',
output: 'libpng16-16.lib',
input: [libpng_def, sdl_image_lib_dir / 'libpng16-16.dll'],
command: [
command: cc.get_argument_syntax() == 'msvc' ? [
'lib',
'/def:' + libpng_def,
'/machine:' + arch_suffix,
'/out:@OUTPUT@',
]
] : ['dlltool', '-k', '--output-lib', '@OUTPUT@', '--def', libpng_def]
)

# SDL2_mixer
Expand Down Expand Up @@ -139,6 +142,19 @@ if (
pg_lib_dirs += common_lib_dir
dlls += [common_lib_dir / 'freetype.dll', common_lib_dir / 'portmidi.dll']

# clean unneeded file that causes build issues
unneeded_file = common_lib_dir / 'libportmidi.dll.a'
if fs.exists(unneeded_file)
run_command(
[
find_program('python3', 'python'),
'-c',
'import os; os.remove("@0@")'.format(unneeded_file),
],
check: true,
)
endif

# put dlls in root of install
install_data(dlls, install_dir: pg_dir)
else
Expand Down
5 changes: 5 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ option('stripped', type: 'boolean', value: 'false')
# Controls whether to compile with -Werror (or its msvc equivalent). The default
# behaviour is to not do this by default
option('error_on_warns', type: 'boolean', value: 'false')

# Controls whether to error on windows when a non msvc compiler is used. The
# default behaviour is to not (and hence, the build can make use of something
# like mingw). This option is ignored on other platforms.
option('win_force_msvc', type: 'boolean', value: 'false')
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ build-backend = 'mesonpy'
# setup = ["-Derror_on_warns=true"]

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

0 comments on commit fbb8b89

Please sign in to comment.