[gnome-calculator] Split many math backend into libcalculator convenience library
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator] Split many math backend into libcalculator convenience library
- Date: Sun, 10 May 2015 23:36:30 +0000 (UTC)
commit 2b2127ea816df9f5450afdad057151a69d094d70
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun May 10 18:24:47 2015 -0500
Split many math backend into libcalculator convenience library
This creates a clearer separation between the files that can use GTK+
(those not used by gcalccmd), avoids compiling files multiple times, and
sets the stage for the search provider to use libcalculator as a private
shared library rather than running the gnome-calculator binary and
parsing the output.
Makefile.am | 2 +-
configure.ac | 17 +++--
lib/Makefile.am | 51 ++++++++++++++++
lib/config.vapi | 2 +
{src => lib}/currency.vala | 0
{src => lib}/equation-lexer.vala | 0
{src => lib}/equation-parser.vala | 0
{src => lib}/equation.vala | 0
{src => lib}/financial.vala | 0
{src => lib}/function-manager.vala | 0
{src => lib}/math-equation.vala | 0
{src => lib}/math-function.vala | 0
{src => lib}/math-variables.vala | 0
{src => lib}/mpfr.vapi | 0
{src => lib}/number.vala | 0
{src => lib}/serializer.vala | 0
{src => lib}/unit.vala | 0
po/POTFILES.in | 27 +++++----
po/POTFILES.skip | 27 +++++----
src/Makefile.am | 113 +++++------------------------------
tests/Makefile.am | 60 ++++++++++++++++++
{src => tests}/test-equation.vala | 0
{src => tests}/test-number.vala | 0
{src => tests}/test-serializer.vala | 0
24 files changed, 170 insertions(+), 129 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 7746cfc..dc1515c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = po src search-provider data help
+SUBDIRS = data lib src search-provider tests help po
# Temporary fix for JHBuild, see https://bugzilla.gnome.org/show_bug.cgi?id=641652
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
diff --git a/configure.ac b/configure.ac
index c92bc41..16c01c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,6 +10,9 @@ GNOME_MAINTAINER_MODE_DEFINES
AM_PROG_VALAC([0.24])
AM_PROG_CC_C_O
+LT_PREREQ([2.2])
+LT_INIT
+
AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
GLIB_GSETTINGS
@@ -22,21 +25,19 @@ GLIB_REQUIRED=2.40.0
GTK_REQUIRED=3.11.6
GTKSOURCEVIEW_REQUIRED=3.15.1
+# FIXME We link to it too, so this check needs to be better....
AC_CHECK_HEADER([mpfr.h], [], [AC_MSG_ERROR([The mpfr header is missing. Please, install mpfr])])
-PKG_CHECK_MODULES(GNOME_CALCULATOR, [
- gtk+-3.0 >= $GTK_REQUIRED
+PKG_CHECK_MODULES(LIBCALCULATOR, [
glib-2.0 >= $GLIB_REQUIRED
gio-2.0 >= $GLIB_REQUIRED
gtksourceview-3.0 >= $GTKSOURCEVIEW_REQUIRED
libxml-2.0
- gmodule-export-2.0
])
-PKG_CHECK_MODULES(GCALCCMD, [
- glib-2.0 >= $GLIB_REQUIRED
- gio-2.0 >= $GLIB_REQUIRED
- libxml-2.0
+PKG_CHECK_MODULES(GNOME_CALCULATOR, [
+ gtk+-3.0 >= $GTK_REQUIRED
+ gmodule-export-2.0
])
PKG_CHECK_MODULES(SEARCH_PROVIDER, [
@@ -69,8 +70,10 @@ dnl ###########################################################################
AC_OUTPUT([
Makefile
search-provider/Makefile
+lib/Makefile
src/Makefile
po/Makefile.in
data/Makefile
help/Makefile
+tests/Makefile
])
diff --git a/lib/Makefile.am b/lib/Makefile.am
new file mode 100644
index 0000000..4f1f599
--- /dev/null
+++ b/lib/Makefile.am
@@ -0,0 +1,51 @@
+pkglib_LTLIBRARIES = libcalculator.la
+
+AM_CPPFLAGS = \
+ -DUI_DIR=\""$(datadir)/gnome-calculator"\" \
+ -DVERSION=\""$(VERSION)"\" \
+ -DLOCALE_DIR=\""$(localedir)"\" \
+ -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
+ -w \
+ $(LIBCALCULATOR_CFLAGS)
+
+libcalculator_la_SOURCES = \
+ config.vapi \
+ mpfr.vapi \
+ currency.vala \
+ equation.vala \
+ equation-lexer.vala \
+ equation-parser.vala \
+ financial.vala \
+ function-manager.vala \
+ math-equation.vala \
+ math-function.vala \
+ math-variables.vala \
+ number.vala \
+ serializer.vala \
+ unit.vala
+
+libcalculator_la_VALAFLAGS = \
+ --target-glib 2.32 \
+ --pkg posix \
+ --pkg gtksourceview-3.0 \
+ --pkg libxml-2.0 \
+ --header=libcalculator.h \
+ --vapi=libcalculator.vapi
+
+libcalculator_la_LDFLAGS = -avoid-version -no-undefined
+
+libcalculator_la_LIBADD = \
+ $(LIBCALCULATOR_LIBS) \
+ -lgmp \
+ -lm \
+ -lmpfr
+
+EXTRA_DIST = \
+ libcalculator.h \
+ libcalculator.vapi
+
+MAINTAINERCLEANFILES = \
+ libcalculator.h \
+ libcalculator.vapi
+
+-include $(top_srcdir)/git.mk
diff --git a/lib/config.vapi b/lib/config.vapi
new file mode 100644
index 0000000..ffe4322
--- /dev/null
+++ b/lib/config.vapi
@@ -0,0 +1,2 @@
+public const string GETTEXT_PACKAGE;
+public const string LOCALE_DIR;
diff --git a/src/currency.vala b/lib/currency.vala
similarity index 100%
rename from src/currency.vala
rename to lib/currency.vala
diff --git a/src/equation-lexer.vala b/lib/equation-lexer.vala
similarity index 100%
rename from src/equation-lexer.vala
rename to lib/equation-lexer.vala
diff --git a/src/equation-parser.vala b/lib/equation-parser.vala
similarity index 100%
rename from src/equation-parser.vala
rename to lib/equation-parser.vala
diff --git a/src/equation.vala b/lib/equation.vala
similarity index 100%
rename from src/equation.vala
rename to lib/equation.vala
diff --git a/src/financial.vala b/lib/financial.vala
similarity index 100%
rename from src/financial.vala
rename to lib/financial.vala
diff --git a/src/function-manager.vala b/lib/function-manager.vala
similarity index 100%
rename from src/function-manager.vala
rename to lib/function-manager.vala
diff --git a/src/math-equation.vala b/lib/math-equation.vala
similarity index 100%
rename from src/math-equation.vala
rename to lib/math-equation.vala
diff --git a/src/math-function.vala b/lib/math-function.vala
similarity index 100%
rename from src/math-function.vala
rename to lib/math-function.vala
diff --git a/src/math-variables.vala b/lib/math-variables.vala
similarity index 100%
rename from src/math-variables.vala
rename to lib/math-variables.vala
diff --git a/src/mpfr.vapi b/lib/mpfr.vapi
similarity index 100%
rename from src/mpfr.vapi
rename to lib/mpfr.vapi
diff --git a/src/number.vala b/lib/number.vala
similarity index 100%
rename from src/number.vala
rename to lib/number.vala
diff --git a/src/serializer.vala b/lib/serializer.vala
similarity index 100%
rename from src/serializer.vala
rename to lib/serializer.vala
diff --git a/src/unit.vala b/lib/unit.vala
similarity index 100%
rename from src/unit.vala
rename to lib/unit.vala
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c129cbc..cc801af 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -9,23 +9,26 @@ data/gnome-calculator.desktop.in
data/gnome-calculator.appdata.xml.in
[type: gettext/glade]data/menu.ui
data/org.gnome.calculator.gschema.xml
-src/currency.vala
-src/equation-lexer.vala
-src/equation-parser.vala
-src/equation.vala
-src/financial.vala
+lib/currency.vala
+lib/equation.vala
+lib/equation-lexer.vala
+lib/equation-parser.vala
+lib/financial.vala
+lib/function-manager.vala
+lib/math-equation.vala
+lib/math-function.vala
+lib/math-variables.vala
+lib/number.vala
+lib/serializer.vala
+lib/unit.vala
src/gcalccmd.vala
src/gnome-calculator.vala
src/math-buttons.vala
src/math-converter.vala
src/math-display.vala
-src/math-equation.vala
src/math-preferences.vala
src/math-variable-popup.vala
-src/math-variables.vala
src/math-window.vala
-src/number.vala
-src/serializer.vala
-src/test-equation.vala
-src/test-number.vala
-src/unit.vala
+tests/test-equation.vala
+tests/test-number.vala
+tests/test-serializer.vala
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 6c8d92e..5cd6182 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -1,20 +1,23 @@
-src/currency.c
-src/equation.c
-src/equation-lexer.c
-src/equation-parser.c
-src/financial.c
+lib/currency.c
+lib/equation.c
+lib/equation-lexer.c
+lib/equation-parser.c
+lib/financial.c
+lib/function-manager.c
+lib/math-equation.c
+lib/math-function.c
+lib/math-variables.c
+lib/number.c
+lib/serializer.c
+lib/unit.c
src/gcalccmd.c
src/gnome-calculator.c
src/math-buttons.c
src/math-converter.c
src/math-display.c
-src/math-equation.c
src/math-preferences.c
src/math-variable-popup.c
-src/math-variables.c
src/math-window.c
-src/number.c
-src/serializer.c
-src/test-equation.c
-src/test-number.c
-src/unit.c
+tests/test-equation.c
+tests/test-number.c
+tests/test-serializer.c
diff --git a/src/Makefile.am b/src/Makefile.am
index d3a52d7..b8dde9f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,4 @@
bin_PROGRAMS = gnome-calculator gcalccmd
-noinst_PROGRAMS = test-number test-equation test-serializer
-
-TESTS = test-number test-equation test-serializer
AM_CPPFLAGS = \
-DUI_DIR=\""$(datadir)/gnome-calculator"\" \
@@ -9,7 +6,8 @@ AM_CPPFLAGS = \
-DLOCALE_DIR=\""$(localedir)"\" \
-DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
-w \
- $(GNOME_CALCULATOR_CFLAGS)
+ -I$(top_srcdir)/lib \
+ $(LIBCALCULATOR_CFLAGS)
BUILT_SOURCES = resources.c
@@ -18,26 +16,13 @@ resources.c: $(top_srcdir)/data/gnome-calculator.gresource.xml $(shell $(GLIB_CO
gnome_calculator_SOURCES = \
config.vapi \
- mpfr.vapi \
gnome-calculator.vala \
- currency.vala \
- equation.vala \
- equation-lexer.vala \
- equation-parser.vala \
- financial.vala \
math-buttons.vala \
math-converter.vala \
math-display.vala \
- math-equation.vala \
math-preferences.vala \
- math-variables.vala \
math-variable-popup.vala \
math-window.vala \
- number.vala \
- serializer.vala \
- unit.vala \
- math-function.vala \
- function-manager.vala \
math-function-popup.vala \
math-history.vala \
$(BUILT_SOURCES)
@@ -47,98 +32,32 @@ gnome_calculator_VALAFLAGS = \
--pkg posix \
--pkg gtk+-3.0 \
--pkg gtksourceview-3.0 \
- --pkg libxml-2.0
+ --pkg libxml-2.0 \
+ $(top_builddir)/lib/libcalculator.vapi \
+ $(top_builddir)/lib/mpfr.vapi
+
+gnome_calculator_CPPFLAGS = \
+ $(AM_CPPFLAGS) \
+ $(GNOME_CALCULATOR_CFLAGS)
gnome_calculator_LDADD = \
$(GNOME_CALCULATOR_LIBS) \
- -lmpfr \
- -lgmp
+ $(top_builddir)/lib/libcalculator.la
gcalccmd_SOURCES = \
config.vapi \
- mpfr.vapi \
- gcalccmd.vala \
- currency.vala \
- equation.vala \
- equation-lexer.vala \
- equation-parser.vala \
- number.vala \
- serializer.vala \
- unit.vala \
- math-function.vala \
- function-manager.vala
+ gcalccmd.vala
gcalccmd_VALAFLAGS = \
--target-glib 2.32 \
--pkg posix \
--pkg gio-2.0 \
- --pkg libxml-2.0
+ --pkg gtksourceview-3.0 \
+ --pkg libxml-2.0 \
+ $(top_builddir)/lib/libcalculator.vapi \
+ $(top_builddir)/lib/mpfr.vapi
gcalccmd_LDADD = \
- $(GCALCCMD_LIBS) \
- -lmpfr \
- -lgmp
-
-test_number_SOURCES = \
- config.vapi \
- mpfr.vapi \
- test-number.vala \
- number.vala \
- serializer.vala
-
-test_number_VALAFLAGS = \
- --target-glib 2.32 \
- --pkg posix \
- --pkg gio-2.0 \
- --pkg libxml-2.0
-
-test_number_LDADD = \
- $(GCALCCMD_LIBS) \
- -lm \
- -lmpfr \
- -lgmp
-
-test_equation_SOURCES = \
- config.vapi \
- mpfr.vapi \
- test-equation.vala \
- currency.vala \
- equation.vala \
- equation-lexer.vala \
- equation-parser.vala \
- number.vala \
- serializer.vala \
- unit.vala \
- math-function.vala \
- function-manager.vala
-
-test_equation_VALAFLAGS = \
- --target-glib 2.32 \
- --pkg posix \
- --pkg gio-2.0 \
- --pkg libxml-2.0
-
-test_equation_LDADD = \
- $(GCALCCMD_LIBS) \
- -lmpfr \
- -lgmp
-
-test_serializer_SOURCES = \
- config.vapi \
- mpfr.vapi \
- test-serializer.vala \
- number.vala \
- serializer.vala
-
-test_serializer_VALAFLAGS = \
- --target-glib 2.32 \
- --pkg posix \
- --pkg gio-2.0 \
- --pkg libxml-2.0
-
-test_serializer_LDADD = \
- $(GCALCCMD_LIBS) \
- -lmpfr \
- -lgmp
+ $(top_builddir)/lib/libcalculator.la
-include $(top_srcdir)/git.mk
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..ac4bb18
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,60 @@
+noinst_PROGRAMS = test-number test-equation test-serializer
+TESTS = test-number test-equation test-serializer
+
+AM_CPPFLAGS = \
+ -w \
+ -I$(top_srcdir)/lib \
+ $(LIBCALCULATOR_CFLAGS)
+
+test_number_SOURCES = \
+ test-number.vala
+
+test_number_VALAFLAGS = \
+ --target-glib 2.32 \
+ --pkg posix \
+ --pkg gio-2.0 \
+ --pkg gtksourceview-3.0 \
+ --pkg libxml-2.0 \
+ $(top_builddir)/lib/libcalculator.vapi \
+ $(top_builddir)/lib/mpfr.vapi
+
+test_number_LDADD = \
+ $(LIBCALCULATOR_LIBS) \
+ -lm \
+ $(top_builddir)/lib/libcalculator.la
+
+test_equation_SOURCES = \
+ test-equation.vala
+
+test_equation_VALAFLAGS = \
+ --target-glib 2.32 \
+ --pkg posix \
+ --pkg gio-2.0 \
+ --pkg gtksourceview-3.0 \
+ --pkg libxml-2.0 \
+ $(top_builddir)/lib/libcalculator.vapi \
+ $(top_builddir)/lib/mpfr.vapi
+
+test_equation_LDADD = \
+ $(LIBCALCULATOR_LIBS) \
+ -lm \
+ $(top_builddir)/lib/libcalculator.la
+
+test_serializer_SOURCES = \
+ test-serializer.vala
+
+test_serializer_VALAFLAGS = \
+ --target-glib 2.32 \
+ --pkg posix \
+ --pkg gio-2.0 \
+ --pkg gtksourceview-3.0 \
+ --pkg libxml-2.0 \
+ $(top_builddir)/lib/libcalculator.vapi \
+ $(top_builddir)/lib/mpfr.vapi
+
+test_serializer_LDADD = \
+ $(LIBCALCULATOR_LIBS) \
+ -lm \
+ $(top_builddir)/lib/libcalculator.la
+
+-include $(top_srcdir)/git.mk
diff --git a/src/test-equation.vala b/tests/test-equation.vala
similarity index 100%
rename from src/test-equation.vala
rename to tests/test-equation.vala
diff --git a/src/test-number.vala b/tests/test-number.vala
similarity index 100%
rename from src/test-number.vala
rename to tests/test-number.vala
diff --git a/src/test-serializer.vala b/tests/test-serializer.vala
similarity index 100%
rename from src/test-serializer.vala
rename to tests/test-serializer.vala
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]