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
=== modified file 'debian/changelog'
--- debian/changelog 2017-02-09 12:47:56 +0000
+++ debian/changelog 2017-02-13 18:15:21 +0000
@@ -1,3 +1,10 @@
1cmake-extras (1.2-0ubuntu1) UNRELEASED; urgency=medium
2
3 * Add autopkgtest for gsettings macro.
4 * Handle generated gschema files. (LP: #1661686)
5
6 -- Rodney Dawes <rodney.dawes@canonical.com> Fri, 10 Feb 2017 18:01:37 -0500
7
1cmake-extras (1.1+17.04.20170209-0ubuntu1) zesty; urgency=medium8cmake-extras (1.1+17.04.20170209-0ubuntu1) zesty; urgency=medium
29
3 [ Pete ]10 [ Pete ]
411
=== modified file 'debian/tests/control'
--- debian/tests/control 2017-02-09 10:55:03 +0000
+++ debian/tests/control 2017-02-13 18:15:21 +0000
@@ -45,3 +45,13 @@
45 libglib2.0-dev,45 libglib2.0-dev,
46 pkg-config,46 pkg-config,
47 python-clang-3.8,47 python-clang-3.8,
48
49Tests: gsettings
50Restrictions: allow-stderr
51Depends:
52 build-essential,
53 cmake,
54 cmake-extras,
55 libglib2.0-dev,
56 pkg-config,
57 uuid-runtime,
4858
=== added file 'debian/tests/gsettings'
--- debian/tests/gsettings 1970-01-01 00:00:00 +0000
+++ debian/tests/gsettings 2017-02-13 18:15:21 +0000
@@ -0,0 +1,53 @@
1#!/bin/bash
2
3# autopkgtest check: Build a trivial project that uses the
4# find_package(GSettings) macro.
5# (C) 2017 Canonical Ltd.
6
7set -euo pipefail
8IFS=$'\n\t'
9
10tempdir=$(mktemp --tmpdir="${AUTOPKGTEST_TMP:-/tmp}" -d)
11trap "rm -rf $tempdir" 0 INT QUIT ABRT PIPE TERM
12
13demodir="$(pwd)/examples/gsettings-demo"
14srcdir="${tempdir}/source"
15bindir="${tempdir}/build"
16installdir="${tempdir}/install"
17
18cp -r "${demodir}" "${srcdir}"
19mkdir -p "${bindir}"
20
21DEFAULT_UUID=$(uuidgen)
22
23# Move into bindir temporarily
24(
25 cd "${bindir}"
26 cmake "${srcdir}" -DCMAKE_INSTALL_PREFIX="${installdir}" -DGSETTINGS_LOCALINSTALL=1 -DGSETTINGS_COMPILE=1 -DDEFAULT_UUID_VALUE=${DEFAULT_UUID}
27 make
28 make VERBOSE=1 install
29)
30
31### Test the schemas
32export GSETTINGS_SCHEMA_DIR="${installdir}/share/glib-2.0/schemas"
33
34# verify generated schema
35VALUE=$(gsettings get com.canonical.cmake-extras.generated-test install-id)
36
37if [ "x${VALUE}" != "x'${DEFAULT_UUID}'" ]; then
38 echo "Generated schema is wrong."
39 echo "\tActual: ${VALUE}"
40 echo "\tExpected: '${DEFAULT_UUID}'"
41 exit 1
42fi
43
44# verify static schema
45VALUE=$(gsettings get com.canonical.cmake-extras.static-test use-gsettings)
46
47EXPECTED=false
48if [ ${VALUE} != ${EXPECTED} ]; then
49 echo "Generated schema is wrong."
50 echo "\tActual: ${VALUE}"
51 echo "\tExpected: ${EXPECTED}"
52 exit 1
53fi
054
=== added directory 'examples/gsettings-demo'
=== added file 'examples/gsettings-demo/CMakeLists.txt'
--- examples/gsettings-demo/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ examples/gsettings-demo/CMakeLists.txt 2017-02-13 18:15:21 +0000
@@ -0,0 +1,13 @@
1cmake_minimum_required(VERSION 3.1)
2project(intltool-demo)
3
4include(GNUInstallDirs)
5find_package(GSettings)
6
7set (DEFAULT_UUID_VALUE "" CACHE STRING "Default UUID to use in schema.")
8set (DEFAULT_UUID "'${DEFAULT_UUID_VALUE}'")
9
10add_schema ("static.gschema.xml")
11
12configure_file ("generated.gschema.xml.in" "generated.gschema.xml")
13add_schema ("generated.gschema.xml")
014
=== added file 'examples/gsettings-demo/generated.gschema.xml.in'
--- examples/gsettings-demo/generated.gschema.xml.in 1970-01-01 00:00:00 +0000
+++ examples/gsettings-demo/generated.gschema.xml.in 2017-02-13 18:15:21 +0000
@@ -0,0 +1,9 @@
1<schemalist>
2 <schema id="com.canonical.cmake-extras.generated-test" path="/com/canonical/cmake-extras/generated-test/">
3 <key name="install-id" type="s">
4 <default>@DEFAULT_UUID@</default>
5 <summary>Just a test</summary>
6 <description>No really, it's just a test.</description>
7 </key>
8 </schema>
9</schemalist>
010
=== added file 'examples/gsettings-demo/static.gschema.xml'
--- examples/gsettings-demo/static.gschema.xml 1970-01-01 00:00:00 +0000
+++ examples/gsettings-demo/static.gschema.xml 2017-02-13 18:15:21 +0000
@@ -0,0 +1,9 @@
1<schemalist>
2 <schema id="com.canonical.cmake-extras.static-test" path="/com/canonical/cmake-extras/static-test/">
3 <key name="use-gsettings" type="b">
4 <default>false</default>
5 <summary>Just a test</summary>
6 <description>No really, it's just a test.</description>
7 </key>
8 </schema>
9</schemalist>
010
=== modified file 'src/GSettings/GSettingsConfig.cmake'
--- src/GSettings/GSettingsConfig.cmake 2016-12-07 15:30:09 +0000
+++ src/GSettings/GSettingsConfig.cmake 2017-02-13 18:15:21 +0000
@@ -23,9 +23,16 @@
23 SET (GSETTINGS_DIR "${_glib_prefix}/share/glib-2.0/schemas/")23 SET (GSETTINGS_DIR "${_glib_prefix}/share/glib-2.0/schemas/")
24 endif (GSETTINGS_LOCALINSTALL)24 endif (GSETTINGS_LOCALINSTALL)
2525
26 # Use the correct schema file as it may be generated
27 if (EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${SCHEMA_NAME})
28 set (SCHEMA_FILE "${CMAKE_CURRENT_BINARY_DIR}/${SCHEMA_NAME}")
29 else ()
30 set (SCHEMA_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME}")
31 endif ()
32
26 # Run the validator and error if it fails33 # Run the validator and error if it fails
27 execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE _glib_comple_schemas OUTPUT_STRIP_TRAILING_WHITESPACE)34 execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE _glib_comple_schemas OUTPUT_STRIP_TRAILING_WHITESPACE)
28 execute_process (COMMAND ${_glib_comple_schemas} --dry-run --schema-file=${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME} ERROR_VARIABLE _schemas_invalid OUTPUT_STRIP_TRAILING_WHITESPACE)35 execute_process (COMMAND ${_glib_comple_schemas} --dry-run --schema-file=${SCHEMA_FILE} ERROR_VARIABLE _schemas_invalid OUTPUT_STRIP_TRAILING_WHITESPACE)
2936
30 if (_schemas_invalid)37 if (_schemas_invalid)
31 message (SEND_ERROR "Schema validation error: ${_schemas_invalid}")38 message (SEND_ERROR "Schema validation error: ${_schemas_invalid}")
@@ -33,7 +40,7 @@
3340
34 # Actually install and recomple schemas41 # Actually install and recomple schemas
35 message (STATUS "GSettings schemas will be installed into ${GSETTINGS_DIR}")42 message (STATUS "GSettings schemas will be installed into ${GSETTINGS_DIR}")
36 install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME} DESTINATION ${GSETTINGS_DIR} OPTIONAL)43 install (FILES ${SCHEMA_FILE} DESTINATION ${GSETTINGS_DIR} OPTIONAL)
3744
38 if (GSETTINGS_COMPILE)45 if (GSETTINGS_COMPILE)
39 install (CODE "message (STATUS \"Compiling GSettings schemas\")")46 install (CODE "message (STATUS \"Compiling GSettings schemas\")")

Subscribers

People subscribed via source and target branches

to all changes: