From f9c1b6f65bec623d593835c400d2d55d981715c8 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 23 Feb 2021 13:11:22 -0500 Subject: Make test suite work with cross-related options Because of skepticism I received in #224, I made this PR which keeps the testsuite and CI improvements but doesn't add any new build options. I hope this would be less controversial: - no new knobs - tests for those using existing build options - CI tests `build_introspection_data = false` --- .gitlab-ci.yml | 21 +++++++++++++++++++++ MSVC.README.rst | 2 +- gir/meson.build | 29 +++++++++++++++++++---------- girepository/meson.build | 7 ------- giscanner/dumper.py | 2 +- giscanner/meson.build | 7 +++++++ meson.build | 9 +++++++-- tests/meson.build | 36 ++++++++++++++++++++++-------------- tests/offsets/meson.build | 5 ++--- tests/scanner/meson.build | 40 ++++++++++++++++------------------------ tools/g-ir-tool-template.in | 2 +- tools/meson.build | 14 ++++++++------ 12 files changed, 105 insertions(+), 69 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d8c72acb..4e4572e1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -88,6 +88,27 @@ fedora-x86_64-subprojects: - "${CI_PROJECT_DIR}/_build/meson-logs" - public +fedora-x86_64-no-introspection-data: + stage: build + variables: + CCACHE_BASEDIR: "${CI_PROJECT_DIR}" + CCACHE_DIR: "${CI_PROJECT_DIR}/_ccache" + CFLAGS: "-Werror" + script: + - python3 -m pip install --user mako markdown + - meson --prefix /usr --libdir /usr/lib64 --buildtype debug -Dbuild_introspection_data=false -Dpython=python3 _build . + - cd _build + - ninja + - meson test --print-errorlogs --suite=gobject-introspection --no-suite=glib + except: + - tags + artifacts: + when: always + name: "gi-_${CI_COMMIT_REF_NAME}" + paths: + - "${CI_PROJECT_DIR}/_build/meson-logs" + - public + fedora-x86_64-python3.6: stage: build variables: diff --git a/MSVC.README.rst b/MSVC.README.rst index ec5ddb56..0c0dd409 100644 --- a/MSVC.README.rst +++ b/MSVC.README.rst @@ -71,7 +71,7 @@ using Ninja or the generated Visual Studio projects. Additional notes for building and running against Python 3.8.x and later ------------------------------------------------------------------------ Python 3.8.x and later made restrictions on where DLLs are searched for third-party -modules, which will therefore affect how the Python tools in tools/ look for dependent +modules, which will therefore affect how the Python tools in ``tools/`` look for dependent DLLs, as they rely on a C Python module, _giscanner.pyd, as the paths in %PATH% are no longer referred to, except for system-supplied DLLs in their designated locations on the system. In order to cope with this, DLLs are being searched for in the diff --git a/gir/meson.build b/gir/meson.build index 557e5517..61fbdfb1 100644 --- a/gir/meson.build +++ b/gir/meson.build @@ -178,11 +178,20 @@ endforeach # out of date. glib_files += files('glib-2.0.c') +gir_giscanner_pymod = [] +gir_giscanner_built_files = [] +if not get_option('gi_cross_use_prebuilt_gi') + # The right thing to do is just make these dependencies of the + # `configure_file` python executable, but that isn't yet supported. + gir_giscanner_pymod = giscanner_pymod + gir_giscanner_built_files = giscanner_built_files +endif + glib_gir = custom_target('gir-glib', input: glib_files, output: 'GLib-2.0.gir', - depends: giscanner_pymod, - depend_files: giscanner_built_files, + depends: gir_giscanner_pymod, + depend_files: gir_giscanner_built_files, install: true, install_dir: girdir, command: glib_command + [ @@ -244,8 +253,8 @@ gobject_files += files('gobject-2.0.c') gobject_gir = custom_target('gir-gobject', input: gobject_files, output: 'GObject-2.0.gir', - depends: [glib_gir, giscanner_pymod], - depend_files: giscanner_built_files, + depends: [glib_gir, gir_giscanner_pymod], + depend_files: gir_giscanner_built_files, install: true, install_dir: girdir, command: gobject_command + [ @@ -291,8 +300,8 @@ gmodule_files += files('gmodule-2.0.c') gir_files += custom_target('gir-gmodule', input: gmodule_files, output: 'GModule-2.0.gir', - depends: [glib_gir, giscanner_pymod], - depend_files: giscanner_built_files, + depends: [glib_gir, gir_giscanner_pymod], + depend_files: gir_giscanner_built_files, install: true, install_dir: girdir, command: gmodule_command + [ @@ -380,8 +389,8 @@ gio_files += files('gio-2.0.c') gio_gir = custom_target('gir-gio', input: gio_files, output: 'Gio-2.0.gir', - depends: [gobject_gir, giscanner_pymod], - depend_files: giscanner_built_files, + depends: [gobject_gir, gir_giscanner_pymod], + depend_files: gir_giscanner_built_files, install: true, install_dir: girdir, command: gio_command + [ @@ -417,8 +426,8 @@ endif gir_files += custom_target('gir-girepository', input: girepo_gir_sources, output: 'GIRepository-2.0.gir', - depends: [gobject_gir, giscanner_pymod, girepo_lib], - depend_files: giscanner_built_files, + depends: [gobject_gir, gir_giscanner_pymod, girepo_lib], + depend_files: gir_giscanner_built_files, install: true, install_dir: girdir, command: girepository_command + [ diff --git a/girepository/meson.build b/girepository/meson.build index c8ef6aa9..786749a9 100644 --- a/girepository/meson.build +++ b/girepository/meson.build @@ -185,13 +185,6 @@ girepo_lib = shared_library('girepository-1.0', install: true, ) -# Copy to builddir for use with giscanner/dumper.py when running uninstalled -configure_file(input : 'gdump.c', - output : 'gdump.c', - copy: true, - install_dir: join_paths(get_option('datadir'), 'gobject-introspection-1.0'), -) - girepo_dep = declare_dependency( link_with: girepo_lib, dependencies: [glib_dep, gobject_dep, gio_dep, gmodule_dep], diff --git a/giscanner/dumper.py b/giscanner/dumper.py index f61c46c1..22afd61e 100644 --- a/giscanner/dumper.py +++ b/giscanner/dumper.py @@ -102,7 +102,7 @@ class DumpCompiler(object): tpl_args = {} if self._uninst_srcdir is not None: - gdump_path = os.path.join(self._uninst_srcdir, 'girepository', 'gdump.c') + gdump_path = os.path.join(self._uninst_srcdir, 'giscanner', 'gdump.c') else: try: gdump_path = GDUMP_PATH diff --git a/giscanner/meson.build b/giscanner/meson.build index 098b7b6b..41edcd44 100644 --- a/giscanner/meson.build +++ b/giscanner/meson.build @@ -44,6 +44,13 @@ foreach f : giscanner_files configuration : giscanner_conf_data) endforeach +# Copy to builddir for use with dumper.py when running uninstalled +configure_file(input : '../girepository/gdump.c', + output : 'gdump.c', + copy: true, + install_dir: join_paths(get_option('datadir'), 'gobject-introspection-1.0'), +) + install_subdir('doctemplates', install_dir: giscannerdir) # XXX: this doesn't track the input, but there is nothing to copy many files diff --git a/meson.build b/meson.build index 9638a5ab..4460e40c 100644 --- a/meson.build +++ b/meson.build @@ -218,14 +218,19 @@ subdir('giscanner') # scenarios where running target binaries through software emulation # is not possible (due to the SW emulation missing support for target HW). if get_option('build_introspection_data') == true - subdir('gir') + subdir('gir') +else + # for tests + typelibs = disabler() + gobject_gir = disabler() + gio_gir = disabler() endif subdir('docs') # The tests will also run, which is not possible if they # were built for a different architecture. if not meson.is_cross_build() - subdir('tests') + subdir('tests') endif install_data('Makefile.introspection', install_dir: join_paths(get_option('datadir'), 'gobject-introspection-1.0')) diff --git a/tests/meson.build b/tests/meson.build index b240749e..d5b76342 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -45,13 +45,17 @@ test_install_dir = join_paths(get_option('datadir'), 'gobject-introspection-1.0' install_data(installed_sources, install_dir: test_install_dir) +# Will be overridden to newly built one in common-case regular, non-cross +# build. +test_girscanner = find_program('g-ir-scanner', native: true, required : false) +test_gircompiler = find_program('g-ir-compiler', native: false, required : false) + # Generate everything.h and everything.c: test_everything_files = custom_target('everything', output: ['everything.h', 'everything.c'], depends: typelibs, command: [ - python, - girscanner, + test_girscanner, '--quiet', '--generate-typelib-tests=Everything,@OUTPUT0@,@OUTPUT1@', '--function-decoration=_GI_TEST_EXTERN', @@ -103,14 +107,15 @@ test_typelibs = [] # well. Though, this could work differently altogether. Instead one could # generate appropriate pkg-config files and point PKG_CONFIG_PATH to them, # leaving all invocations of g-ir-scanner as is. -if glib_dep.type_name() == 'pkgconfig' - test_gir_files += custom_target('gir-everything', +if (glib_dep.type_name() == 'pkgconfig' and + test_girscanner.found() and + get_option('build_introspection_data') == true) + test_gir_files += [custom_target('gir-everything', input: test_everything_sources + test_everything_headers, output: 'Everything-1.0.gir', depends: [everything_lib] + typelibs, command: [ - python, - girscanner, + test_girscanner, '--quiet', '--output=@OUTPUT@', '--no-libtool', @@ -128,15 +133,14 @@ if glib_dep.type_name() == 'pkgconfig' extra_giscanner_args, '@INPUT@', ] - ) + )] - test_gir_files += custom_target('gir-gimarshallingtests', + test_gir_files += [custom_target('gir-gimarshallingtests', input: test_marshalling_sources + test_marshalling_headers, output: 'GIMarshallingTests-1.0.gir', depends: [gimarshallingtests_lib] + typelibs, command: [ - python, - girscanner, + test_girscanner, '--quiet', '--output=@OUTPUT@', '--no-libtool', @@ -155,14 +159,14 @@ if glib_dep.type_name() == 'pkgconfig' extra_giscanner_args, '@INPUT@', ] - ) + )] foreach gir : test_gir_files test_typelibs += custom_target('generate-typelib-@0@'.format(gir).underscorify(), input: gir, output: '@BASENAME@.typelib', depends: [gobject_gir, ], - command: [gircompiler, '-o', '@OUTPUT@', '@INPUT@', + command: [test_gircompiler, '-o', '@OUTPUT@', '@INPUT@', '--includedir', join_paths(build_root, 'gir'), '--includedir', meson.current_build_dir() ], @@ -183,6 +187,10 @@ if glib_dep.type_name() == 'pkgconfig' endif subdir('offsets') -subdir('warn') +if get_option('build_introspection_data') == true + subdir('warn') +endif subdir('scanner') -subdir('repository') +if get_option('build_introspection_data') == true + subdir('repository') +endif diff --git a/tests/offsets/meson.build b/tests/offsets/meson.build index f6a497f6..970e54cf 100644 --- a/tests/offsets/meson.build +++ b/tests/offsets/meson.build @@ -18,8 +18,7 @@ if glib_dep.type_name() == 'pkgconfig' output: 'Offsets-1.0.gir', depends: [test_offsets_lib] + typelibs, command: [ - python, - girscanner, + test_girscanner, '--quiet', '--output=@OUTPUT@', '--no-libtool', @@ -45,7 +44,7 @@ if glib_dep.type_name() == 'pkgconfig' input: test_offsets_gir, output: '@BASENAME@.typelib', depends: [gobject_gir, ], - command: [gircompiler, '-o', '@OUTPUT@', '@INPUT@', + command: [test_gircompiler, '-o', '@OUTPUT@', '@INPUT@', '--includedir', join_paths(build_root, 'gir'), '--includedir', meson.current_build_dir() ], diff --git a/tests/scanner/meson.build b/tests/scanner/meson.build index fa7f7eca..5176b957 100644 --- a/tests/scanner/meson.build +++ b/tests/scanner/meson.build @@ -105,19 +105,19 @@ regress_lib = shared_library('regress-1.0', python_path = run_command(python, ['-c', 'import sys; sys.stdout.write(sys.executable)']).stdout() gircompiler_command = [ - gircompiler, '-o', '@OUTPUT@', '@INPUT@', + test_gircompiler, '-o', '@OUTPUT@', '@INPUT@', '--includedir', join_paths(build_root, 'gir'), '--includedir', meson.current_build_dir(), ] -if glib_dep.type_name() == 'pkgconfig' +if (glib_dep.type_name() == 'pkgconfig' and + get_option('build_introspection_data') == true) typedef_gir = custom_target('gir-typedef', input: ['typedefs.c', 'typedefs.h'], output: 'Typedefs-1.0.gir', depends: [typedef_lib] + typelibs, command: [ - python, - girscanner, + test_girscanner, '--quiet', '--output=@OUTPUT@', '--no-libtool', @@ -156,8 +156,7 @@ if glib_dep.type_name() == 'pkgconfig' output: 'Bar-1.0.gir', depends: [barapp_lib] + typelibs, command: [ - python, - girscanner, + test_girscanner, '--quiet', '--output=@OUTPUT@', '--no-libtool', @@ -195,8 +194,7 @@ if glib_dep.type_name() == 'pkgconfig' output: 'SLetter-1.0.gir', depends: [sletter_lib] + typelibs, command: [ - python, - girscanner, + test_girscanner, '--quiet', '--output=@OUTPUT@', '--no-libtool', @@ -233,8 +231,7 @@ if glib_dep.type_name() == 'pkgconfig' output: 'WarnLib-1.0.gir', depends: [warnlib_lib] + typelibs, command: [ - python, - girscanner, + test_girscanner, '--quiet', '--output=@OUTPUT@', '--no-libtool', @@ -269,8 +266,7 @@ if glib_dep.type_name() == 'pkgconfig' output: 'Utility-1.0.gir', depends: [utility_lib] + typelibs, command: [ - python, - girscanner, + test_girscanner, '--quiet', '--output=@OUTPUT@', '--no-libtool', @@ -307,8 +303,7 @@ if glib_dep.type_name() == 'pkgconfig' output: 'GtkFrob-1.0.gir', depends: [gtkfrob_lib] + typelibs, command: [ - python, - girscanner, + test_girscanner, '--quiet', '--output=@OUTPUT@', '--no-libtool', @@ -346,8 +341,7 @@ if glib_dep.type_name() == 'pkgconfig' output: 'GetType-1.0.gir', depends: [gettype_lib] + typelibs, command: [ - python, - girscanner, + test_girscanner, '--quiet', '--output=@OUTPUT@', '--no-libtool', @@ -384,8 +378,7 @@ if glib_dep.type_name() == 'pkgconfig' output: 'Symbolfilter-1.0.gir', depends: typelibs, command: [ - python, - girscanner, + test_girscanner, '--quiet', '--output=@OUTPUT@', '--no-libtool', @@ -412,8 +405,7 @@ if glib_dep.type_name() == 'pkgconfig' output: 'Identfilter-1.0.gir', depends: typelibs, command: [ - python, - girscanner, + test_girscanner, '--quiet', '--output=@OUTPUT@', '--no-libtool', @@ -441,8 +433,7 @@ if glib_dep.type_name() == 'pkgconfig' output: 'Headeronly-1.0.gir', depends: typelibs, command: [ - python, - girscanner, + test_girscanner, '--quiet', '--output=@OUTPUT@', '--no-libtool', @@ -477,8 +468,7 @@ if glib_dep.type_name() == 'pkgconfig' output: 'Regress-1.0.gir', depends: [regress_lib] + typelibs + [utility_gir], command: [ - python, - girscanner, + test_girscanner, '--quiet', '--output=@OUTPUT@', '--no-libtool', @@ -514,6 +504,8 @@ if glib_dep.type_name() == 'pkgconfig' command: gircompiler_command, ) test_typelibs += regress_typelib +else + regress_gir = disabler() endif gi_tester = files(join_paths('..', 'gi-tester')) diff --git a/tools/g-ir-tool-template.in b/tools/g-ir-tool-template.in index 75bf759c..6e98f52e 100755 --- a/tools/g-ir-tool-template.in +++ b/tools/g-ir-tool-template.in @@ -81,7 +81,7 @@ if not os.path.isfile(os.path.join(pylibdir, 'giscanner', '_giscanner' + py_mod_ builddir = os.path.abspath(os.path.join(filedir, '..')) pylibdir = builddir builtins.__dict__['GIRDIR'].append(os.path.join(filedir, os.pardir, 'gir')) - gdump_path = os.path.join(builddir, 'girepository', 'gdump.c') + gdump_path = os.path.join(builddir, 'giscanner', 'gdump.c') if os.path.isfile(gdump_path): builtins.__dict__['GDUMP_PATH'] = gdump_path else: diff --git a/tools/meson.build b/tools/meson.build index f272c955..46b487e0 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -30,6 +30,11 @@ foreach tool : tools output: tool[0], configuration: tools_conf, install_dir: get_option('bindir'), + # Not yet supported, but put here to document intention. + # depends: [ + # giscanner_pymod + # ], + # depend_files: giscanner_built_files, ) tool_output += tool_bin # Provide tools for others when we're a subproject and they use the Meson GNOME module @@ -59,6 +64,7 @@ gircompiler = executable('g-ir-compiler', 'compiler.c', install: true, c_args: custom_c_args, ) +meson.override_find_program('g-ir-compiler', gircompiler) girgenerate = executable('g-ir-generate', 'generate.c', dependencies: [ @@ -68,15 +74,11 @@ girgenerate = executable('g-ir-generate', 'generate.c', install: true, c_args: custom_c_args, ) +meson.override_find_program('g-ir-generate', girgenerate) girinspect = executable('g-ir-inspect', 'g-ir-inspect.c', dependencies: girepo_dep, install: true, c_args: custom_c_args, ) - -if not get_option('gi_cross_use_prebuilt_gi') - meson.override_find_program('g-ir-compiler', gircompiler) - meson.override_find_program('g-ir-generate', girgenerate) - meson.override_find_program('g-ir-inspect', girinspect) -endif +meson.override_find_program('g-ir-inspect', girinspect) -- cgit v1.2.1