1 Return-Path: <bremner@tethera.net>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by arlo.cworth.org (Postfix) with ESMTP id D82BD6DE092E
\r
6 for <notmuch@notmuchmail.org>; Sat, 30 Apr 2016 18:25:05 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=-0.015 tagged_above=-999 required=5
\r
12 tests=[AWL=-0.004, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01]
\r
14 Received: from arlo.cworth.org ([127.0.0.1])
\r
15 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id xjT_tt67AqQ5 for <notmuch@notmuchmail.org>;
\r
17 Sat, 30 Apr 2016 18:24:58 -0700 (PDT)
\r
18 Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])
\r
19 by arlo.cworth.org (Postfix) with ESMTPS id D74D86DE02AF
\r
20 for <notmuch@notmuchmail.org>; Sat, 30 Apr 2016 18:24:48 -0700 (PDT)
\r
21 Received: from remotemail by fethera.tethera.net with local (Exim 4.84)
\r
22 (envelope-from <bremner@tethera.net>)
\r
23 id 1awg7n-0006bj-Rf; Sat, 30 Apr 2016 21:24:43 -0400
\r
24 Received: (nullmailer pid 29943 invoked by uid 1000);
\r
25 Sun, 01 May 2016 01:24:43 -0000
\r
26 From: David Bremner <david@tethera.net>
\r
27 To: notmuch@notmuchmail.org
\r
28 Subject: [Patch v3 03/11] lib/cli: add library API / CLI for compile time
\r
30 Date: Sat, 30 Apr 2016 22:24:31 -0300
\r
31 Message-Id: <1462065879-29860-4-git-send-email-david@tethera.net>
\r
32 X-Mailer: git-send-email 2.8.0.rc3
\r
33 In-Reply-To: <1462065879-29860-1-git-send-email-david@tethera.net>
\r
34 References: <1462065879-29860-1-git-send-email-david@tethera.net>
\r
36 Content-Type: text/plain; charset=UTF-8
\r
37 Content-Transfer-Encoding: 8bit
\r
38 X-BeenThere: notmuch@notmuchmail.org
\r
39 X-Mailman-Version: 2.1.20
\r
41 List-Id: "Use and development of the notmuch mail system."
\r
42 <notmuch.notmuchmail.org>
\r
43 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,
\r
44 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
46 List-Post: <mailto:notmuch@notmuchmail.org>
\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
48 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
50 X-List-Received-Date: Sun, 01 May 2016 01:25:05 -0000
\r
52 This is intentionally low tech; if we have more than two options it may
\r
53 make sense to build up what infrastructure is provided.
\r
55 doc/man1/notmuch-config.rst | 5 +++++
\r
56 lib/Makefile.local | 1 +
\r
57 lib/built-with.c | 33 +++++++++++++++++++++++++++++++++
\r
58 lib/notmuch.h | 5 +++++
\r
59 notmuch-config.c | 22 ++++++++++++++++++++++
\r
60 test/T030-config.sh | 6 ++++--
\r
61 test/T040-setup.sh | 6 ++++--
\r
62 test/test-lib.sh | 6 ++++++
\r
63 8 files changed, 80 insertions(+), 4 deletions(-)
\r
64 create mode 100644 lib/built-with.c
\r
66 diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst
\r
67 index 40c1272..26a8eb1 100644
\r
68 --- a/doc/man1/notmuch-config.rst
\r
69 +++ b/doc/man1/notmuch-config.rst
\r
70 @@ -132,6 +132,11 @@ The available configuration items are described below.
\r
74 + **built_with.<name>**
\r
76 + Compile time feature <name>. Current possibilities include
\r
77 + "compact" (see **notmuch-compact(1)**)
\r
78 + and "field_processor" (see **notmuch-search-terms(7)**).
\r
82 diff --git a/lib/Makefile.local b/lib/Makefile.local
\r
83 index 3a07090..36c3924 100644
\r
84 --- a/lib/Makefile.local
\r
85 +++ b/lib/Makefile.local
\r
86 @@ -39,6 +39,7 @@ libnotmuch_c_srcs = \
\r
87 $(dir)/message-file.c \
\r
90 + $(dir)/built-with.c \
\r
93 libnotmuch_cxx_srcs = \
\r
94 diff --git a/lib/built-with.c b/lib/built-with.c
\r
95 new file mode 100644
\r
96 index 0000000..b619bed
\r
98 +++ b/lib/built-with.c
\r
100 +/* notmuch - Not much of an email program, (just index and search)
\r
102 + * Copyright © 2016 David Bremner
\r
104 + * This program is free software: you can redistribute it and/or modify
\r
105 + * it under the terms of the GNU General Public License as published by
\r
106 + * the Free Software Foundation, either version 3 of the License, or
\r
107 + * (at your option) any later version.
\r
109 + * This program is distributed in the hope that it will be useful,
\r
110 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
111 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
112 + * GNU General Public License for more details.
\r
114 + * You should have received a copy of the GNU General Public License
\r
115 + * along with this program. If not, see http://www.gnu.org/licenses/ .
\r
117 + * Author: David Bremner <david@tethera.net>
\r
120 +#include "notmuch.h"
\r
121 +#include "notmuch-private.h"
\r
124 +notmuch_built_with (const char *name) {
\r
125 + if (STRNCMP_LITERAL (name, "compact") == 0) {
\r
126 + return HAVE_XAPIAN_COMPACT;
\r
127 + } else if (STRNCMP_LITERAL (name, "field_processor") == 0) {
\r
128 + return HAVE_XAPIAN_FIELD_PROCESSOR;
\r
133 diff --git a/lib/notmuch.h b/lib/notmuch.h
\r
134 index cb46fc0..3a092ef 100644
\r
135 --- a/lib/notmuch.h
\r
136 +++ b/lib/notmuch.h
\r
137 @@ -1838,6 +1838,11 @@ notmuch_filenames_move_to_next (notmuch_filenames_t *filenames);
\r
139 notmuch_filenames_destroy (notmuch_filenames_t *filenames);
\r
142 + * interrogate the library for compile time features
\r
145 +notmuch_built_with (const char *name);
\r
149 diff --git a/notmuch-config.c b/notmuch-config.c
\r
150 index d252bb2..97a46fa 100644
\r
151 --- a/notmuch-config.c
\r
152 +++ b/notmuch-config.c
\r
153 @@ -750,6 +750,8 @@ _item_split (char *item, char **group, char **key)
\r
157 +#define BUILT_WITH_PREFIX "built_with."
\r
160 notmuch_config_command_get (notmuch_config_t *config, char *item)
\r
162 @@ -773,6 +775,9 @@ notmuch_config_command_get (notmuch_config_t *config, char *item)
\r
163 tags = notmuch_config_get_new_tags (config, &length);
\r
164 for (i = 0; i < length; i++)
\r
165 printf ("%s\n", tags[i]);
\r
166 + } else if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) {
\r
168 + notmuch_built_with (item + strlen (BUILT_WITH_PREFIX)) ? "true" : "false");
\r
172 @@ -804,6 +809,11 @@ notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char
\r
176 + if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) {
\r
177 + fprintf (stderr, "Error: read only option: %s\n", item);
\r
181 if (_item_split (item, &group, &key))
\r
184 @@ -830,6 +840,17 @@ notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char
\r
185 return notmuch_config_save (config);
\r
190 +_notmuch_config_list_options () {
\r
191 + printf("%scompact=%s\n",
\r
192 + BUILT_WITH_PREFIX,
\r
193 + notmuch_built_with ("compact") ? "true" : "false");
\r
194 + printf("%sfield_processor=%s\n",
\r
195 + BUILT_WITH_PREFIX,
\r
196 + notmuch_built_with ("field_processor") ? "true" : "false");
\r
200 notmuch_config_command_list (notmuch_config_t *config)
\r
202 @@ -865,6 +886,7 @@ notmuch_config_command_list (notmuch_config_t *config)
\r
204 g_strfreev (groups);
\r
206 + _notmuch_config_list_options ();
\r
210 diff --git a/test/T030-config.sh b/test/T030-config.sh
\r
211 index f404908..a4e24c3 100755
\r
212 --- a/test/T030-config.sh
\r
213 +++ b/test/T030-config.sh
\r
214 @@ -44,7 +44,7 @@ test_expect_equal "$(notmuch config get foo.nonexistent)" ""
\r
216 test_begin_subtest "List all items"
\r
217 notmuch config set database.path "/canonical/path"
\r
218 -output=$(notmuch config list)
\r
219 +output=$(notmuch config list | notmuch_options_sanitize)
\r
220 test_expect_equal "$output" "\
\r
221 database.path=/canonical/path
\r
222 user.name=Notmuch Test Suite
\r
223 @@ -56,7 +56,9 @@ search.exclude_tags=
\r
224 maildir.synchronize_flags=true
\r
225 crypto.gpg_path=gpg
\r
226 foo.string=this is another string value
\r
227 -foo.list=this;is another;list value;"
\r
228 +foo.list=this;is another;list value;
\r
229 +built_with.compact=something
\r
230 +built_with.field_processor=something"
\r
232 test_begin_subtest "Top level --config=FILE option"
\r
233 cp "${NOTMUCH_CONFIG}" alt-config
\r
234 diff --git a/test/T040-setup.sh b/test/T040-setup.sh
\r
235 index cf0c00b..be2f0db 100755
\r
236 --- a/test/T040-setup.sh
\r
237 +++ b/test/T040-setup.sh
\r
238 @@ -19,7 +19,7 @@ another.suite@example.com
\r
242 -output=$(notmuch --config=new-notmuch-config config list)
\r
243 +output=$(notmuch --config=new-notmuch-config config list | notmuch_built_with_sanitize)
\r
244 test_expect_equal "$output" "\
\r
245 database.path=/path/to/maildir
\r
246 user.name=Test Suite
\r
247 @@ -29,6 +29,8 @@ new.tags=foo;bar;
\r
249 search.exclude_tags=baz;
\r
250 maildir.synchronize_flags=true
\r
251 -crypto.gpg_path=gpg"
\r
252 +crypto.gpg_path=gpg
\r
253 +built_with.compact=something
\r
254 +built_with.field_processor=something"
\r
257 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
258 index ac04b15..09f8731 100644
\r
259 --- a/test/test-lib.sh
\r
260 +++ b/test/test-lib.sh
\r
261 @@ -733,6 +733,12 @@ notmuch_uuid_sanitize ()
\r
263 sed 's/[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}/UUID/g'
\r
266 +notmuch_built_with_sanitize ()
\r
268 + sed 's/^built_with[.]\(.*\)=.*$/built_with.\1=something/'
\r
271 # End of notmuch helper functions
\r
273 # Use test_set_prereq to tell that a particular prerequisite is available.
\r