Skip to content

Meson port

Philip Chimento requested to merge ptomato/gjs:meson into master

This is a port of the existing Autotools build system to Meson.

As per https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting, I've updated gnome-continuous to force the autotools build until we are ready to remove it.

Some differences between the build products with the two build systems:

I used DESTDIR to install both builds and compare the installed files with meld: Screenshot_from_2019-09-07_10-56-01

Looks like the binaries are not byte-for-byte identical, unfortunately. I examined the compiler arguments from each build and can't figure out what might be causing this. It seems that the difference is that Autotools defines -DHAVE_CONFIG_H (incorrectly!) and -DPIC, while Meson defines -D_FILE_OFFSET_BITS=64. I think it's probably harmless.

Meson symlinks libgjs.so.0.0.0 to libgjs.so.0, instead of the other way around as Autotools does it. I think this is probably harmless.

The difference in the .typelib file is due to the above symlink change, and also to the use of relative paths in the source location info, as can be revealed by diffing the .gir files (not installed):

--- _autotools_build/GjsPrivate-1.0.gir	2019-09-05 22:27:58.747118381 -0700
+++ _meson_build/GjsPrivate-1.0.gir	2019-09-05 23:07:32.206724058 -0700
@@ -10,13 +10,14 @@
   <include name="Gio" version="2.0"/>
   <namespace name="GjsPrivate"
              version="1.0"
-             shared-library="libgjs.so.0"
+             shared-library="libgjs.so.0.0.0"
              c:identifier-prefixes="Gjs"
              c:symbol-prefixes="gjs_">
     <function-macro name="DBUS_IMPLEMENTATION"
                     c:identifier="GJS_DBUS_IMPLEMENTATION"
                     introspectable="0">
-      <source-position filename="gjs-gdbus-wrapper.h" line="39"/>
+      <source-position filename="../libgjs-private/gjs-gdbus-wrapper.h"
+                       line="39"/>
       <parameters>
         <parameter name="object">
         </parameter>

(plus many many more of the same sort of change)

A bit surprising is the difference in the .pc file, but this seems to be harmless:

--- _autotools_install/usr/lib/pkgconfig/gjs-1.0.pc	2019-09-07 10:39:55.028290413 -0700
+++ _meson_install/usr/lib/pkgconfig/gjs-1.0.pc	2019-09-05 22:44:35.223647285 -0700
@@ -1,18 +1,17 @@
 prefix=/usr
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
 exec_prefix=${prefix}
-libdir=/usr/lib
 bindir=${exec_prefix}/bin
-includedir=${prefix}/include
 datarootdir=${prefix}/share
 datadir=${datarootdir}
-
 gjs_console=${bindir}/gjs-console
 
-Cflags: -I${includedir}/gjs-1.0
-Requires:  glib-2.0 >= 2.58.0 gobject-2.0 >= 2.58.0 gio-2.0 >= 2.58.0  
-Requires.private:  gobject-introspection-1.0 libffi gthread-2.0 gio-2.0 >= 2.58.0 mozjs-60 cairo cairo-gobject gthread-2.0 gio-2.0 >= 2.58.0 mozjs-60 cairo-xlib
-Libs: -L${libdir} -lgjs
-
 Name: gjs-1.0
 Description: JS bindings for GObjects
 Version: 1.58.0
+Requires: glib-2.0 >=  2.58.0, gobject-2.0 >=  2.58.0, gio-2.0 >=  2.58.0
+Requires.private: gthread-2.0 >=  2.58.0, gobject-introspection-1.0 >=  1.41.4, libffi, mozjs-60, cairo, cairo-gobject, cairo-xlib
+Libs: -L${libdir} -lgjs
+Cflags: -I${includedir}/gjs-1.0

All the same lines are there, just out of order; and the Meson pkgconfig generator adds commas, extra spaces, and deduplicates the Requires lines. (The difference in libdir is because I specifically passed -Dlibdir=/usr/lib to the Meson build, to match the Autotools build instead of the default of /usr/lib64.)

Comparing the symbols exported by the libgjs library, we lose two symbols that were not supposed to be exported in the first place (messages and modules_resources_get_resource) and we are now exporting a bunch of C++ symbols:

$ nm -gC --defined-only _autotools_install/usr/lib/libgjs.so.0 | cut -d' ' -f2- | sort > _autotools_symbols.txt
$ nm -gC --defined-only _meson_install/usr/lib/libgjs.so.0 | cut -d' ' -f2- | sort > _meson_symbols.txt
$ diff -u _autotools_symbols.txt _meson_symbols.txt
--- _autotools_symbols.txt	2019-09-07 12:11:59.964845360 -0700
+++ _meson_symbols.txt	2019-09-07 12:12:11.567014524 -0700
@@ -72,8 +72,68 @@
 D gjs_ns_class
 D gjs_param_class
 D gjs_repo_class
-D messages
+T gjs_argument_display_name(char const*, GjsArgumentType)
+T gjs_array_from_strv(JSContext*, JS::MutableHandle<JS::Value>, char const**)
+T gjs_array_to_strv(JSContext*, JS::Value, unsigned int, void**)
 T gjs_bindtextdomain
+T gjs_build_string_array(JSContext*, long, char**)
+T gjs_byte_array_from_byte_array(JSContext*, _GByteArray*)
+T gjs_byte_array_from_data(JSContext*, unsigned long, void*)
+T gjs_byte_array_get_byte_array(JS::Handle<JSObject*>)
+T gjs_byte_array_get_bytes(JS::Handle<JSObject*>)
+T gjs_cairo_check_status(JSContext*, _cairo_status, char const*)
+T gjs_cairo_context_define_proto(JSContext*, JS::Handle<JSObject*>, JS::MutableHandle<JSObject*>)
+T gjs_cairo_context_from_context(JSContext*, _cairo*)
+T gjs_cairo_context_get_context(JSContext*, JS::Handle<JSObject*>)
+T gjs_cairo_context_init()
+T gjs_cairo_gradient_define_proto(JSContext*, JS::Handle<JSObject*>, JS::MutableHandle<JSObject*>)
+T gjs_cairo_gradient_get_proto(JSContext*)
+T gjs_cairo_image_surface_define_proto(JSContext*, JS::Handle<JSObject*>, JS::MutableHandle<JSObject*>)
+T gjs_cairo_image_surface_from_surface(JSContext*, _cairo_surface*)
+T gjs_cairo_linear_gradient_define_proto(JSContext*, JS::Handle<JSObject*>, JS::MutableHandle<JSObject*>)
+T gjs_cairo_linear_gradient_from_pattern(JSContext*, _cairo_pattern*)
+T gjs_cairo_path_define_proto(JSContext*, JS::Handle<JSObject*>, JS::MutableHandle<JSObject*>)
+T gjs_cairo_path_from_path(JSContext*, cairo_path*)
+T gjs_cairo_path_get_path(JSContext*, JSObject*)
+T gjs_cairo_pattern_construct(JSContext*, JS::Handle<JSObject*>, _cairo_pattern*)
+T gjs_cairo_pattern_define_proto(JSContext*, JS::Handle<JSObject*>, JS::MutableHandle<JSObject*>)
+T gjs_cairo_pattern_finalize_pattern(JSFreeOp*, JSObject*)
+T gjs_cairo_pattern_from_pattern(JSContext*, _cairo_pattern*)
+T gjs_cairo_pattern_get_pattern(JSContext*, JSObject*)
+T gjs_cairo_pattern_get_proto(JSContext*)
+T gjs_cairo_pdf_surface_define_proto(JSContext*, JS::Handle<JSObject*>, JS::MutableHandle<JSObject*>)
+T gjs_cairo_pdf_surface_from_surface(JSContext*, _cairo_surface*)
+T gjs_cairo_ps_surface_define_proto(JSContext*, JS::Handle<JSObject*>, JS::MutableHandle<JSObject*>)
+T gjs_cairo_ps_surface_from_surface(JSContext*, _cairo_surface*)
+T gjs_cairo_radial_gradient_define_proto(JSContext*, JS::Handle<JSObject*>, JS::MutableHandle<JSObject*>)
+T gjs_cairo_radial_gradient_from_pattern(JSContext*, _cairo_pattern*)
+T gjs_cairo_region_define_proto(JSContext*, JS::Handle<JSObject*>, JS::MutableHandle<JSObject*>)
+T gjs_cairo_region_init()
+T gjs_cairo_solid_pattern_define_proto(JSContext*, JS::Handle<JSObject*>, JS::MutableHandle<JSObject*>)
+T gjs_cairo_solid_pattern_from_pattern(JSContext*, _cairo_pattern*)
+T gjs_cairo_surface_construct(JSContext*, JS::Handle<JSObject*>, _cairo_surface*)
+T gjs_cairo_surface_define_proto(JSContext*, JS::Handle<JSObject*>, JS::MutableHandle<JSObject*>)
+T gjs_cairo_surface_finalize_surface(JSFreeOp*, JSObject*)
+T gjs_cairo_surface_from_surface(JSContext*, _cairo_surface*)
+T gjs_cairo_surface_get_proto(JSContext*)
+T gjs_cairo_surface_get_surface(JSContext*, JSObject*)
+T gjs_cairo_surface_init()
+T gjs_cairo_surface_pattern_define_proto(JSContext*, JS::Handle<JSObject*>, JS::MutableHandle<JSObject*>)
+T gjs_cairo_surface_pattern_from_pattern(JSContext*, _cairo_pattern*)
+T gjs_cairo_svg_surface_define_proto(JSContext*, JS::Handle<JSObject*>, JS::MutableHandle<JSObject*>)
+T gjs_cairo_svg_surface_from_surface(JSContext*, _cairo_surface*)
+T gjs_callback_trampoline_new(JSContext*, JS::Handle<JSFunction*>, _GIBaseInfoStub*, GIScopeType, JS::Handle<JSObject*>, bool)
+T gjs_callback_trampoline_ref(GjsCallbackTrampoline*)
+T gjs_callback_trampoline_unref(GjsCallbackTrampoline*)
+T gjs_closure_get_callable(_GClosure*)
+T gjs_closure_get_context(_GClosure*)
+T gjs_closure_invoke(_GClosure*, JS::Handle<JSObject*>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>, bool)
+T gjs_closure_is_valid(_GClosure*)
+T gjs_closure_new_for_signal(JSContext*, JSFunction*, char const*, unsigned int)
+T gjs_closure_new(JSContext*, JSFunction*, char const*, bool)
+T gjs_closure_new_marshaled(JSContext*, JSFunction*, char const*)
+T gjs_closure_trace(_GClosure*, JSTracer*)
+T gjs_construct_object_dynamic(JSContext*, JS::Handle<JSObject*>, JS::HandleValueArray const&)
 T gjs_context_define_string_array
 T gjs_context_eval
 T gjs_context_eval_file
@@ -88,23 +148,101 @@
 T gjs_context_new
 T gjs_context_new_with_search_path
 T gjs_context_print_stack_stderr
+T GjsContextPrivate::from_object(_GjsContext*)
+T GjsContextPrivate::from_object(_GObject*)
 T gjs_context_setup_debugger_console
 T gjs_coverage_get_type
 T gjs_coverage_new
 T gjs_coverage_write_statistics
+T gjs_create_global_object(JSContext*)
+T gjs_create_js_context(GjsContextPrivate*)
+T gjs_create_ns(JSContext*, char const*)
+T gjs_create_root_importer(JSContext*, char const* const*)
 T gjs_dbus_implementation_emit_property_changed
 T gjs_dbus_implementation_emit_signal
 T gjs_dbus_implementation_get_type
+T gjs_debug(GjsDebugTopic, char const*, ...)
+T gjs_debug_id[abi:cxx11](jsid)
+T gjs_debug_object[abi:cxx11](JSObject*)
+T gjs_debug_string[abi:cxx11](JSString*)
+T gjs_debug_symbol[abi:cxx11](JS::Symbol*)
+T gjs_debug_value[abi:cxx11](JS::Value)
+T gjs_define_byte_array_stuff(JSContext*, JS::MutableHandle<JSObject*>)
+T gjs_define_console_stuff(JSContext*, JS::MutableHandle<JSObject*>)
+T gjs_define_enumeration(JSContext*, JS::Handle<JSObject*>, _GIBaseInfoStub*)
+T gjs_define_enum_values(JSContext*, JS::Handle<JSObject*>, _GIBaseInfoStub*)
+T gjs_define_error_properties(JSContext*, JS::Handle<JSObject*>)
+T gjs_define_function(JSContext*, JS::Handle<JSObject*>, unsigned long, _GIBaseInfoStub*)
+T gjs_define_global_properties(JSContext*, JS::Handle<JSObject*>, char const*)
+T gjs_define_info(JSContext*, JS::Handle<JSObject*>, _GIBaseInfoStub*, bool*)
+T gjs_define_param_class(JSContext*, JS::Handle<JSObject*>)
+T gjs_define_private_gi_stuff(JSContext*, JS::MutableHandle<JSObject*>)
+T gjs_define_property_dynamic(JSContext*, JS::Handle<JSObject*>, char const*, char const*, bool (*)(JSContext*, unsigned int, JS::Value*), bool (*)(JSContext*, unsigned int, JS::Value*), JS::Handle<JS::Value>, unsigned int)
+T gjs_define_repo(JSContext*, JS::MutableHandle<JSObject*>)
+T gjs_define_string_array(JSContext*, JS::Handle<JSObject*>, char const*, long, char const**, unsigned int)
+T gjs_define_union_class(JSContext*, JS::Handle<JSObject*>, _GIBaseInfoStub*)
 T gjs_dumpstack
+T gjs_dynamic_property_private_slot(JSObject*)
+T gjs_environment_variable_is_set(char const*)
 T gjs_error_quark
 T gjs_format_int_alternative_output
+T gjs_format_stack_trace(JSContext*, JS::Handle<JSObject*>)
+T gjs_g_argument_release_in_arg(JSContext*, GITransfer, _GIBaseInfoStub*, _GIArgument*)
+T gjs_g_argument_release_in_array(JSContext*, GITransfer, _GIBaseInfoStub*, unsigned int, _GIArgument*)
+T gjs_g_argument_release(JSContext*, GITransfer, _GIBaseInfoStub*, _GIArgument*)
+T gjs_g_argument_release_out_array(JSContext*, GITransfer, _GIBaseInfoStub*, unsigned int, _GIArgument*)
+T gjs_gc_if_needed(JSContext*)
+T gjs_gerror_make_from_error(JSContext*, JS::Handle<JSObject*>)
+T gjs_get_global_slot(JSContext*, GjsGlobalSlot)
+T gjs_get_import_global(JSContext*)
 T gjs_get_js_version
+T gjs_get_string_id(JSContext*, jsid, mozilla::UniquePtr<char [], JS::FreePolicy>*)
+T gjs_gi_argument_init_default(_GIBaseInfoStub*, _GIArgument*)
+T gjs_g_param_from_param(JSContext*, JS::Handle<JSObject*>)
+T gjs_g_strv_concat(char***, int)
 T gjs_gtk_container_child_set_property
+T gjs_gtype_create_gtype_wrapper(JSContext*, unsigned long)
+T gjs_gtype_get_actual_gtype(JSContext*, JS::Handle<JSObject*>, unsigned long*)
+T gjs_hyphen_from_camel(char const*)
+T gjs_hyphen_to_underscore(char const*)
+T gjs_import_native_module(JSContext*, JS::Handle<JSObject*>, char const*)
+T gjs_info_type_name(GIInfoType)
+T gjs_init_class_dynamic(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSObject*>, char const*, char const*, JSClass const*, bool (*)(JSContext*, unsigned int, JS::Value*), unsigned int, JSPropertySpec*, JSFunctionSpec*, JSPropertySpec*, JSFunctionSpec*, JS::MutableHandle<JSObject*>, JS::MutableHandle<JSObject*>)
+T gjs_intern_string_to_id(JSContext*, char const*)
+T gjs_invoke_c_function_uncached(JSContext*, _GIBaseInfoStub*, JS::Handle<JSObject*>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>)
+T gjs_invoke_constructor_from_c(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::HandleValueArray const&, _GIArgument*)
+T gjs_is_registered_native_module(char const*)
+T gjs_js_define_cairo_stuff(JSContext*, JS::MutableHandle<JSObject*>)
+T gjs_js_define_system_stuff(JSContext*, JS::MutableHandle<JSObject*>)
 T gjs_js_error_get_type
 T gjs_js_error_quark
+T gjs_load_internal_source(JSContext*, char const*, mozilla::UniquePtr<char16_t [], JS::FreePolicy>*, unsigned long*)
+T gjs_load_native_module(JSContext*, char const*, JS::MutableHandle<JSObject*>)
 T gjs_locale_category_get_type
+T gjs_log_exception_full(JSContext*, JS::Handle<JS::Value>, JS::Handle<JSString*>)
+T gjs_log_exception(JSContext*)
+T gjs_lookup_generic_constructor(JSContext*, _GIBaseInfoStub*)
+T gjs_lookup_generic_prototype(JSContext*, _GIBaseInfoStub*)
+T gjs_lookup_interface_constructor(JSContext*, unsigned long, JS::MutableHandle<JS::Value>)
+T gjs_lookup_namespace_object_by_name(JSContext*, JS::Handle<jsid>)
+T gjs_lookup_namespace_object(JSContext*, _GIBaseInfoStub*)
+T gjs_lookup_object_constructor_from_info(JSContext*, _GIBaseInfoStub*, unsigned long)
+T gjs_lookup_object_constructor(JSContext*, unsigned long, JS::MutableHandle<JS::Value>)
+T gjs_lookup_private_namespace(JSContext*)
+T gjs_maybe_gc(JSContext*)
 T gjs_memory_report
+T gjs_module_import(JSContext*, JS::Handle<JSObject*>, JS::Handle<jsid>, char const*, _GFile*)
+T gjs_new_object_with_generic_prototype(JSContext*, _GIBaseInfoStub*)
+T gjs_object_clear_toggles()
+T gjs_object_require_converted_property(JSContext*, JS::Handle<JSObject*>, char const*, JS::Handle<jsid>, unsigned int*)
+T gjs_object_require_property(JSContext*, JS::Handle<JSObject*>, char const*, JS::Handle<jsid>, bool*)
+T gjs_object_require_property(JSContext*, JS::Handle<JSObject*>, char const*, JS::Handle<jsid>, int*)
+T gjs_object_require_property(JSContext*, JS::Handle<JSObject*>, char const*, JS::Handle<jsid>, JS::MutableHandle<JSObject*>)
+T gjs_object_require_property(JSContext*, JS::Handle<JSObject*>, char const*, JS::Handle<jsid>, JS::MutableHandle<JS::Value>)
+T gjs_object_require_property(JSContext*, JS::Handle<JSObject*>, char const*, JS::Handle<jsid>, mozilla::UniquePtr<char [], JS::FreePolicy>*)
+T gjs_object_shutdown_toggle_queue()
 T gjs_open_bytes
+T gjs_param_from_g_param(JSContext*, _GParamSpec*)
 T gjs_param_spec_get_flags
 T gjs_param_spec_get_owner_type
 T gjs_param_spec_get_value_type
@@ -114,6 +252,48 @@
 T gjs_profiler_set_filename
 T gjs_profiler_start
 T gjs_profiler_stop
+T gjs_register_native_module(char const*, bool (*)(JSContext*, JS::MutableHandle<JSObject*>))
+T gjs_register_static_modules()
+T gjs_set_global_slot(JSContext*, GjsGlobalSlot, JS::Value)
 T gjs_setlocale
+T gjs_string_from_filename(JSContext*, char const*, long, JS::MutableHandle<JS::Value>)
+T gjs_string_from_ucs4(JSContext*, unsigned int const*, long, JS::MutableHandle<JS::Value>)
+T gjs_string_from_utf8(JSContext*, char const*, JS::MutableHandle<JS::Value>)
+T gjs_string_from_utf8_n(JSContext*, char const*, unsigned long, JS::MutableHandle<JS::Value>)
+T gjs_string_get_char16_data(JSContext*, JS::Handle<JSString*>, char16_t**, unsigned long*)
+T gjs_string_to_filename(JSContext*, JS::Value, GjsAutoPointer<char, char, &GjsAutoCharFuncs::free, &GjsAutoCharFuncs::dup>*)
+T gjs_string_to_ucs4(JSContext*, JS::Handle<JSString*>, unsigned int**, unsigned long*)
+T gjs_string_to_utf8(JSContext*, JS::Value, mozilla::UniquePtr<char [], JS::FreePolicy>*)
+T gjs_struct_foreign_convert_from_g_argument(JSContext*, JS::MutableHandle<JS::Value>, _GIBaseInfoStub*, _GIArgument*)
+T gjs_struct_foreign_convert_to_g_argument(JSContext*, JS::Value, _GIBaseInfoStub*, char const*, GjsArgumentType, GITransfer, bool, _GIArgument*)
+T gjs_struct_foreign_register(char const*, char const*, GjsForeignInfo*)
+T gjs_struct_foreign_release_g_argument(JSContext*, GITransfer, _GIBaseInfoStub*, _GIArgument*)
 T gjs_textdomain
-T modules_resources_get_resource
+T gjs_throw_abstract_constructor_error(JSContext*, JS::CallArgs&)
+T gjs_throw_constructor_error(JSContext*)
+T gjs_throw_custom(JSContext*, JSProtoKey, char const*, char const*, ...)
+T gjs_throw_gerror(JSContext*, _GError*)
+T gjs_throw_gerror_message(JSContext*, _GError*)
+T gjs_throw(JSContext*, char const*, ...)
+T gjs_throw_literal(JSContext*, char const*)
+T gjs_typecheck_gtype(JSContext*, JS::Handle<JSObject*>, bool)
+T gjs_typecheck_instance(JSContext*, JS::Handle<JSObject*>, JSClass const*, bool)
+T gjs_typecheck_param(JSContext*, JS::Handle<JSObject*>, unsigned long, bool)
+T gjs_unichar_from_string(JSContext*, JS::Value, unsigned int*)
+T gjs_union_from_c_union(JSContext*, _GIBaseInfoStub*, void*)
+T gjs_unix_shebang_len(std::__cxx11::basic_string<char16_t, std::char_traits<char16_t>, std::allocator<char16_t> > const&, unsigned int*)
+T gjs_utf8_script_to_utf16[abi:cxx11](char const*, long)
+T gjs_value_debug_string(JSContext*, JS::Handle<JS::Value>)
+T gjs_value_from_explicit_array(JSContext*, JS::MutableHandle<JS::Value>, _GIBaseInfoStub*, _GIArgument*, int)
+T gjs_value_from_g_argument(JSContext*, JS::MutableHandle<JS::Value>, _GIBaseInfoStub*, _GIArgument*, bool)
+T gjs_value_from_g_value(JSContext*, JS::MutableHandle<JS::Value>, _GValue const*)
+T gjs_value_to_arg(JSContext*, JS::Handle<JS::Value>, _GIBaseInfoStub*, _GIArgument*)
+T gjs_value_to_explicit_array(JSContext*, JS::Handle<JS::Value>, _GIBaseInfoStub*, _GIArgument*, unsigned long*)
+T gjs_value_to_g_argument(JSContext*, JS::Handle<JS::Value>, _GIBaseInfoStub*, char const*, GjsArgumentType, GITransfer, bool, _GIArgument*)
+T gjs_value_to_g_value(JSContext*, JS::Handle<JS::Value>, _GValue*)
+T gjs_value_to_g_value_no_copy(JSContext*, JS::Handle<JS::Value>, _GValue*)
+T gjs_warning_reporter(JSContext*, JSErrorReport*)
+T gjs_wrapper_define_gtype_prop(JSContext*, JS::Handle<JSObject*>, unsigned long)
+T gjs_wrapper_throw_nonexistent_field(JSContext*, unsigned long, char const*)
+T gjs_wrapper_throw_readonly_field(JSContext*, unsigned long, char const*)
+T gjs_wrapper_to_string_func(JSContext*, JSObject*, char const*, _GIBaseInfoStub*, unsigned long, void const*, JS::MutableHandle<JS::Value>)

I have to admit I don't understand this part; the C++ symbols must also be exported in the Autotools-built library somehow, or else the test programs wouldn't link. Maybe I'm not using the correct arguments to nm?

Merge request reports