Merge lp:~pete-woods/cmake-extras/add-intltool-filter-option into lp:cmake-extras

Proposed by Pete Woods
Status: Merged
Approved by: Pete Woods
Approved revision: 64
Merged at revision: 60
Proposed branch: lp:~pete-woods/cmake-extras/add-intltool-filter-option
Merge into: lp:cmake-extras
Prerequisite: lp:~pete-woods/cmake-extras/add-include-checker-macros
Diff against target: 108 lines (+35/-5)
5 files modified
debian/changelog (+1/-0)
debian/tests/intltool (+5/-3)
examples/intltool-demo/po/CMakeLists.txt (+1/-0)
examples/intltool-demo/test/test.cpp (+1/-0)
src/Intltool/IntltoolConfig.cmake (+27/-2)
To merge this branch: bzr merge lp:~pete-woods/cmake-extras/add-intltool-filter-option
Reviewer Review Type Date Requested Status
dobey (community) Approve
Review via email: mp+316732@code.launchpad.net

Commit message

Add FILTER argument to intltool macros.

Description of the change

Add FILTER argument to intltool macros.

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

Nice.

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:39:48 +0000
3+++ debian/changelog 2017-02-09 12:39:48 +0000
4@@ -1,6 +1,7 @@
5 cmake-extras (1.1-0ubuntu1) UNRELEASED; urgency=medium
6
7 * Add IncludeChecker macro.
8+ * Add FILTER argument to intltool macros.
9
10 -- Pete <pete.woods@canonical.com> Wed, 08 Feb 2017 15:02:38 +0000
11
12
13=== modified file 'debian/tests/intltool'
14--- debian/tests/intltool 2017-01-09 10:35:11 +0000
15+++ debian/tests/intltool 2017-02-09 12:39:48 +0000
16@@ -38,18 +38,20 @@
17 retval=$?
18 set -e
19
20- if [ ${retval} -eq 0 ]; then
21+ expected=${2:-0}
22+
23+ if [ ${retval} -eq ${expected} ]; then
24 echo "OK"
25 else
26 echo "FAILED"
27+ return 1
28 fi
29-
30- return ${retval}
31 }
32
33 check_potfile 'msgid "FooApp"'
34 check_potfile 'msgid "FooApp is really great"'
35 check_potfile 'msgid "Hello FooApp!"'
36+check_potfile 'msgid "this translation should be ignored"' 1
37
38 # This binary is a test suite that will exit this outer BASH script if it fails
39 G_MESSAGES_DEBUG=all "${installdir}/usr/bin/fooapp"
40
41=== modified file 'examples/intltool-demo/po/CMakeLists.txt'
42--- examples/intltool-demo/po/CMakeLists.txt 2017-01-09 10:35:11 +0000
43+++ examples/intltool-demo/po/CMakeLists.txt 2017-02-09 12:39:48 +0000
44@@ -6,6 +6,7 @@
45 POTFILES_TEMPLATE "POTFILES.in.in"
46 GETTEXT_PACKAGE ${GETTEXT_PACKAGE}
47 COPYRIGHT_HOLDER "Foocorp Ltd."
48+ FILTER ".*test.*"
49 )
50
51 intltool_install_translations(
52
53=== added directory 'examples/intltool-demo/test'
54=== added file 'examples/intltool-demo/test/test.cpp'
55--- examples/intltool-demo/test/test.cpp 1970-01-01 00:00:00 +0000
56+++ examples/intltool-demo/test/test.cpp 2017-02-09 12:39:48 +0000
57@@ -0,0 +1,1 @@
58+_("this translation should be ignored")
59
60=== modified file 'src/Intltool/IntltoolConfig.cmake'
61--- src/Intltool/IntltoolConfig.cmake 2016-12-02 05:58:34 +0000
62+++ src/Intltool/IntltoolConfig.cmake 2017-02-09 12:39:48 +0000
63@@ -155,10 +155,32 @@
64 set(${OUTPUT} "${_TMP}" PARENT_SCOPE)
65 endfunction()
66
67+function(_INTLTOOL_LIST_FILTER INPUT OUTPUT)
68+ set(_multiValueArgs EXPRESSIONS)
69+ cmake_parse_arguments(_ARG "" "" "${_multiValueArgs}" ${ARGN})
70+
71+ if(_ARG_EXPRESSIONS)
72+ set(_TMP "")
73+ foreach(_ITEM ${${INPUT}})
74+ foreach(_REGEX ${_ARG_EXPRESSIONS})
75+ if("${_ITEM}" MATCHES "${_REGEX}")
76+ else()
77+ list(APPEND _TMP "${_ITEM}")
78+ endif()
79+ endforeach()
80+ endforeach()
81+ set(${OUTPUT} "${_TMP}" PARENT_SCOPE)
82+ unset(_TMP)
83+ else()
84+ set(${OUTPUT} "${${INPUT}}" PARENT_SCOPE)
85+ endif()
86+endfunction()
87+
88+
89 function(INTLTOOL_UPDATE_POTFILE)
90 set(_options ALL UBUNTU_SDK_DEFAULTS)
91 set(_oneValueArgs COPYRIGHT_HOLDER GETTEXT_PACKAGE OUTPUT_FILE PO_DIRECTORY POTFILES_TEMPLATE)
92- set(_multiValueArgs KEYWORDS FILE_GLOBS)
93+ set(_multiValueArgs KEYWORDS FILE_GLOBS FILTER)
94
95 cmake_parse_arguments(_ARG "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
96
97@@ -213,7 +235,10 @@
98 )
99
100 # We don't want to include paths from the binary directory
101- _intltool_exclude_path(_SOURCE_FILES ${CMAKE_BINARY_DIR} _FILTERED_SOURCE_FILES)
102+ _intltool_exclude_path(_SOURCE_FILES ${CMAKE_BINARY_DIR} _FILTERED_SOURCE_FILES_TMP)
103+
104+ # Remove any paths from the filter expressions
105+ _intltool_list_filter(_FILTERED_SOURCE_FILES_TMP _FILTERED_SOURCE_FILES EXPRESSIONS ${_ARG_FILTER})
106
107 # Build the text to substitute into the POTFILES.in
108 _intltool_join_list(_FILTERED_SOURCE_FILES "\n" GENERATED_POTFILES)

Subscribers

People subscribed via source and target branches

to all changes: