Merge lp:~dobey/cmake-extras/fix-gsettings into lp:cmake-extras

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 65
Merged at revision: 62
Proposed branch: lp:~dobey/cmake-extras/fix-gsettings
Merge into: lp:cmake-extras
Diff against target: 168 lines (+110/-2)
7 files modified
debian/changelog (+7/-0)
debian/tests/control (+10/-0)
debian/tests/gsettings (+53/-0)
examples/gsettings-demo/CMakeLists.txt (+13/-0)
examples/gsettings-demo/generated.gschema.xml.in (+9/-0)
examples/gsettings-demo/static.gschema.xml (+9/-0)
src/GSettings/GSettingsConfig.cmake (+9/-2)
To merge this branch: bzr merge lp:~dobey/cmake-extras/fix-gsettings
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
Pete Woods Approve
Review via email: mp+317012@code.launchpad.net

Commit message

Check for gsettings schema file in binary dir first.
Add autopkgtest for testing the gsettings module.

To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) wrote :

I understand this is a work in progress, but I'd like to see more complete tests before this lands

Revision history for this message
dobey (dobey) wrote :

> I understand this is a work in progress, but I'd like to see more complete
> tests before this lands

And done.

Revision history for this message
Pete Woods (pete-woods) :
review: Approve
Revision history for this message
Charles Kerr (charlesk) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2017-02-09 12:47:56 +0000
3+++ debian/changelog 2017-02-13 18:15:21 +0000
4@@ -1,3 +1,10 @@
5+cmake-extras (1.2-0ubuntu1) UNRELEASED; urgency=medium
6+
7+ * Add autopkgtest for gsettings macro.
8+ * Handle generated gschema files. (LP: #1661686)
9+
10+ -- Rodney Dawes <rodney.dawes@canonical.com> Fri, 10 Feb 2017 18:01:37 -0500
11+
12 cmake-extras (1.1+17.04.20170209-0ubuntu1) zesty; urgency=medium
13
14 [ Pete ]
15
16=== modified file 'debian/tests/control'
17--- debian/tests/control 2017-02-09 10:55:03 +0000
18+++ debian/tests/control 2017-02-13 18:15:21 +0000
19@@ -45,3 +45,13 @@
20 libglib2.0-dev,
21 pkg-config,
22 python-clang-3.8,
23+
24+Tests: gsettings
25+Restrictions: allow-stderr
26+Depends:
27+ build-essential,
28+ cmake,
29+ cmake-extras,
30+ libglib2.0-dev,
31+ pkg-config,
32+ uuid-runtime,
33
34=== added file 'debian/tests/gsettings'
35--- debian/tests/gsettings 1970-01-01 00:00:00 +0000
36+++ debian/tests/gsettings 2017-02-13 18:15:21 +0000
37@@ -0,0 +1,53 @@
38+#!/bin/bash
39+
40+# autopkgtest check: Build a trivial project that uses the
41+# find_package(GSettings) macro.
42+# (C) 2017 Canonical Ltd.
43+
44+set -euo pipefail
45+IFS=$'\n\t'
46+
47+tempdir=$(mktemp --tmpdir="${AUTOPKGTEST_TMP:-/tmp}" -d)
48+trap "rm -rf $tempdir" 0 INT QUIT ABRT PIPE TERM
49+
50+demodir="$(pwd)/examples/gsettings-demo"
51+srcdir="${tempdir}/source"
52+bindir="${tempdir}/build"
53+installdir="${tempdir}/install"
54+
55+cp -r "${demodir}" "${srcdir}"
56+mkdir -p "${bindir}"
57+
58+DEFAULT_UUID=$(uuidgen)
59+
60+# Move into bindir temporarily
61+(
62+ cd "${bindir}"
63+ cmake "${srcdir}" -DCMAKE_INSTALL_PREFIX="${installdir}" -DGSETTINGS_LOCALINSTALL=1 -DGSETTINGS_COMPILE=1 -DDEFAULT_UUID_VALUE=${DEFAULT_UUID}
64+ make
65+ make VERBOSE=1 install
66+)
67+
68+### Test the schemas
69+export GSETTINGS_SCHEMA_DIR="${installdir}/share/glib-2.0/schemas"
70+
71+# verify generated schema
72+VALUE=$(gsettings get com.canonical.cmake-extras.generated-test install-id)
73+
74+if [ "x${VALUE}" != "x'${DEFAULT_UUID}'" ]; then
75+ echo "Generated schema is wrong."
76+ echo "\tActual: ${VALUE}"
77+ echo "\tExpected: '${DEFAULT_UUID}'"
78+ exit 1
79+fi
80+
81+# verify static schema
82+VALUE=$(gsettings get com.canonical.cmake-extras.static-test use-gsettings)
83+
84+EXPECTED=false
85+if [ ${VALUE} != ${EXPECTED} ]; then
86+ echo "Generated schema is wrong."
87+ echo "\tActual: ${VALUE}"
88+ echo "\tExpected: ${EXPECTED}"
89+ exit 1
90+fi
91
92=== added directory 'examples/gsettings-demo'
93=== added file 'examples/gsettings-demo/CMakeLists.txt'
94--- examples/gsettings-demo/CMakeLists.txt 1970-01-01 00:00:00 +0000
95+++ examples/gsettings-demo/CMakeLists.txt 2017-02-13 18:15:21 +0000
96@@ -0,0 +1,13 @@
97+cmake_minimum_required(VERSION 3.1)
98+project(intltool-demo)
99+
100+include(GNUInstallDirs)
101+find_package(GSettings)
102+
103+set (DEFAULT_UUID_VALUE "" CACHE STRING "Default UUID to use in schema.")
104+set (DEFAULT_UUID "'${DEFAULT_UUID_VALUE}'")
105+
106+add_schema ("static.gschema.xml")
107+
108+configure_file ("generated.gschema.xml.in" "generated.gschema.xml")
109+add_schema ("generated.gschema.xml")
110
111=== added file 'examples/gsettings-demo/generated.gschema.xml.in'
112--- examples/gsettings-demo/generated.gschema.xml.in 1970-01-01 00:00:00 +0000
113+++ examples/gsettings-demo/generated.gschema.xml.in 2017-02-13 18:15:21 +0000
114@@ -0,0 +1,9 @@
115+<schemalist>
116+ <schema id="com.canonical.cmake-extras.generated-test" path="/com/canonical/cmake-extras/generated-test/">
117+ <key name="install-id" type="s">
118+ <default>@DEFAULT_UUID@</default>
119+ <summary>Just a test</summary>
120+ <description>No really, it's just a test.</description>
121+ </key>
122+ </schema>
123+</schemalist>
124
125=== added file 'examples/gsettings-demo/static.gschema.xml'
126--- examples/gsettings-demo/static.gschema.xml 1970-01-01 00:00:00 +0000
127+++ examples/gsettings-demo/static.gschema.xml 2017-02-13 18:15:21 +0000
128@@ -0,0 +1,9 @@
129+<schemalist>
130+ <schema id="com.canonical.cmake-extras.static-test" path="/com/canonical/cmake-extras/static-test/">
131+ <key name="use-gsettings" type="b">
132+ <default>false</default>
133+ <summary>Just a test</summary>
134+ <description>No really, it's just a test.</description>
135+ </key>
136+ </schema>
137+</schemalist>
138
139=== modified file 'src/GSettings/GSettingsConfig.cmake'
140--- src/GSettings/GSettingsConfig.cmake 2016-12-07 15:30:09 +0000
141+++ src/GSettings/GSettingsConfig.cmake 2017-02-13 18:15:21 +0000
142@@ -23,9 +23,16 @@
143 SET (GSETTINGS_DIR "${_glib_prefix}/share/glib-2.0/schemas/")
144 endif (GSETTINGS_LOCALINSTALL)
145
146+ # Use the correct schema file as it may be generated
147+ if (EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${SCHEMA_NAME})
148+ set (SCHEMA_FILE "${CMAKE_CURRENT_BINARY_DIR}/${SCHEMA_NAME}")
149+ else ()
150+ set (SCHEMA_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME}")
151+ endif ()
152+
153 # Run the validator and error if it fails
154 execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE _glib_comple_schemas OUTPUT_STRIP_TRAILING_WHITESPACE)
155- execute_process (COMMAND ${_glib_comple_schemas} --dry-run --schema-file=${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME} ERROR_VARIABLE _schemas_invalid OUTPUT_STRIP_TRAILING_WHITESPACE)
156+ execute_process (COMMAND ${_glib_comple_schemas} --dry-run --schema-file=${SCHEMA_FILE} ERROR_VARIABLE _schemas_invalid OUTPUT_STRIP_TRAILING_WHITESPACE)
157
158 if (_schemas_invalid)
159 message (SEND_ERROR "Schema validation error: ${_schemas_invalid}")
160@@ -33,7 +40,7 @@
161
162 # Actually install and recomple schemas
163 message (STATUS "GSettings schemas will be installed into ${GSETTINGS_DIR}")
164- install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME} DESTINATION ${GSETTINGS_DIR} OPTIONAL)
165+ install (FILES ${SCHEMA_FILE} DESTINATION ${GSETTINGS_DIR} OPTIONAL)
166
167 if (GSETTINGS_COMPILE)
168 install (CODE "message (STATUS \"Compiling GSettings schemas\")")

Subscribers

People subscribed via source and target branches

to all changes: