Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
Fix bad assumption about host_machine.system()
Browse files Browse the repository at this point in the history
Despite it being auto-detected as e.g. darwin for macOS, the correct
value needs to be the actual OS. Otherwise Meson will attempt to run
iOS Simulator binaries on macOS without a wrapper.
  • Loading branch information
oleavr committed May 19, 2017
1 parent d8fa038 commit e8cef70
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 61 deletions.
4 changes: 2 additions & 2 deletions bindings/gumpp/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ gumpp_sources = [

extra_link_args = []
extra_link_depends = []
if host_machine.system() == 'darwin'
if host_os_family == 'darwin'
symlist = 'gumpp.symbols'
extra_link_args += ['-Wl,-exported_symbols_list,' + join_paths(meson.current_source_dir(), symlist)]
extra_link_depends += [symlist]
elif host_machine.system() != 'windows'
elif host_os_family != 'windows'
symscript = 'gumpp.version'
extra_link_args += ['-Wl,--version-script,' + join_paths(meson.current_source_dir(), symscript)]
extra_link_depends += [symscript]
Expand Down
8 changes: 4 additions & 4 deletions gum/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ gum_sources = [
'arch-mips/gummipsrelocator.c',
]

if host_machine.system() == 'windows'
if host_os_family == 'windows'
gum_headers += [
'backend-windows/gumwindows.h',
'backend-dbghelp/gumdbghelp.h',
Expand All @@ -84,7 +84,7 @@ if host_machine.system() == 'windows'
]
endif

if host_machine.system() == 'darwin'
if host_os_family == 'darwin'
gum_headers += [
'backend-darwin/gumdarwin.h',
'backend-darwin/gumdarwinbacktracer.h',
Expand All @@ -109,7 +109,7 @@ if host_machine.system() == 'darwin'
]
endif

if host_machine.system() == 'linux'
if host_os_family == 'linux'
gum_headers += [
'backend-linux/gumlinux.h',
]
Expand All @@ -122,7 +122,7 @@ if host_machine.system() == 'linux'
]
endif

if host_machine.system() == 'qnx'
if host_os_family == 'qnx'
gum_headers += [
'backend-qnx/gumqnx.h',
]
Expand Down
8 changes: 4 additions & 4 deletions libs/gum/prof/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@ gum_prof_sources = [

host_cpu_is_intel = host_machine.cpu_family() == 'x86' or host_machine.cpu_family() == 'x86_64'

if host_cpu_is_intel and host_machine.system() != 'qnx'
if host_cpu_is_intel and host_os_family != 'qnx'
gum_prof_sources += ['gumcyclesampler-x86.c']
endif

if host_machine.system() == 'darwin'
if host_os_family == 'darwin'
gum_prof_sources += ['gumbusycyclesampler-darwin.c']
if not host_cpu_is_intel
gum_prof_sources += ['gumcyclesampler-darwin.c']
endif
endif

if host_machine.system() == 'linux'
if host_os_family == 'linux'
gum_prof_sources += ['gumbusycyclesampler-linux.c']
if not host_cpu_is_intel
gum_prof_sources += ['gumcyclesampler-linux.c']
endif
endif

if host_machine.system() == 'qnx'
if host_os_family == 'qnx'
gum_prof_sources += [
'gumbusycyclesampler-qnx.c',
'gumcyclesampler-qnx.c',
Expand Down
103 changes: 57 additions & 46 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,57 +1,68 @@
project('frida-gum', 'c', 'cpp', version: '1.0.0')

languages = ['c', 'cpp']
if host_machine.system() == 'darwin'
languages += ['objc', 'objcpp']
add_languages('objc', 'objcpp')
endif
host_os_family = ''
host_os = host_machine.system()

gum_version = meson.project_version()
api_version = '1.0'
if not meson.is_cross_build()
target_conditionals_prefix = '#include <TargetConditionals.h>'

cc = meson.get_compiler('c')
is_macos_src = target_conditionals_prefix + '''
#if !TARGET_OS_OSX
# error Not macOS
#endif
'''
if cc.compiles(is_macos_src, name: 'compiling for macOS')
host_os = 'macos'
endif

cdata = configuration_data()
is_ios_src = target_conditionals_prefix + '''
#if !TARGET_OS_IOS
# error Not iOS
#endif
'''
if cc.compiles(is_ios_src, name: 'compiling for iOS')
host_os = 'ios'
endif

if cc.has_header('android/api-level.h')
host_os = 'android'
endif
endif

os_defines = [
['windows', 'HAVE_WINDOWS'],
['darwin', 'HAVE_DARWIN'],
['linux', 'HAVE_LINUX'],
['qnx', 'HAVE_QNX'],
os_families = [
['windows', 'windows'],
['macos', 'darwin'],
['linux', 'linux'],
['ios', 'darwin'],
['android', 'linux'],
['qnx', 'qnx'],
]
foreach d : os_defines
if d.get(0) == host_machine.system()
cdata.set(d.get(1), 1)
foreach f : os_families
if f.get(0) == host_os
host_os_family = f.get(1)
endif
endforeach

host_os = host_machine.system()

target_conditionals_prefix = '#include <TargetConditionals.h>'

is_macos_src = target_conditionals_prefix + '''
#if !TARGET_OS_OSX
# error Not macOS
#endif
'''
if cc.compiles(is_macos_src, name: 'compiling for macOS')
host_os = 'macos'
cdata.set('HAVE_MACOS', 1)
if host_os_family == ''
error('Unsupported OS')
endif

is_ios_src = target_conditionals_prefix + '''
#if !TARGET_OS_IOS
# error Not iOS
#endif
'''
if cc.compiles(is_ios_src, name: 'compiling for iOS')
host_os = 'ios'
cdata.set('HAVE_IOS', 1)
languages = ['c', 'cpp']
if host_os_family == 'darwin'
languages += ['objc', 'objcpp']
add_languages('objc', 'objcpp')
endif

if cc.has_header('android/api-level.h')
host_os = 'android'
cdata.set('HAVE_ANDROID', 1)
gum_version = meson.project_version()
api_version = '1.0'

cc = meson.get_compiler('c')

cdata = configuration_data()

cdata.set('HAVE_' + host_os_family.to_upper(), 1)
if host_os != host_os_family
cdata.set('HAVE_' + host_os.to_upper(), 1)
endif

cpu_defines = [
Expand Down Expand Up @@ -151,18 +162,18 @@ if unwind_dep.found()
cdata.set('HAVE_LIBUNWIND', 1)
extra_deps += [unwind_dep]
extra_requires_private += ['libunwind']
elif host_machine.system() == 'linux' or host_machine.system() == 'qnx'
elif host_os_family == 'linux' or host_os_family == 'qnx'
error('libunwind is required')
endif

have_bfd = cc.has_header('bfd.h')
if have_bfd
if host_machine.system() == 'linux'
if host_os_family == 'linux'
extra_libs_private += ['-lbfd', '-ldl', '-lz']
else
extra_libs_private += ['-lbfd', '-lz']
endif
elif host_machine.system() == 'linux' or host_machine.system() == 'qnx'
elif host_os_family == 'linux' or host_os_family == 'qnx'
error('libbfd is required')
endif

Expand All @@ -175,7 +186,7 @@ if get_option('enable_gumjs')

json_glib_dep = dependency('json-glib-1.0')

if host_machine.system() == 'windows'
if host_os_family == 'windows'
gio_os_package_name = 'gio-windows-2.0'
else
gio_os_package_name = 'gio-unix-2.0'
Expand All @@ -184,7 +195,7 @@ if get_option('enable_gumjs')
gumjs_extra_deps += [gio_os_package_dep]
gumjs_extra_requires += [gio_os_package_name]

if host_machine.system() == 'linux' or host_machine.system() == 'qnx'
if host_os_family == 'linux' or host_os_family == 'qnx'
gumjs_extra_libraries += ['-lm']
endif

Expand Down Expand Up @@ -217,7 +228,7 @@ add_project_arguments(
'-DG_LOG_DOMAIN="Frida"',
language: languages)

if host_machine.system() == 'linux'
if host_os_family == 'linux'
add_project_arguments('-D_GNU_SOURCE=1', language: languages)
endif

Expand Down
2 changes: 1 addition & 1 deletion tests/core/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ core_sources = [
'arch-arm64/arm64relocator.c',
]

if host_machine.system() == 'darwin'
if host_os_family == 'darwin'
core_sources += [
'interceptor-darwin.c',
'exceptor-darwin.c',
Expand Down
2 changes: 1 addition & 1 deletion tests/data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test_function_libraries = [
'targetfunctions',
'specialfunctions',
]
if host_machine.system() == 'darwin'
if host_os_family == 'darwin'
shlib_extension = 'dylib'
else
shlib_extension = 'so'
Expand Down
2 changes: 1 addition & 1 deletion tests/gumjs/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ gumjs_sources = [
'kscript.c',
]

if host_machine.system() == 'darwin'
if host_os_family == 'darwin'
gumjs_sources += [
'script-darwin.m',
]
Expand Down
2 changes: 1 addition & 1 deletion tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ endif

force_cpp_linking = get_option('enable_gumpp') or have_v8
if force_cpp_linking
if host_machine.system() == 'darwin'
if host_os_family == 'darwin'
# Work around Meson bug: https://github.com/mesonbuild/meson/issues/1766
runner_sources += ['dummy.mm']
else
Expand Down
2 changes: 1 addition & 1 deletion vapi/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ vapis = [
'frida-gum-@0@.vapi'.format(api_version),
]

if host_machine.system() == 'linux'
if host_os_family == 'linux'
vapis += ['frida-gum-linux-@0@.vapi'.format(api_version)]
endif

Expand Down

0 comments on commit e8cef70

Please sign in to comment.