[evolution-data-server] Bug 793488 - Drop hard build dependency on python (and partly perl)
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 793488 - Drop hard build dependency on python (and partly perl)
- Date: Mon, 12 Mar 2018 13:12:19 +0000 (UTC)
commit a28389bae67f09a12e093998aa29956c66a7b359
Author: Milan Crha <mcrha redhat com>
Date: Mon Mar 12 14:12:17 2018 +0100
Bug 793488 - Drop hard build dependency on python (and partly perl)
There is still a perl build dependency, to install also
src/tools/addressbook-export/csv2vcard
script, but it's a soft dependency, because when the perl is not found,
then there's shown a warning during the configure time, but otherwise
the build continues with no problem.
CMakeLists.txt | 10 --
src/addressbook/libebook-contacts/CMakeLists.txt | 25 ++++-
.../libebook-contacts/gen-western-table.c | 122 +++++++++++++++++++
.../libebook-contacts/gen-western-table.py | 60 ---------
src/camel/CMakeLists.txt | 12 ++-
src/camel/camel-gen-tables.c | 127 ++++++++++++++++++++
src/camel/gentables.pl | 105 ----------------
7 files changed, 282 insertions(+), 179 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ccf1c37..d3aa802 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -292,16 +292,6 @@ if(NOT GPERF)
message(FATAL_ERROR "You need gperf to build ${PROJECT_NAME}")
endif(NOT GPERF)
-find_program(PERL perl)
-if(NOT PERL)
- message(FATAL_ERROR "You need perl to build ${PROJECT_NAME}")
-endif(NOT PERL)
-
-find_program(PYTHON python3 python2 python)
-if(NOT PYTHON)
- message(FATAL_ERROR "You need python to build ${PROJECT_NAME}")
-endif(NOT PYTHON)
-
# ******************************
# db_load checking, it's optional
# ******************************
diff --git a/src/addressbook/libebook-contacts/CMakeLists.txt
b/src/addressbook/libebook-contacts/CMakeLists.txt
index 2eb9087..76486ca 100644
--- a/src/addressbook/libebook-contacts/CMakeLists.txt
+++ b/src/addressbook/libebook-contacts/CMakeLists.txt
@@ -2,10 +2,31 @@ glib_mkenums(e-book-contacts-enumtypes e-book-contacts-types.h E_BOOK_CONTACTS_E
add_pkgconfig_file(libebook-contacts.pc.in libebook-contacts-${API_VERSION}.pc)
+add_executable(gen-western-table
+ gen-western-table.c
+)
+
+target_compile_definitions(gen-western-table PRIVATE
+ -DG_LOG_DOMAIN=\"gen-western-table\"
+)
+
+target_compile_options(gen-western-table PUBLIC
+ ${GNOME_PLATFORM_CFLAGS}
+)
+
+target_include_directories(gen-western-table PUBLIC
+ ${CMAKE_BINARY_DIR}
+ ${GNOME_PLATFORM_INCLUDE_DIRS}
+)
+
+target_link_libraries(gen-western-table
+ ${GNOME_PLATFORM_LDFLAGS}
+)
+
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/e-name-western-tables.h
- COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/gen-western-table.py
<${CMAKE_CURRENT_SOURCE_DIR}/e-name-western-tables.h.in >${CMAKE_CURRENT_BINARY_DIR}/e-name-western-tables.h
- DEPENDS gen-western-table.py e-name-western-tables.h.in
+ COMMAND ${CMAKE_CURRENT_BINARY_DIR}/gen-western-table
"${CMAKE_CURRENT_SOURCE_DIR}/e-name-western-tables.h.in" >${CMAKE_CURRENT_BINARY_DIR}/e-name-western-tables.h
+ DEPENDS gen-western-table e-name-western-tables.h.in
)
set(DEPENDENCIES
diff --git a/src/addressbook/libebook-contacts/gen-western-table.c
b/src/addressbook/libebook-contacts/gen-western-table.c
new file mode 100644
index 0000000..3648139
--- /dev/null
+++ b/src/addressbook/libebook-contacts/gen-western-table.c
@@ -0,0 +1,122 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2018 Red Hat, Inc. (www.redhat.com)
+ *
+ * This library is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "evolution-data-server-config.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+
+static void
+output (const gchar *varname,
+ GSList *strings)
+{
+ GSList *link;
+ gint index;
+
+ g_return_if_fail (varname != NULL);
+ g_return_if_fail (strings != NULL);
+
+ printf ("static const gchar %s_table[] = {\n", varname);
+ for (link = strings; link; link = g_slist_next (link)) {
+ const gchar *str = link->data;
+
+ printf (" \"%s\\0\"\n", str);
+ }
+ printf ("};\n");
+
+ index = 0;
+
+ printf ("static const guint %s_index[] = {\n", varname);
+ for (link = strings; link; link = g_slist_next (link)) {
+ const gchar *str = link->data;
+
+ printf (" %d,\n", index);
+
+ index += strlen (str) + 1;
+ }
+ printf ("};\n\n");
+}
+
+typedef enum {
+ STATE_VAR,
+ STATE_STRING
+} State;
+
+static void
+process_content (const gchar *content)
+{
+ State state = STATE_VAR;
+ const gchar *varname = NULL;
+ GSList *strings = NULL;
+ gchar **lines;
+ gint ii;
+
+ printf ("/* This file is generated by gen-western-table. DO NOT EDIT */\n");
+
+ lines = g_strsplit (content, "\n", -1);
+
+ for (ii = 0; lines && lines[ii]; ii++) {
+ gchar *line = lines[ii];
+
+ if (!*line) {
+ strings = g_slist_reverse (strings);
+ output (varname, strings);
+ state = STATE_VAR;
+ varname = NULL;
+ g_slist_free (strings);
+ strings = NULL;
+ } else if (state == STATE_VAR) {
+ varname = line;
+ state = STATE_STRING;
+ } else if (state == STATE_STRING) {
+ strings = g_slist_prepend (strings, line);
+ } else {
+ g_warn_if_reached ();
+ }
+ }
+
+ g_strfreev (lines);
+
+ g_warn_if_fail (state == STATE_VAR);
+ g_warn_if_fail (strings == NULL);
+}
+
+gint
+main (gint argc,
+ gchar *argv[])
+{
+ GError *error = NULL;
+ gchar *contents = NULL;
+
+ if (argc != 2) {
+ g_warning ("Expects one argument, input file with western tables description");
+ return 1;
+ }
+
+ if (!g_file_get_contents (argv[1], &contents, NULL, &error) || !contents || error) {
+ g_warning ("Failed to read '%s': %s\n", argv[1], error ? error->message : "Unknown error");
+ g_clear_error (&error);
+ return 2;
+ }
+
+ process_content (contents);
+
+ g_free (contents);
+
+ return 0;
+}
diff --git a/src/camel/CMakeLists.txt b/src/camel/CMakeLists.txt
index 743f129..74070df 100644
--- a/src/camel/CMakeLists.txt
+++ b/src/camel/CMakeLists.txt
@@ -1,9 +1,17 @@
glib_mkenums(camel-enumtypes camel-enums.h CAMEL_ENUMTYPES_H)
+add_executable(camel-gen-tables
+ camel-gen-tables.c
+)
+
+target_include_directories(camel-gen-tables PUBLIC
+ ${CMAKE_BINARY_DIR}
+)
+
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/camel-mime-tables.c
- COMMAND ${PERL} ${CMAKE_CURRENT_SOURCE_DIR}/gentables.pl
${CMAKE_CURRENT_BINARY_DIR}/camel-mime-tables.c
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gentables.pl
+ COMMAND ${CMAKE_CURRENT_BINARY_DIR}/camel-gen-tables >${CMAKE_CURRENT_BINARY_DIR}/camel-mime-tables.c
+ DEPENDS camel-gen-tables
)
set(SOURCES
diff --git a/src/camel/camel-gen-tables.c b/src/camel/camel-gen-tables.c
new file mode 100644
index 0000000..7e1c9e6
--- /dev/null
+++ b/src/camel/camel-gen-tables.c
@@ -0,0 +1,127 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2018 Red Hat, Inc. (www.redhat.com)
+ *
+ * This library is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "evolution-data-server-config.h"
+
+#include <stdio.h>
+
+#define CHARS_LWSP " \t\n\r"
+#define CHARS_TSPECIAL "()<>@,;:\\\"/[]?="
+#define CHARS_SPECIAL "()<>@,;:\\\".[]"
+#define CHARS_CSPECIAL "()\\\r" /* not in comments */
+#define CHARS_DSPECIAL "[]\\\r \t" /* not in domains */
+#define CHARS_ATTRCHAR "*\'% " /* extra non-included attribute-chars */
+
+enum {
+ CAMEL_MIME_IS_CTRL = 1 << 0,
+ CAMEL_MIME_IS_LWSP = 1 << 1,
+ CAMEL_MIME_IS_TSPECIAL = 1 << 2,
+ CAMEL_MIME_IS_SPECIAL = 1 << 3,
+ CAMEL_MIME_IS_SPACE = 1 << 4,
+ CAMEL_MIME_IS_DSPECIAL = 1 << 5,
+ CAMEL_MIME_IS_QPSAFE = 1 << 6,
+ CAMEL_MIME_IS_ESAFE = 1 << 7, /* encoded word safe */
+ CAMEL_MIME_IS_PSAFE = 1 << 8, /* encoded word in phrase safe */
+ CAMEL_MIME_IS_ATTRCHAR = 1 << 9 /* attribute-char safe (rfc2184) */
+};
+
+/* set bit in character positions */
+static void
+add_bits (unsigned short table[256],
+ unsigned short bit,
+ const char *chars)
+{
+ while (*chars) {
+ unsigned short pos = (unsigned short) (*chars);
+ table[pos] |= bit;
+ chars++;
+ }
+}
+
+/* remove bit in character positions */
+static void
+rem_bits (unsigned short table[256],
+ unsigned short bit,
+ const char *chars)
+{
+ while (*chars) {
+ unsigned short pos = (unsigned short) (*chars);
+ table[pos] = (table[pos]) & (~bit);
+ chars++;
+ }
+}
+
+int
+main (int argc,
+ char *argv[])
+{
+ unsigned short table[256];
+ int ii;
+
+ /* set up base ranges */
+ for (ii = 0; ii < 256; ii++) {
+ table[ii] = 0;
+ if (ii < 32 || ii == 127) {
+ table[ii] |= CAMEL_MIME_IS_CTRL | CAMEL_MIME_IS_TSPECIAL;
+ } else if (ii < 127) {
+ table[ii] |= CAMEL_MIME_IS_ATTRCHAR;
+ }
+ if ((ii >= 32 && ii <= 60) || (ii >= 62 && ii <= 126) || ii == 9) {
+ table[ii] |= CAMEL_MIME_IS_QPSAFE | CAMEL_MIME_IS_ESAFE;
+ }
+ if ((ii >= 0x30 && ii <= 0x39) || (ii >= 0x61 && ii <= 0x7a) || (ii >= 0x41 && ii <= 0x5a)) {
+ table[ii] |= CAMEL_MIME_IS_PSAFE;
+ }
+ }
+
+ table[0x20] |= CAMEL_MIME_IS_SPACE;
+
+ add_bits (table, CAMEL_MIME_IS_LWSP, CHARS_LWSP);
+ add_bits (table, CAMEL_MIME_IS_TSPECIAL, CHARS_TSPECIAL);
+ add_bits (table, CAMEL_MIME_IS_SPECIAL, CHARS_SPECIAL);
+ /* not in domains */
+ add_bits (table, CAMEL_MIME_IS_DSPECIAL, CHARS_DSPECIAL);
+
+ /* list of characters that must be encoded.
+ * encoded word in text specials: rfc 2047 5(1) */
+ rem_bits (table, CAMEL_MIME_IS_ESAFE, "()<>@,;:\"/[]?.=_");
+
+ /* non-included attribute-chars (tspecial + extra) */
+ rem_bits (table, CAMEL_MIME_IS_ATTRCHAR, CHARS_ATTRCHAR CHARS_TSPECIAL);
+
+ /* list of additional characters that can be left unencoded.
+ * encoded word in phrase specials: rfc 2047 5(3) */
+ add_bits (table, CAMEL_MIME_IS_PSAFE, "!*+-/");
+
+ /* output */
+ printf ("/* This file is generated by camel-gen-tables. DO NOT EDIT */\n\n");
+ printf ("const unsigned short camel_mime_special_table[256] = {\n\t");
+ for (ii = 0; ii < 256; ii++) {
+ printf ("0x%04x,", table[ii]);
+ if ((ii & 0x7) == 0x7) {
+ printf ("\n");
+ if (ii != 0xff) {
+ printf ("\t");
+ }
+ } else {
+ printf (" ");
+ }
+ }
+ printf ("};\n");
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]