[gtk] gtk: Speed up build
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] gtk: Speed up build
- Date: Fri, 1 Oct 2021 03:30:57 +0000 (UTC)
commit 802ad3920988d3d8104b9f438a820633a1ed76fd
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Sep 30 22:55:31 2021 -0400
gtk: Speed up build
Avoid serializing the gresource blob into a C string
and running gcc over it. Instead, use ld to put it
directly into an .o file and add it to the build.
The build system machinations here were copied from
gobject/tests/meson.build, and should ideally be part
of the meson gnome module.
gtk/meson.build | 85 +++++++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 74 insertions(+), 11 deletions(-)
---
diff --git a/gtk/meson.build b/gtk/meson.build
index bc097fdd6f..8907c1c6dd 100644
--- a/gtk/meson.build
+++ b/gtk/meson.build
@@ -863,17 +863,80 @@ if not fs.exists('theme/Default/Default-light.css')
endif
endif
-gtkresources = gnome.compile_resources('gtkresources',
- gtk_gresources_xml,
- dependencies: theme_deps,
- source_dir: [
- # List in order of preference
- meson.current_build_dir(),
- meson.current_source_dir(),
- ],
- c_name: '_gtk',
- extra_args: '--manual-register',
-)
+
+objcopy_supports_add_symbol = false
+objcopy = find_program('objcopy', required : false)
+if objcopy.found()
+ objcopy_supports_add_symbol = run_command(objcopy, '--help').stdout().contains('--add-symbol')
+endif
+
+ld = find_program('ld', required : false)
+
+if build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
+ glib_compile_resources = find_program('glib-compile-resources')
+
+ # Create the resource blob
+ gtk_gresource = custom_target('gtk.gresource',
+ input : gtk_gresources_xml,
+ depends : theme_deps,
+ output : 'gtk.gresource',
+ command : [glib_compile_resources,
+ '--target=@OUTPUT@',
+ '--sourcedir=' + meson.current_source_dir(),
+ '--sourcedir=' + meson.current_build_dir(),
+ '@INPUT@'])
+
+ # Create resource data file
+ gtk_resources_c = custom_target('gtk_resources.c',
+ input : gtk_gresources_xml,
+ depends : theme_deps,
+ output : 'gtk_resources.c',
+ command : [glib_compile_resources,
+ '--target=@OUTPUT@',
+ '--sourcedir=' + meson.current_source_dir(),
+ '--sourcedir=' + meson.current_build_dir(),
+ '--generate-source',
+ '--external-data',
+ '--c-name', '_gtk',
+ '--manual-register',
+ '@INPUT@'])
+
+ # Create object file containing resource data
+ gtk_resources_binary = custom_target('gtk_resources.o',
+ input : gtk_gresource,
+ output : 'gtk_resources.o',
+ command : [ld,
+ '-r',
+ '-b','binary',
+ '@INPUT@',
+ '-o','@OUTPUT@'])
+
+ # Rename symbol to match the one in the C file
+ gtk_resources_o = custom_target('gtk_resources2.o',
+ input : gtk_resources_binary,
+ output : 'gtk_resources2.o',
+ command : [objcopy,
+ '--add-symbol','_gtk_resource_data=.data:0',
+ '@INPUT@',
+ '@OUTPUT@'])
+
+ gtkresources = [
+ gtk_resources_c,
+ gtk_resources_o,
+ ]
+else
+ gtkresources = gnome.compile_resources('gtkresources',
+ gtk_gresources_xml,
+ dependencies: theme_deps,
+ source_dir: [
+ # List in order of preference
+ meson.current_build_dir(),
+ meson.current_source_dir(),
+ ],
+ c_name: '_gtk',
+ extra_args: '--manual-register',
+ )
+endif
foreach lang : [ 'de', 'fr', 'es', 'zh' ]
conf = configuration_data()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]