From 9a3cfb413c95c17483bffb0e735bb8a744ccf313 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Thu, 9 Jan 2020 13:01:22 +0000
Subject: [PATCH] build: Consistently sort dependencies in stack order

It's slightly preferable to list linker and compiler flags in stack
order, with the lowest in the stack first. This allows use of a
higher-level library from a non-standard prefix without also necessarily
picking up lower-level libraries from the same non-standard-prefix.
For example, if /path/to/json-glib also includes a copy of GLib, then

    -L/path/to/glib -lglib-2.0 -L/path/to/json-glib -ljson-glib-1.0

will link the GLib from /path/to/glib, but

    -L/path/to/json-glib -ljson-glib-1.0 -L/path/to/glib -lglib-2.0

will link both the GLib and the json-glib from /path/to/json-glib.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 bin/meson.build                 | 2 +-
 helpers/meson.build             | 2 +-
 steam-runtime-tools/meson.build | 2 +-
 tests/meson.build               | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/bin/meson.build b/bin/meson.build
index 8761bde2f..c99713ded 100644
--- a/bin/meson.build
+++ b/bin/meson.build
@@ -24,7 +24,7 @@
 executable(
   'steam-runtime-system-info',
   'system-info.c',
-  dependencies : [glib, libsteamrt_dep, json_glib],
+  dependencies : [glib, json_glib, libsteamrt_dep],
   install : true,
   # Use the adjacent libsteam-runtime-tools and json-glib, ignoring
   # LD_LIBRARY_PATH even if set
diff --git a/helpers/meson.build b/helpers/meson.build
index 75dfd1544..c9fd9f63f 100644
--- a/helpers/meson.build
+++ b/helpers/meson.build
@@ -35,7 +35,7 @@ executable(
   multiarch + '-check-locale',
   'check-locale.c',
   include_directories : project_include_dirs,
-  dependencies : [json_glib, glib],
+  dependencies : [glib, json_glib],
   install : true,
   install_dir : pkglibexecdir,
   # Use json-glib and GLib from the adjacent libdir, ignoring LD_LIBRARY_PATH
diff --git a/steam-runtime-tools/meson.build b/steam-runtime-tools/meson.build
index 0df88ed5e..7f372c4f8 100644
--- a/steam-runtime-tools/meson.build
+++ b/steam-runtime-tools/meson.build
@@ -76,7 +76,7 @@ libsteamrt = library(
     '-D_SRT_API_MAJOR="' + api_major + '"',
   ],
   include_directories : project_include_dirs,
-  dependencies : [glib, gobject, libdl, json_glib, threads, libelf],
+  dependencies : [libdl, threads, libelf, glib, gobject, json_glib],
   soversion : abi_major,
   version : abi_major + '.' + abi_minor,
   install : true,
diff --git a/tests/meson.build b/tests/meson.build
index 47137cf2b..8a59c3c4d 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -86,7 +86,7 @@ foreach test_name : tests
     c_args : [
       '-D_SRT_MULTIARCH="' + multiarch + '"',
     ],
-    dependencies : [glib, gobject, libsteamrt_dep, json_glib],
+    dependencies : [glib, gobject, json_glib, libsteamrt_dep],
     include_directories : project_include_dirs,
     install : get_option('installed_tests'),
     install_dir : tests_dir,
-- 
GitLab