Skip to content

Commit ece84a2

Browse files
committed
Merge branch 'require-cairo' into 'master'
build: Build Cairo from subproject if not found See merge request GNOME/gjs!941
2 parents e2ce720 + 215ffb7 commit ece84a2

File tree

8 files changed

+51
-101
lines changed

8 files changed

+51
-101
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,7 @@ build_minimal:
150150
stage: test
151151
image: registry.gitlab.gnome.org/gnome/gjs:fedora.mozjs115
152152
variables:
153-
CONFIG_OPTS: >-
154-
-Dbuildtype=release
155-
-Dcairo=disabled -Dreadline=disabled -Dprofiler=disabled
153+
CONFIG_OPTS: -Dbuildtype=release -Dreadline=disabled -Dprofiler=disabled
156154
TEST_OPTS: --setup=verbose
157155
except:
158156
- schedules

doc/CPP_Style_Guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ its functionality is no longer used in the file.
432432
Here is an example of all of the above rules together:
433433
434434
```c++
435-
#include <config.h> // for ENABLE_CAIRO
435+
#include <config.h> // for ENABLE_PROFILER
436436
437437
#include <string.h> // for strlen
438438

gjs/context.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,11 @@
9393
#include "gjs/profiler.h"
9494
#include "gjs/promise.h"
9595
#include "gjs/text-encoding.h"
96+
#include "modules/cairo-module.h"
9697
#include "modules/console.h"
9798
#include "modules/print.h"
9899
#include "modules/system.h"
99100
#include "util/log.h"
100-
#ifdef ENABLE_CAIRO
101-
# include "modules/cairo-module.h"
102-
#endif
103101

104102
namespace mozilla {
105103
union Utf8Unit;
@@ -345,9 +343,7 @@ gjs_context_class_init(GjsContextClass *klass)
345343
registry.add("_encodingNative", gjs_define_text_encoding_stuff);
346344
registry.add("_gi", gjs_define_private_gi_stuff);
347345
registry.add("gi", gjs_define_repo);
348-
#ifdef ENABLE_CAIRO
349346
registry.add("cairoNative", gjs_js_define_cairo_stuff);
350-
#endif
351347
registry.add("system", gjs_js_define_system_stuff);
352348
registry.add("console", gjs_define_console_stuff);
353349
registry.add("_print", gjs_define_print_stuff);

installed-tests/js/meson.build

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,9 @@ else
5252
test_gir_warning_c_args += ['-Wno-error']
5353
endif
5454

55-
regress_dependencies = [glib, gobject, gio]
56-
regress_gir_includes = ['Gio-2.0']
55+
regress_dependencies = [glib, gobject, gio, cairo, cairo_gobject]
56+
regress_gir_includes = ['Gio-2.0', 'cairo-1.0']
5757
regress_gir_c_args = test_gir_extra_c_args
58-
if build_cairo
59-
regress_gir_includes += 'cairo-1.0'
60-
regress_dependencies += [cairo, cairo_gobject]
61-
else
62-
regress_gir_c_args += ['-D_GI_DISABLE_CAIRO']
63-
endif
6458

6559
libregress = library('regress', regress_sources,
6660
c_args: regress_gir_c_args + test_gir_warning_c_args,
@@ -108,6 +102,7 @@ subdir('libgjstesttools')
108102

109103
jasmine_tests = [
110104
'self',
105+
'Cairo',
111106
'Exceptions',
112107
'Format',
113108
'Fundamental',
@@ -140,10 +135,6 @@ jasmine_tests = [
140135
'WarnLib',
141136
]
142137

143-
if build_cairo
144-
jasmine_tests += 'Cairo'
145-
endif
146-
147138
if not get_option('skip_gtk_tests')
148139
jasmine_tests += [
149140
'Gtk3',
@@ -236,6 +227,7 @@ endforeach
236227

237228
modules_tests = [
238229
'Async',
230+
'CairoModule',
239231
'Console',
240232
'ESModules',
241233
'AsyncMainloop',
@@ -245,9 +237,6 @@ modules_tests = [
245237
'Timers',
246238
'WeakRef',
247239
]
248-
if build_cairo
249-
modules_tests += 'CairoModule'
250-
endif
251240

252241
foreach test : modules_tests
253242
test_file = files('test@[email protected]'.format(test))

meson.build

Lines changed: 29 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -137,30 +137,12 @@ gio = dependency('gio-2.0', version: glib_required_version,
137137
ffi = dependency('libffi', fallback: ['libffi', 'ffi_dep'])
138138
gi = dependency('gobject-introspection-1.0', version: '>= 1.66.0',
139139
fallback: ['gobject-introspection', 'girepo_dep'])
140+
cairo = dependency('cairo', fallback: ['cairo', 'libcairo_dep'])
141+
cairo_gobject = dependency('cairo-gobject',
142+
fallback: ['cairo', 'libcairogobject_dep'])
143+
cairo_xlib = dependency('cairo-xlib', required: false)
140144
spidermonkey = dependency('mozjs-115')
141145

142-
# We might need to look for the headers and lib's for Cairo
143-
# manually on MSVC/clang-cl builds...
144-
if get_option('cairo').disabled()
145-
# dummy not-found dependency since we break the tristate feature in the else block
146-
cairo = dependency('', required: false)
147-
cairo_gobject = cairo
148-
cairo_xlib = cairo
149-
else
150-
cairo = dependency('cairo', required: get_option('cairo').enabled() and cxx.get_argument_syntax() != 'msvc')
151-
cairo_gobject = dependency('cairo-gobject', required: cairo.found() and cxx.get_argument_syntax() != 'msvc')
152-
cairo_xlib = dependency('cairo-xlib', required: false)
153-
endif
154-
155-
if cxx.get_argument_syntax() == 'msvc' and not get_option('cairo').disabled()
156-
if not cairo.found()
157-
cairo = cc.find_library('cairo', has_headers: ['cairo.h'], required: get_option('cairo').enabled())
158-
endif
159-
if not cairo_gobject.found()
160-
cairo_gobject = cc.find_library('cairo-gobject', has_headers: ['cairo-gobject.h'], required: cairo.found())
161-
endif
162-
endif
163-
164146
sysprof_capture = dependency('sysprof-capture-4',
165147
required: get_option('profiler'), include_type: 'system',
166148
fallback: ['sysprof', 'libsysprof_capture_dep'],
@@ -241,7 +223,6 @@ it on other platforms.''')
241223
endif
242224
endif
243225

244-
build_cairo = cairo.found()
245226
build_readline = readline.found()
246227

247228
### Check for library features #################################################
@@ -334,8 +315,6 @@ header_conf.set('GJS_VERSION', int_version,
334315
header_conf.set_quoted('PACKAGE_STRING', '@0@ @1@'.format(meson.project_name(),
335316
meson.project_version()))
336317

337-
header_conf.set('ENABLE_CAIRO', build_cairo,
338-
description: 'Build with Cairo support')
339318
header_conf.set('ENABLE_PROFILER', build_profiler,
340319
description: 'Build the profiler')
341320
# COMPAT: SpiderMonkey headers in some places use DEBUG instead of JS_DEBUG
@@ -451,6 +430,23 @@ libgjs_sources = [
451430
'modules/console.cpp', 'modules/console.h',
452431
'modules/print.cpp', 'modules/print.h',
453432
'modules/system.cpp', 'modules/system.h',
433+
'modules/cairo-private.h',
434+
'modules/cairo-module.h',
435+
'modules/cairo-region.cpp',
436+
'modules/cairo-context.cpp',
437+
'modules/cairo-path.cpp',
438+
'modules/cairo-surface.cpp',
439+
'modules/cairo-image-surface.cpp',
440+
'modules/cairo-ps-surface.cpp',
441+
'modules/cairo-pdf-surface.cpp',
442+
'modules/cairo-svg-surface.cpp',
443+
'modules/cairo-pattern.cpp',
444+
'modules/cairo-gradient.cpp',
445+
'modules/cairo-linear-gradient.cpp',
446+
'modules/cairo-radial-gradient.cpp',
447+
'modules/cairo-surface-pattern.cpp',
448+
'modules/cairo-solid-pattern.cpp',
449+
'modules/cairo.cpp',
454450
]
455451

456452
# GjsPrivate introspection sources
@@ -473,54 +469,20 @@ libgjs_jsapi_sources = [
473469
'util/misc.cpp', 'util/misc.h',
474470
]
475471

476-
module_cairo_srcs = [
477-
'modules/cairo-private.h',
478-
'modules/cairo-module.h',
479-
'modules/cairo-region.cpp',
480-
'modules/cairo-context.cpp',
481-
'modules/cairo-path.cpp',
482-
'modules/cairo-surface.cpp',
483-
'modules/cairo-image-surface.cpp',
484-
'modules/cairo-ps-surface.cpp',
485-
'modules/cairo-pdf-surface.cpp',
486-
'modules/cairo-svg-surface.cpp',
487-
'modules/cairo-pattern.cpp',
488-
'modules/cairo-gradient.cpp',
489-
'modules/cairo-linear-gradient.cpp',
490-
'modules/cairo-radial-gradient.cpp',
491-
'modules/cairo-surface-pattern.cpp',
492-
'modules/cairo-solid-pattern.cpp',
493-
'modules/cairo.cpp',
494-
]
495-
496472
module_resource_srcs = gnome.compile_resources('js-resources',
497473
'js.gresource.xml',
498474
c_name: 'js_resources')
499475
module_resource_lib = static_library('js-resources', module_resource_srcs,
500476
dependencies: gio, override_options: ['unity=off'])
501477

502-
libgjs_dependencies = [glib, gobject, gthread, gio, gi, ffi, spidermonkey,
503-
readline, libatomic]
504-
pkg_dependencies = [glib, gobject, gthread, gio, gi, ffi, spidermonkey]
505-
libraries_private = []
506-
507-
if build_cairo
508-
libgjs_sources += module_cairo_srcs
509-
libgjs_dependencies += [cairo, cairo_gobject]
510-
if cairo.type_name() == 'pkgconfig'
511-
pkg_dependencies += [cairo]
512-
elif cairo.type_name() == 'library'
513-
libraries_private += cairo
514-
endif
515-
if cairo_gobject.type_name() == 'pkgconfig'
516-
pkg_dependencies += [cairo_gobject]
517-
elif cairo_gobject.type_name() == 'library'
518-
libraries_private += cairo_gobject
519-
endif
520-
if cairo_xlib.found()
521-
libgjs_dependencies += cairo_xlib
522-
pkg_dependencies += cairo_xlib
523-
endif
478+
libgjs_dependencies = [glib, gobject, gthread, gio, gi, ffi, cairo,
479+
cairo_gobject, spidermonkey, readline, libatomic]
480+
pkg_dependencies = [glib, gobject, gthread, gio, gi, ffi, cairo, cairo_gobject,
481+
spidermonkey]
482+
483+
if cairo_xlib.found()
484+
libgjs_dependencies += cairo_xlib
485+
pkg_dependencies += cairo_xlib
524486
endif
525487

526488
if build_readline
@@ -624,7 +586,6 @@ endif
624586

625587
pkg.generate(libgjs, name: api_name, description: 'JS bindings for GObjects',
626588
requires: [glib, gobject, gio], requires_private: pkg_dependencies,
627-
libraries_private: libraries_private,
628589
subdirs: api_name,
629590
variables: [
630591
'exec_prefix=${prefix}',
@@ -752,10 +713,6 @@ building a debug or debugoptimized build. This will make development more
752713
difficult. Consider reconfiguring SpiderMonkey with --enable-debug.''')
753714
endif
754715

755-
if not build_cairo
756-
warning('Building without Cairo support, not all tests will be run.')
757-
endif
758-
759716
if get_option('skip_gtk_tests')
760717
warning('Not using GTK, not all tests will be run.')
761718
endif
@@ -806,7 +763,6 @@ summary({
806763
'Precompiled headers': get_option('b_pch'),
807764
}, section: 'Build options', bool_yn: true)
808765
summary({
809-
'Cairo module': build_cairo,
810766
'Use readline for input': build_readline,
811767
'Profiler (Linux only)': build_profiler,
812768
'Dtrace debugging': get_option('dtrace'),

meson_options.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
# Features
55

6-
option('cairo', type: 'feature', value: 'auto',
7-
description: 'Build cairo module')
86
option('readline', type: 'feature', value: 'auto',
97
description: 'Use readline for input in interactive shell and debugger')
108
option('profiler', type: 'feature', value: 'auto',

subprojects/cairo.wrap

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
2+
# SPDX-FileCopyrightText: 2024 Philip Chimento <[email protected]>
3+
4+
[wrap-git]
5+
directory = cairo
6+
url = https://gitlab.freedesktop.org/cairo/cairo.git
7+
push-url = [email protected]:cairo/cairo.git
8+
revision = master
9+
depth = 1
10+
11+
[provide]
12+
cairo = libcairo_dep
13+
cairo-gobject = libcairogobject_dep

test/test-ci.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ if test "$1" = "SETUP"; then
149149
elif test "$1" = "BUILD"; then
150150
do_Set_Env
151151

152-
DEFAULT_CONFIG_OPTS="-Dcairo=enabled -Dreadline=enabled -Dprofiler=enabled \
153-
-Ddtrace=false -Dsystemtap=false -Dverbose_logs=false --werror"
152+
DEFAULT_CONFIG_OPTS="-Dreadline=enabled -Dprofiler=enabled -Ddtrace=false \
153+
-Dsystemtap=false -Dverbose_logs=false --werror"
154154
meson setup _build $DEFAULT_CONFIG_OPTS $CONFIG_OPTS
155155
ninja -C _build
156156

0 commit comments

Comments
 (0)