Skip to content

Commit 4185990

Browse files
committed
Simplify the approach for constructing cross-build file.
1 parent 40ef8d2 commit 4185990

File tree

1 file changed

+9
-31
lines changed

1 file changed

+9
-31
lines changed

mesonpy/__init__.py

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -725,42 +725,20 @@ def __init__(
725725
family = 'aarch64' if arch == 'arm64' else arch
726726
subsystem = 'ios-simulator' if ios_ver.is_simulator else 'ios'
727727
min_ios_version = os.getenv('IPHONEOS_DEPLOYMENT_TARGET', ios_ver.release)
728-
729-
cflags = []
730-
for flag in shlex.split(sysconfig.get_config_var('CFLAGS')):
731-
# Ensure the iOS minimum version reflects the current build environment
732-
if flag.startswith('-mios-version-min='):
733-
cflags.append(f"-mios-version-min={min_ios_version}")
734-
# Don't propagate warning settings or preprocessor defines
735-
elif not (flag.startswith('-W') or flag.startswith('-D')):
736-
cflags.append(flag)
737-
738-
ldflags = []
739-
# BLDSHARED includes the linker as the first argument; we just need the flags.
740-
for flag in shlex.split(sysconfig.get_config_var('BLDSHARED'))[1:]:
741-
# Ensure the iOS minimum version reflects the current build environment
742-
if flag.startswith('-mios-version-min='):
743-
ldflags.append(f"-mios-version-min={min_ios_version}")
744-
# Don't propagate linking flags; those will be added by meson.
745-
elif flag not in {'-dynamiclib'}:
746-
ldflags.append(flag)
728+
prefix = sysconfig.get_config_var("prefix")
747729

748730
cross_file_data = textwrap.dedent(f'''
749731
[binaries]
750-
c = '{arch}-apple-{subsystem}-clang'
751-
cpp = '{arch}-apple-{subsystem}-clang++'
752-
objc = '{arch}-apple-{subsystem}-clang'
753-
objcpp = '{arch}-apple-{subsystem}-clang++'
754-
ar = '{arch}-apple-{subsystem}-ar'
732+
c = ['{arch}-apple-{subsystem}-clang', '-mios-version-min={min_ios_version}']
733+
cpp = ['{arch}-apple-{subsystem}-clang++', '-mios-version-min={min_ios_version}']
734+
objc = ['{arch}-apple-{subsystem}-clang', '-mios-version-min={min_ios_version}']
735+
objcpp = ['{arch}-apple-{subsystem}-clang++', '-mios-version-min={min_ios_version}']
736+
ar = ['{arch}-apple-{subsystem}-ar']
755737
756738
[built-in options]
757-
c_args = {cflags!r}
758-
cpp_args = {cflags!r}
759-
objc_args = {cflags!r}
760-
761-
c_link_args = {ldflags!r}
762-
cpp_link_args = {ldflags!r}
763-
objc_link_args = {ldflags!r}
739+
c_link_args = ['-mios-version-min={min_ios_version}', '-F', {prefix!r}, '-framework', 'Python']
740+
cpp_link_args = ['-mios-version-min={min_ios_version}', '-F', {prefix!r}, '-framework', 'Python']
741+
objc_link_args = ['-mios-version-min={min_ios_version}', '-F', {prefix!r}, '-framework', 'Python']
764742
765743
[host_machine]
766744
system = 'ios'

0 commit comments

Comments
 (0)