mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 06:56:14 +01:00
meson: Use meson.can_run_host_binaries()
It is not only shorter than `not meson.is_cross_build() or meson.has_exe_wrapper()` but also handle the case of cross compiling to a compatible arch such as building for i386 on an amd64.
This commit is contained in:
parent
25ab87d8e5
commit
374be41433
@ -1,9 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
if not os.environ.get("DESTDIR"):
|
||||
print("GIO module cache creation...")
|
||||
subprocess.call([sys.argv[1], sys.argv[2]])
|
@ -978,7 +978,7 @@ glib_compile_resources = executable('glib-compile-resources',
|
||||
# Cannot override those programs in cross compilation case because they are
|
||||
# native executables that cannot be run on the build machine.
|
||||
# See https://gitlab.gnome.org/GNOME/glib/issues/1859.
|
||||
if not meson.is_cross_build()
|
||||
if not meson.can_run_host_binaries()
|
||||
meson.override_find_program('glib-compile-schemas', glib_compile_schemas)
|
||||
meson.override_find_program('glib-compile-resources', glib_compile_resources)
|
||||
meson.override_find_program('gio-querymodules', gio_querymodules)
|
||||
|
@ -603,7 +603,7 @@ if installed_tests_enabled
|
||||
endforeach
|
||||
endif
|
||||
|
||||
if not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
if meson.can_run_host_binaries()
|
||||
|
||||
compiler_type = '--compiler=@0@'.format(cc.get_id())
|
||||
|
||||
|
@ -71,7 +71,7 @@ int main ()
|
||||
gl_cv_cc_double_expbit0_word = -1
|
||||
gl_cv_cc_double_expbit0_bit = -1
|
||||
|
||||
if not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
if meson.can_run_host_binaries()
|
||||
run_result = cc.run(double_exponent_test,
|
||||
name : 'where to find the exponent in a \'double\'')
|
||||
if run_result.compiled() and run_result.returncode() == 0
|
||||
|
@ -76,7 +76,7 @@ int main()
|
||||
return result;
|
||||
}'''
|
||||
|
||||
if not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
if meson.can_run_host_binaries()
|
||||
run_result = cc.run(frexp_test,
|
||||
name : 'frexp works',
|
||||
dependencies : [libm])
|
||||
|
@ -104,7 +104,7 @@ int main()
|
||||
}
|
||||
'''
|
||||
|
||||
if not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
if meson.can_run_host_binaries()
|
||||
run_result = cc.run(frexpl_test,
|
||||
name : 'frexpl works',
|
||||
dependencies : [libm])
|
||||
|
@ -33,7 +33,7 @@ int main()
|
||||
}
|
||||
'''
|
||||
|
||||
if not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
if meson.can_run_host_binaries()
|
||||
run_result = cc.run(ldexpl_test,
|
||||
name : 'ldexpl works',
|
||||
dependencies : [libm])
|
||||
|
@ -79,7 +79,7 @@ glibc_printf_directive_a_test = '''
|
||||
int main () { return 0; }
|
||||
'''
|
||||
|
||||
if not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
if meson.can_run_host_binaries()
|
||||
run_result = cc.run(printf_directive_a_test,
|
||||
name : 'printf supports the \'a\' and \'A\' directives')
|
||||
gl_cv_func_printf_directive_a = run_result.compiled() and run_result.returncode() == 0
|
||||
|
@ -29,7 +29,7 @@ int main ()
|
||||
}
|
||||
'''
|
||||
|
||||
if not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
if meson.can_run_host_binaries()
|
||||
run_result = cc.run(printf_directive_f_test,
|
||||
name : 'printf supports the \'F\' directive')
|
||||
gl_cv_func_printf_directive_f = run_result.compiled() and run_result.returncode() == 0
|
||||
|
@ -62,7 +62,7 @@ int main ()
|
||||
}
|
||||
'''
|
||||
|
||||
if not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
if meson.can_run_host_binaries()
|
||||
run_result = cc.run(printf_directive_ls_test,
|
||||
name : 'printf supports the \'ls\' directive')
|
||||
gl_cv_func_printf_directive_ls = run_result.compiled() and run_result.returncode() == 0
|
||||
|
@ -54,7 +54,7 @@ int main()
|
||||
}
|
||||
'''
|
||||
|
||||
if not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
if meson.can_run_host_binaries()
|
||||
run_result = cc.run(printf_enomem_test,
|
||||
name : 'printf survives out-of-memory conditions')
|
||||
gl_cv_func_printf_enomem = run_result.compiled() and run_result.returncode() == 0
|
||||
|
@ -20,7 +20,7 @@ int main ()
|
||||
return 0;
|
||||
}'''
|
||||
|
||||
if not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
if meson.can_run_host_binaries()
|
||||
run_result = cc.run(printf_flag_grouping_test,
|
||||
name : 'printf supports the grouping flag')
|
||||
gl_cv_func_printf_flag_grouping = run_result.compiled() and run_result.returncode() == 0
|
||||
|
@ -22,7 +22,7 @@ int main ()
|
||||
}
|
||||
'''
|
||||
|
||||
if not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
if meson.can_run_host_binaries()
|
||||
run_result = cc.run(printf_flag_leftadjust_test,
|
||||
name : 'printf supports the left-adjust flag correctly')
|
||||
gl_cv_func_printf_flag_leftadjust = run_result.compiled() and run_result.returncode() == 0
|
||||
|
@ -23,7 +23,7 @@ int main ()
|
||||
}
|
||||
'''
|
||||
|
||||
if not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
if meson.can_run_host_binaries()
|
||||
run_result = cc.run(printf_flag_zero_test,
|
||||
name : 'printf supports the zero flag correctly')
|
||||
gl_cv_func_printf_flag_zero = run_result.compiled() and run_result.returncode() == 0
|
||||
|
@ -77,7 +77,7 @@ int main ()
|
||||
}
|
||||
'''
|
||||
|
||||
if not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
if meson.can_run_host_binaries()
|
||||
run_result = cc.run(printf_infinite_double_test,
|
||||
name : 'printf supports infinite \'double\' arguments')
|
||||
gl_cv_func_printf_infinite = run_result.compiled() and run_result.returncode() == 0
|
||||
|
@ -167,7 +167,7 @@ int main ()
|
||||
'''
|
||||
|
||||
if gl_cv_func_printf_long_double
|
||||
if not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
if meson.can_run_host_binaries()
|
||||
run_result = cc.run(printf_infinite_long_double_test,
|
||||
name : 'printf supports infinite \'long double\' arguments')
|
||||
gl_cv_func_printf_infinite_long_double = (run_result.compiled() and run_result.returncode() == 0)
|
||||
|
@ -30,7 +30,7 @@ int main ()
|
||||
}
|
||||
'''
|
||||
|
||||
if not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
if meson.can_run_host_binaries()
|
||||
run_result = cc.run(printf_long_double_test,
|
||||
name : 'printf supports \'long double\' arguments')
|
||||
gl_cv_func_printf_long_double = run_result.compiled() and run_result.returncode() == 0
|
||||
|
@ -37,7 +37,7 @@ int main ()
|
||||
}
|
||||
'''
|
||||
|
||||
if not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
if meson.can_run_host_binaries()
|
||||
run_result = cc.run(printf_precision_test,
|
||||
name : 'printf supports large precisions')
|
||||
gl_cv_func_printf_precision = run_result.compiled() and run_result.returncode() == 0
|
||||
|
@ -315,7 +315,7 @@ executable('testing-helper', 'testing-helper.c',
|
||||
)
|
||||
|
||||
# some testing of gtester functionality
|
||||
if not meson.is_cross_build() and host_system != 'windows'
|
||||
if meson.can_run_host_binaries() and host_system != 'windows'
|
||||
xmllint = find_program('xmllint', required: false)
|
||||
if xmllint.found()
|
||||
tmpsample_xml = custom_target('tmpsample.xml',
|
||||
|
@ -25,7 +25,7 @@ if g_module_impl == 'G_MODULE_IMPL_DL'
|
||||
if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
|
||||
message('Building for MSVC: assuming that symbols are prefixed with underscore')
|
||||
g_module_need_uscore = 1
|
||||
elif meson.has_exe_wrapper()
|
||||
elif meson.can_run_host_binaries()
|
||||
# FIXME: communicate result via stdout instead of return value, so non-0 return is not printed in bold red
|
||||
rres = cc.run(dlopen_dlsym_test_code,
|
||||
dependencies : libdl_dep,
|
||||
|
@ -12,7 +12,7 @@ project('glib', 'c', 'cpp',
|
||||
cc = meson.get_compiler('c')
|
||||
cxx = meson.get_compiler('cpp')
|
||||
|
||||
cc_can_run = not meson.is_cross_build() or meson.has_exe_wrapper()
|
||||
cc_can_run = meson.can_run_host_binaries()
|
||||
|
||||
if cc.get_argument_syntax() == 'msvc'
|
||||
# Ignore several spurious warnings for things glib does very commonly
|
||||
@ -100,7 +100,7 @@ installed_tests_template = files('template.test.in')
|
||||
installed_tests_template_tap = files('template-tap.test.in')
|
||||
|
||||
# Don’t build the tests unless we can run them (either natively, in an exe wrapper, or by installing them for later use)
|
||||
build_tests = get_option('tests') and (not meson.is_cross_build() or (meson.is_cross_build() and meson.has_exe_wrapper()) or installed_tests_enabled)
|
||||
build_tests = get_option('tests') and (meson.can_run_host_binaries() or installed_tests_enabled)
|
||||
|
||||
add_project_arguments('-D_GNU_SOURCE', language: 'c')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user