[gucharmap] unicode: Remove generated sources
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gucharmap] unicode: Remove generated sources
- Date: Thu, 3 Mar 2016 18:01:51 +0000 (UTC)
commit 8abd62c462b9a45c5ed182b35fbb27e3242cb1b0
Author: Christian Persch <chpe gnome org>
Date: Thu Mar 3 19:01:01 2016 +0100
unicode: Remove generated sources
Instead of putting the generated sources in git and the tarballs,
generate them at build time from data either provided in a directory
with --with-unicode-data=DIRECTORY or downloaded (and checksum-
checked) from unicode.org. The only generated file to remain in
git is unicode-i18n.h dummy file which contains the translatable
strings, for extraction by gettext.
configure.ac | 50 +-
gucharmap/Makefile.am | 74 +-
gucharmap/download-unicode-files.sh | 23 -
gucharmap/gen-guch-unicode-tables.pl | 36 +-
gucharmap/gucharmap-script-codepoint-list.c | 2 +
gucharmap/gucharmap-unicode-info.c | 2 +
gucharmap/unicode-blocks.h | 551 -
gucharmap/unicode-categories.h | 2978 -
gucharmap/unicode-names.h |58398 ----------
gucharmap/unicode-nameslist.h |34642 ------
gucharmap/unicode-scripts.h | 2153 -
gucharmap/unicode-unihan.h |166062 ---------------------------
gucharmap/unicode-versions.h | 1396 -
gucharmap/unicode.sha512sums | 6 +
14 files changed, 120 insertions(+), 266253 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e0980c9..321dc4f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
-# Free Software Foundation; either version 2 of the License, or (at your
+# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
@@ -148,6 +148,7 @@ fi
# Some utilities
AC_PROG_LN_S
+AC_PROG_SED
AC_ARG_VAR([GLIB_COMPILE_RESOURCES],[the glib-compile-resources programme])
AC_PATH_PROG([GLIB_COMPILE_RESOURCES],[glib-compile-resources],[false])
@@ -155,28 +156,55 @@ if test "$GLIB_COMPILE_RESOURCES" = "false"; then
AC_MSG_ERROR([glib-compile-resources not found])
fi
-# AC_PATH_PROG([GTK_BUILDER_CONVERT],[gtk-builder-convert],[false])
-# if test "$GTK_BUILDER_CONVERT" = "false"; then
-# AC_MSG_ERROR([gtk-builder-convert not found])
-# fi
-
AC_ARG_VAR([XMLLINT],[the xmllint programme])
AC_PATH_PROG([XMLLINT],[xmllint],[false])
if test "$XMLLINT" = "false"; then
AC_MSG_ERROR([xmllint not found])
fi
-# AC_PATH_PROG([HEXDUMP],[hexdump],[false])
-# if test "$HEXDUMP" = "false"; then
-# AC_MSG_ERROR([hexdump not found])
-# fi
-
AC_ARG_VAR([DESKTOP_FILE_VALIDATE],[the desktop-file-validate programme])
AC_PATH_PROG([DESKTOP_FILE_VALIDATE],[desktop-file-validate],[])
if test -z "$DESKTOP_FILE_VALIDATE"; then
AC_MSG_ERROR([desktop-file-validate not found])
fi
+# Unicode data
+
+AC_MSG_CHECKING([for Unicode data])
+AC_ARG_WITH([unicode-data],
+ [AS_HELP_STRING([--with-unicode-data=none],[Specify absolute directory where the Unicode data files
reside. If 'none', downloads the files to the build directory.])],
+ [unicodedatadir="$(readlink -f $withval)"
+ with_provided_unicode_data="yes (from $unicodedatadir)"],
+ [unicodedatadir='${builddir}'
+ with_provided_unicode_data=no])
+AC_MSG_RESULT([$with_provided_unicode_data])
+
+AM_CONDITIONAL([WITH_UNICODE_DATA],[test "$with_provided_unicode_data" != "no"])
+AC_SUBST([unicodedatadir])
+
+# If we don't have a directory where we can find Unicode data in, we need to download it.
+# For that, we need some utilities
+
+# Note! Not using UNZIP as variable name here since unzip itself
+# uses the UNZIP env var and interprets it as its options.
+AC_ARG_VAR([PROG_UNZIP],[the unzip programme])
+AC_PATH_PROG([PROG_UNZIP],[unzip],[false])
+if test "$PROG_UNZIP" = "false"; then
+ AC_MSG_ERROR([unzip not found])
+fi
+
+AC_ARG_VAR([WGET],[the wget programme])
+AC_PATH_PROG([WGET],[wget],[false])
+if test "$with_provided_unicode_data" = "no" -a "$WGET" = "false"; then
+ AC_MSG_ERROR([wget not found])
+fi
+
+AC_ARG_VAR([SHA512SUM],[the sha512sum programme])
+AC_PATH_PROG([SHA512SUM],[sha512sum],[false])
+if test "$with_provided_unicode_data" = "no" -a "$WGET" = "false"; then
+ AC_MSG_ERROR([sha512sum not found])
+fi
+
# ****
# i18n
# ****
diff --git a/gucharmap/Makefile.am b/gucharmap/Makefile.am
index ac2282d..6d5758c 100644
--- a/gucharmap/Makefile.am
+++ b/gucharmap/Makefile.am
@@ -1,9 +1,9 @@
## Copyright © 2003 Noah Levitt
-## Copyright © 2008 Christian Persch
+## Copyright © 2008, 2016 Christian Persch
##
## This program is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by the
-## Free Software Foundation; either version 2 of the License, or (at your
+## Free Software Foundation; either version 3 of the License, or (at your
## option) any later version.
##
## This program is distributed in the hope that it will be useful, but
@@ -27,6 +27,7 @@ BUILT_SOURCES = \
gucharmap-resources.h \
gucharmap-type-builtins.c \
gucharmap-type-builtins.h \
+ $(unicode_sources) \
$(NULL)
libgucharmap GUCHARMAP_LIBRARY_SUFFIX_U@_la_SOURCES = \
@@ -56,13 +57,6 @@ libgucharmap GUCHARMAP_LIBRARY_SUFFIX_U@_la_SOURCES = \
gucharmap-script-codepoint-list.h \
gucharmap-unicode-info.c \
gucharmap-unicode-info.h \
- unicode-blocks.h \
- unicode-categories.h \
- unicode-names.h \
- unicode-nameslist.h \
- unicode-scripts.h \
- unicode-unihan.h \
- unicode-versions.h \
$(NULL)
nodist_libgucharmap GUCHARMAP_LIBRARY_SUFFIX_U@_la_SOURCES = $(BUILT_SOURCES)
@@ -206,12 +200,54 @@ gucharmap-type-builtins.c: gucharmap-type-builtins.c.template $(libgucharmapincl
&& (cmp -s xgen-gtbc gucharmap-type-builtins.c || cp xgen-gtbc gucharmap-type-builtins.c ) \
&& rm -f xgen-gtbc
-# printoptions.h: print.glade
-# $(AM_V_GEN) $(GTK_BUILDER_CONVERT) --root custom_tab_container $< - | \
-# $(XMLLINT) --noblanks - | \
-# $(HEXDUMP) -v -e '"" 1/1 "0x%02x,""\n"' > xgen-$(@F) \
-# && (cmp -s xgen-$(@F) $@ || cp -f xgen-$(@F) $@) \
-# && rm -f xgen-$(@F)
+# Unicode data
+
+WGETFLAGS = --timestamping --timeout=300 --tries=8 --no-directories --directory-prefix="$(builddir)"
+
+unicode_version = 8.0.0
+
+unicode_files = \
+ Blocks.txt \
+ DerivedAge.txt \
+ NamesList.txt \
+ Scripts.txt \
+ UnicodeData.txt \
+ Unihan.zip \
+ $(NULL)
+
+unicode_sources = \
+ unicode-blocks.h \
+ unicode-categories.h \
+ unicode-names.h \
+ unicode-nameslist.h \
+ unicode-scripts.h \
+ unicode-unihan.h \
+ unicode-versions.h \
+ $(NULL)
+
+stamp-download-unicode-data:
+if WITH_UNICODE_DATA
+ @echo timestamp > $(@F)
+else
+ $(MAKE) download-unicode-data && echo timestamp > $(@F)
+endif
+
+download-unicode-data:
+ for f in $(unicode_files); do \
+ [ -e $(builddir)/$${f} ] || $(WGET) $(WGETFLAGS)
"http://www.unicode.org/Public/$(unicode_version)/ucd/$${f}"; \
+ done && \
+ $(SHA512SUM) --check $(srcdir)/unicode.sha512sums
+
+unicode.sha512sums: stamp-download-unicode-data
+ $(AM_V_GEN)$(SHA512SUM) $(addprefix $(unicodedatadir)/,$(unicode_files)) | $(SED)
's,$(unicodedatadir)/,,g' > $(srcdir)/$(@F)
+
+stamp-unicode-data:
+ PROG_UNZIP=$(PROG_UNZIP) $(srcdir)/gen-guch-unicode-tables.pl $(unicode_version) $(unicodedatadir) &&
\
+ echo timestamp > $(@F)
+
+$(unicode_sources): stamp-unicode-data
+
+# Dist & cleanup
EXTRA_DIST = \
gucharmap-marshal.list \
@@ -221,13 +257,21 @@ EXTRA_DIST = \
download-unicode-files.sh \
gen-guch-unicode-tables.pl \
gucharmap.gresource.xml.in \
+ unicode.sha512sums \
+ unicode-strings.h \
$(NULL)
CLEANFILES = \
stamp-gucharmap-type-builtins.h \
+ stamp-download-unicode-data \
+ stamp-unicode-data \
$(BUILT_SOURCES) \
$(NULL)
+DISTCLEANFILES = \
+ $(unicode_files) \
+ $(NULL)
+
# introspection
if HAVE_INTROSPECTION
diff --git a/gucharmap/gen-guch-unicode-tables.pl b/gucharmap/gen-guch-unicode-tables.pl
index 69d856c..f2b5abb 100755
--- a/gucharmap/gen-guch-unicode-tables.pl
+++ b/gucharmap/gen-guch-unicode-tables.pl
@@ -17,17 +17,9 @@
# NOTE! Some code copied from glib/glib/gen-unicode-tables.pl; keep in sync!
use strict;
-use vars ('$UNZIP');
-# if these things aren't in your path you can put full paths to them here
-$UNZIP = 'unzip';
-
-sub process_unicode_data_txt ($);
-sub process_unihan_zip ($);
-sub process_nameslist_txt ($);
-sub process_blocks_txt ($);
-sub process_scripts_txt ($);
-sub process_versions_txt ($);
+use Env qw($PROG_UNZIP);
+$PROG_UNZIP = "unzip" unless (defined $PROG_UNZIP);
$| = 1; # flush stdout buffer
@@ -94,7 +86,7 @@ exit;
#------------------------#
-sub process_unicode_data_txt ($)
+sub process_unicode_data_txt
{
my ($unicodedata_txt) = @_;
@@ -114,7 +106,6 @@ sub process_unicode_data_txt ($)
print $out "#define UNICODE_NAMES_H\n\n";
print $out "#include <glib.h>\n\n";
- print $out "#include <glib/gi18n-lib.h>\n\n";
my @unicode_pairs;
my %names;
@@ -304,14 +295,14 @@ EOT
#------------------------#
# XXX should do kFrequency too
-sub process_unihan_zip ($)
+sub process_unihan_zip
{
my ($unihan_zip) = @_;
- open (my $unihan, "$UNZIP -c $unihan_zip |") or die;
- open (my $out, "> unicode-unihan.h") or die;
+ print "processing $unihan_zip.";
- print "processing $unihan_zip";
+ open (my $unihan, "$PROG_UNZIP -c '$unihan_zip' |") or die;
+ open (my $out, "> unicode-unihan.h") or die;
print $out "/* unicode-unihan.h */\n";
print $out "/* THIS IS A GENERATED FILE. CHANGES WILL BE OVERWRITTEN. */\n";
@@ -530,7 +521,7 @@ sub print_names_list
print $out "};\n\n";
}
-sub process_nameslist_txt ($)
+sub process_nameslist_txt
{
my ($nameslist_txt) = @_;
@@ -736,7 +727,7 @@ sub read_blocks_txt
close ($blocks_file);
}
-sub process_blocks_txt ($)
+sub process_blocks_txt
{
my ($blocks_txt) = @_;
@@ -753,7 +744,6 @@ sub process_blocks_txt ($)
print $out "#define UNICODE_BLOCKS_H\n\n";
print $out "#include <glib.h>\n";
- print $out "#include <glib/gi18n-lib.h>\n\n";
my @blocks;
read_blocks_txt ($blocks_txt, \ blocks);
@@ -843,7 +833,7 @@ sub read_scripts_txt
$scripts->{"Common"} = 1;
}
-sub process_scripts_txt ($)
+sub process_scripts_txt
{
my ($scripts_txt) = @_;
@@ -865,7 +855,6 @@ sub process_scripts_txt ($)
print $out "#define UNICODE_SCRIPTS_H\n\n";
print $out "#include <glib.h>\n";
- print $out "#include <glib/gi18n-lib.h>\n\n";
print $out "typedef struct _UnicodeScript UnicodeScript;\n\n";
@@ -915,7 +904,7 @@ sub process_scripts_txt ($)
#------------------------#
-sub process_translatable_strings
+sub process_translatable_strings
{
my ($blocks_txt, $scripts_txt) = @_;
@@ -956,7 +945,7 @@ sub process_translatable_strings
#------------------------#
-sub process_versions_txt ($)
+sub process_versions_txt
{
my ($versions_txt) = @_;
@@ -1010,7 +999,6 @@ sub process_versions_txt ($)
print $out "#define UNICODE_VERSIONS_H\n\n";
print $out "#include <glib.h>\n";
- print $out "#include <glib/gi18n-lib.h>\n\n";
print $out "typedef struct {\n";
print $out " gunichar start;\n";
diff --git a/gucharmap/gucharmap-script-codepoint-list.c b/gucharmap/gucharmap-script-codepoint-list.c
index 3197b2f..4c09c0b 100644
--- a/gucharmap/gucharmap-script-codepoint-list.c
+++ b/gucharmap/gucharmap-script-codepoint-list.c
@@ -20,6 +20,8 @@
#include <glib.h>
#include <string.h>
+#include <glib/gi18n-lib.h>
+
#include "gucharmap.h"
#include "gucharmap-private.h"
diff --git a/gucharmap/gucharmap-unicode-info.c b/gucharmap/gucharmap-unicode-info.c
index 80dd6b4..c6eafa5 100644
--- a/gucharmap/gucharmap-unicode-info.c
+++ b/gucharmap/gucharmap-unicode-info.c
@@ -21,6 +21,8 @@
#include <gtk/gtk.h>
#include <string.h>
+#include <glib/gi18n-lib.h>
+
#include "gucharmap.h"
#include "gucharmap-private.h"
diff --git a/gucharmap/unicode.sha512sums b/gucharmap/unicode.sha512sums
new file mode 100644
index 0000000..dd8e650
--- /dev/null
+++ b/gucharmap/unicode.sha512sums
@@ -0,0 +1,6 @@
+7d11590e5678a06b51d9fab787fa4912120ea5e8dc8f89b2cddda9472dadd52514a74b0d3672f47e38f1ed3691e0599cdf6134cd4bbc7b5121977b57e8c842ef
Blocks.txt
+9939b52a5ee51d4b6548199892f3a890324b793dd5fe81c70c8de977f737e3c91b9fc20b8b2241bb5b613d3946a06d9b0a6432cfa3b70432158ad0a78b40b032
DerivedAge.txt
+7f9fb0349f64e8c84d1d2fa3416d561b30744d6f1fcb7d01efe1bc93dca2fe7f58148918270bfeb92551a1e08c7fefba3208af259bf35d8653a1c7772b8da259
NamesList.txt
+c444218e9eb1090e0edf24f7dbafa9ff44031fa1b2124bf9133faa2022101a1e2f0cc56a5f014c3cb37fdc672fb65f14e67bc816ada082cdb256055c7009a9d2
Scripts.txt
+34b46357ead07ec499746cac355e1fd6f3a1feea0fb786a28fe28985dd264323fba0ebf9ee6f7ab29bf412da191992aa3f6b41a394f817bcd1193f7eb06c1c91
UnicodeData.txt
+4ab0f816041801720f626c264d5c9e4ded3f729c2de4b837428c9748b84950f1433243cdf8fb41ae58cbb32f401cebd547bf0eff268ff7549d5632c7baacd137
Unihan.zip
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]