Skip to content

Commit 7ce0c1b

Browse files
committed
Add support for GIRepository-2.0.
This is needed to support cjs/mozjs 140+ and will be enabled at at build-time according to the cjs version provided.
1 parent 2ed098b commit 7ce0c1b

8 files changed

Lines changed: 55 additions & 10 deletions

File tree

js/misc/config.js.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ var PACKAGE_NAME = '@PACKAGE_NAME@';
66
var PACKAGE_VERSION = '@PACKAGE_VERSION@';
77
/* 1 if networkmanager is available, 0 otherwise */
88
var BUILT_NM_AGENT = @BUILT_NM_AGENT@;
9+
10+
var USE_GIR20 = @USE_GIR20@;

js/misc/fileUtils.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
22

3+
const config = imports.misc.config;
34
const Gio = imports.gi.Gio;
45
const GLib = imports.gi.GLib;
56
const ByteArray = imports.byteArray;
@@ -24,9 +25,19 @@ var cinnamonImportNames = [
2425
'misc',
2526
'perf'
2627
];
27-
var giImportNames = imports.gi.GIRepository.Repository
28-
.get_default()
29-
.get_loaded_namespaces();
28+
29+
var giImportNames = null;
30+
31+
if (config.USE_GIR20) {
32+
giImportNames = imports.gi.GIRepository.Repository
33+
.dup_default()
34+
.get_loaded_namespaces();
35+
} else {
36+
giImportNames = imports.gi.GIRepository.Repository
37+
.get_default()
38+
.get_loaded_namespaces();
39+
}
40+
3041
var LoadedModules = [];
3142
var FunctionConstructor = Symbol();
3243
var Symbols = {};

meson.build

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,25 @@ dbus = dependency('dbus-1')
2424
servicedir = dbus.get_variable(pkgconfig: 'session_bus_services_dir', pkgconfig_define: ['datadir', datadir])
2525

2626
# dependencies
27-
cjs = dependency('cjs-1.0', version: '>= 4.8.0')
27+
cjs = dependency('cjs-1.0', version: '>= 115.0')
2828
clutter = dependency('muffin-clutter-0')
2929
cmenu = dependency('libcinnamon-menu-3.0', version: '>= 4.8.0')
3030
cogl = dependency('muffin-cogl-0')
3131
cogl_path = dependency('muffin-cogl-path-0')
3232
gcr = dependency('gcr-base-3', version: '>= 3.7.5')
3333
gdkx11 = dependency('gdk-x11-3.0')
34-
gi = dependency('gobject-introspection-1.0', version: '>= 0.9.2')
3534
polkit = dependency('polkit-agent-1', version: '>= 0.100')
3635
atk = dependency('atk-bridge-2.0')
3736
gio = dependency('gio-2.0', version: '>= 2.36.0')
3837
gio_unix = dependency('gio-unix-2.0')
38+
39+
use_gir20 = false
40+
if cjs.version().version_compare('>= 139.9')
41+
gi = dependency('girepository-2.0', version: '>= 2.36.0')
42+
use_gir20 = true
43+
else
44+
gi = dependency('gobject-introspection-1.0', version: '>= 0.9.2')
45+
endif
3946
gl = dependency('gl')
4047
glib_version = '2.79.2'
4148
glib = dependency('glib-2.0', version: '>= ' + glib_version)
@@ -86,6 +93,7 @@ cinnamon_conf = configuration_data()
8693
cinnamon_conf.set_quoted('VERSION', version)
8794
cinnamon_conf.set_quoted('GETTEXT_PACKAGE', meson.project_name().to_lower())
8895
cinnamon_conf.set('BUILT_NM_AGENT', internal_nm_agent)
96+
cinnamon_conf.set10('USE_GIR20', use_gir20)
8997

9098
have_mallinfo = cc.has_function('mallinfo', prefix: '#include <malloc.h>')
9199
if have_mallinfo
@@ -161,6 +169,7 @@ config_js_conf = configuration_data()
161169
config_js_conf.set('PACKAGE_NAME', meson.project_name().to_lower())
162170
config_js_conf.set('PACKAGE_VERSION', version)
163171
config_js_conf.set10('BUILT_NM_AGENT', internal_nm_agent)
172+
config_js_conf.set10('USE_GIR20', use_gir20)
164173

165174
configure_file(
166175
input: 'js/misc/config.js.in',
@@ -169,7 +178,6 @@ configure_file(
169178
install_dir: 'share/cinnamon/js/misc/'
170179
)
171180

172-
173181
excluded_files = []
174182
if get_option('exclude_info_settings')
175183
excluded_files += ['usr/share/applications/cinnamon-settings-info.desktop']

src/cinnamon-generic-container.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
#include <clutter/clutter.h>
2121
#include <gtk/gtk.h>
22-
#include <girepository.h>
2322

2423
static void cinnamon_generic_container_iface_init (ClutterContainerIface *iface);
2524

src/cinnamon-global-private.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#ifndef __CINNAMON_GLOBAL_PRIVATE_H__
33
#define __CINNAMON_GLOBAL_PRIVATE_H__
44

5+
#include "config.h"
6+
57
#include <errno.h>
68
#include <math.h>
79
#include <stdarg.h>
@@ -10,7 +12,13 @@
1012

1113
#include "cinnamon-global.h"
1214
#include <gio/gio.h>
15+
16+
#if USE_GIR20
17+
#include <girepository/girepository.h>
18+
#else
1319
#include <girepository.h>
20+
#endif
21+
1422
#include <meta/meta-plugin.h>
1523

1624

src/cinnamon-global.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
22

3-
#include "config.h"
4-
53
#include <fcntl.h>
64

75
#include "cinnamon-global-private.h"

src/cinnamon-tray-manager.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include <clutter/clutter.h>
66
#include <clutter/x11/clutter-x11.h>
7-
#include <girepository.h>
87
#include <gtk/gtk.h>
98
#include <meta/display.h>
109
#include <meta/util.h>

src/main.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
#include <clutter/clutter.h>
1212
#include <dbus/dbus-shared.h>
1313
#include <glib/gi18n-lib.h>
14+
15+
#if USE_GIR20
16+
#include <girepository/girepository.h>
17+
#else
1418
#include <girepository.h>
19+
#endif
20+
1521
#include <meta/main.h>
1622
#include <meta/meta-plugin.h>
1723
#include <meta/prefs.h>
@@ -369,16 +375,30 @@ main (int argc, char **argv)
369375
cinnamon_a11y_init ();
370376
cinnamon_perf_log_init ();
371377

378+
#if USE_GIR20
379+
g_autoptr (GIRepository) repo = NULL;
380+
repo = gi_repository_dup_default ();
381+
382+
gi_repository_prepend_search_path (repo, CINNAMON_PKGLIBDIR);
383+
gi_repository_prepend_search_path (repo, MUFFIN_TYPELIB_DIR);
384+
#else
372385
g_irepository_prepend_search_path (CINNAMON_PKGLIBDIR);
373386
g_irepository_prepend_search_path (MUFFIN_TYPELIB_DIR);
387+
#endif
374388

375389
/* We need to explicitly add the directories where the private libraries are
376390
* installed to the GIR's library path, so that they can be found at runtime
377391
* when linking using DT_RUNPATH (instead of DT_RPATH), which is the default
378392
* for some linkers (e.g. gold) and in some distros (e.g. Debian).
379393
*/
394+
395+
#if USE_GIR20
396+
gi_repository_prepend_library_path (repo, CINNAMON_PKGLIBDIR);
397+
gi_repository_prepend_library_path (repo, MUFFIN_TYPELIB_DIR);
398+
#else
380399
g_irepository_prepend_library_path (CINNAMON_PKGLIBDIR);
381400
g_irepository_prepend_library_path (MUFFIN_TYPELIB_DIR);
401+
#endif
382402

383403
/* Disable debug spew from various libraries */
384404
g_log_set_handler ("Cvc", G_LOG_LEVEL_DEBUG,

0 commit comments

Comments
 (0)