build: Move objcopy checks to one place
authorMatthias Clasen <mclasen@redhat.com>
Wed, 28 Jun 2023 11:11:01 +0000 (07:11 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 28 Jun 2023 11:11:51 +0000 (07:11 -0400)
We were doing the same thing in three places.
Move it to the toplevel meson.build, so we
can change it in one place.

demos/gtk-demo/meson.build
demos/widget-factory/meson.build
gtk/meson.build
meson.build

index b1a4b525140360b119df69e971f52e8d62250720..a464e6e0a864f666c30ec02cf1698f6dd9585d1e 100644 (file)
@@ -158,17 +158,7 @@ demos_h = custom_target('gtk4 demo header',
   command: [ find_program('geninclude.py'), '@OUTPUT@', '@INPUT@' ],
 )
 
-objcopy_supports_add_symbol = false
-objcopy = find_program('objcopy', required : false)
-if objcopy.found()
-  objcopy_supports_add_symbol = run_command(objcopy, '--help', check: false).stdout().contains('--add-symbol')
-endif
-
-ld = find_program('ld', required : false)
-
-if not meson.is_cross_build() and build_machine.cpu_family() != 'arm' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
-  glib_compile_resources = find_program('glib-compile-resources')
-
+if can_use_objcopy_for_resources
   # Create the resource blob
   gtkdemo_gresource = custom_target('gtkdemo.gresource',
       input : 'demo.gresource.xml',
index bc4bb294783eab6911317762a83a590113267e5b..8e61c2486923a9b69cca993568bacff84d8bac16 100644 (file)
@@ -1,16 +1,6 @@
 # demos/widget-factory
 
-objcopy_supports_add_symbol = false
-objcopy = find_program('objcopy', required : false)
-if objcopy.found()
-  objcopy_supports_add_symbol = run_command(objcopy, '--help', check: false).stdout().contains('--add-symbol')
-endif
-
-ld = find_program('ld', required : false)
-
-if not meson.is_cross_build() and build_machine.cpu_family() != 'arm' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
-  glib_compile_resources = find_program('glib-compile-resources')
-
+if can_use_objcopy_for_resources
   # Create the resource blob
   widgetfactory_gresource = custom_target('widgetfactory.gresource',
       input : 'widget-factory.gresource.xml',
index 80ed4cae160d0f6d70b2f3b8e1645d72aa8abf35..19bc2212772dbf18dccfbf7a62f853d8a0b4d4ca 100644 (file)
@@ -758,17 +758,7 @@ if not fs.exists('theme/Default/Default-light.css')
 endif
 
 
-objcopy_supports_add_symbol = false
-objcopy = find_program('objcopy', required : false)
-if objcopy.found()
-  objcopy_supports_add_symbol = run_command(objcopy, '--help', check: false).stdout().contains('--add-symbol')
-endif
-
-ld = find_program('ld', required : false)
-
-if not meson.is_cross_build() and build_machine.cpu_family() == 'x86_64' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
-  glib_compile_resources = find_program('glib-compile-resources')
-
+if can_use_objcopy_for_resources
   # Create the resource blob
   gtk_gresource = custom_target('gtk.gresource',
       input : gtk_gresources_xml,
index 2959a8dbfe84b55c128065f04d1ab6d1ca2d0130..c0c605f5ce31180ac9ac94d90880348e29ee29b7 100644 (file)
@@ -737,6 +737,23 @@ endif
 build_gir = gir.found() and (get_option('introspection').enabled() or
                              (get_option('introspection').allowed() and get_option('gtk_doc')))
 
+# Resource building
+glib_compile_resources = find_program('glib-compile-resources')
+
+objcopy_supports_add_symbol = false
+objcopy = find_program('objcopy', required : false)
+if objcopy.found()
+  objcopy_supports_add_symbol = run_command(objcopy, '--help', check: false).stdout().contains('--add-symbol')
+endif
+
+ld = find_program('ld', required : false)
+
+if not meson.is_cross_build() and build_machine.cpu_family() == 'x86_64' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
+  can_use_objcopy_for_resources = true
+else
+  can_use_objcopy_for_resources = false
+endif
+
 project_build_root = meson.current_build_dir()
 
 gen_visibility_macros = find_program('build-aux/meson/gen-visibility-macros.py')