[gnome-calculator/60-split-out-a-backend-library: 9/47] gcalc: added new library gcalc



commit 1c9993fc4f4c310c853ae8e09eb2663cfef52848
Author: Daniel Espinosa <esodan gmail com>
Date:   Wed Dec 5 13:46:48 2018 -0600

    gcalc: added new library gcalc

 lib/gcalc-result.vala      |  25 +++++++++++
 lib/gcalc-solver.vala      |  23 +++++++++++
 lib/gcalc.deps.in          |   1 +
 lib/gcalc.pc.in            |  13 ++++++
 lib/meson.build            |  95 ++++++++++++++++++++++++++++++++++++++++++
 lib/namespace-info.vala.in |  26 ++++++++++++
 meson.build                |   3 ++
 org.gnome.Calculator.json  | 101 +++++++++++++++++++++++++--------------------
 8 files changed, 243 insertions(+), 44 deletions(-)
---
diff --git a/lib/gcalc-result.vala b/lib/gcalc-result.vala
new file mode 100644
index 00000000..4e99130f
--- /dev/null
+++ b/lib/gcalc-result.vala
@@ -0,0 +1,25 @@
+/* gcalc-result.vala
+ *
+ * Copyright (C) 2018  Daniel Espinosa <esodan gmail 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; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * 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/>.
+ *
+ * Authors:
+ *      Daniel Espinosa <esodan gmail com>
+ */
+public interface GCalc.Result : Object {
+  public abstract bool is_valid { get; }
+  public abstract string to_string ();
+}
+
diff --git a/lib/gcalc-solver.vala b/lib/gcalc-solver.vala
new file mode 100644
index 00000000..498a589a
--- /dev/null
+++ b/lib/gcalc-solver.vala
@@ -0,0 +1,23 @@
+/* gcalc-solver.vala
+ *
+ * Copyright (C) 2018  Daniel Espinosa <esodan gmail 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; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * 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/>.
+ *
+ * Authors:
+ *      Daniel Espinosa <esodan gmail com>
+ */
+public interface GCalc.Solver : Object {
+  public abstract Result solve (string str) throws GLib.Error;
+}
diff --git a/lib/gcalc.deps.in b/lib/gcalc.deps.in
new file mode 100644
index 00000000..cd10dfde
--- /dev/null
+++ b/lib/gcalc.deps.in
@@ -0,0 +1 @@
+gio-2.0
diff --git a/lib/gcalc.pc.in b/lib/gcalc.pc.in
new file mode 100644
index 00000000..faaae0bb
--- /dev/null
+++ b/lib/gcalc.pc.in
@@ -0,0 +1,13 @@
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=@libdir@
+datadir=@prefix@/share
+includedir=@prefix@/include
+
+Name: libgcalc
+Description: GNOME Calculator Libray
+URL: http://live.gnome.org/
+Version: @PROJECT_VERSION@
+Requires: gio-2.0 >= 2.50
+Libs: -L${libdir} -lgcalc-@API_VERSION@
+Cflags: -I${includedir}/gcalc-@API_VERSION@
diff --git a/lib/meson.build b/lib/meson.build
index bc1b9792..2516b631 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -42,3 +42,98 @@ libcalculator = static_library('calculator', libcalculator_sources,
   include_directories: config_h_dir,
   install: false,
 )
+
+# Public Library gcalc
+
+PROJECT_NAME='gcalc'
+API_VERSION='1'
+VERSIONED_PROJECT_NAME=PROJECT_NAME+'-'+API_VERSION
+CAMEL_CASE_NAME='GClac'
+VERSIONED_CAMEL_CASE_NAME=CAMEL_CASE_NAME+'-'+API_VERSION
+vapidir = join_paths (get_option('datadir'),'vala','vapi')
+GIR_NAME= VERSIONED_CAMEL_CASE_NAME+'.gir'
+TYPELIB_NAME= VERSIONED_CAMEL_CASE_NAME+'.typelib'
+VAPI_NAME = VERSIONED_PROJECT_NAME+'.vapi'
+
+conf = configuration_data()
+conf.set('prefix', get_option('prefix'))
+conf.set('libdir', '${exec_prefix}/'+get_option ('libdir'))
+conf.set('PROJECT_NAME', PROJECT_NAME)
+conf.set('PROJECT_VERSION', meson.project_version ())
+conf.set('API_VERSION', API_VERSION)
+
+configure_file(input : 'gcalc.pc.in',
+       output : 'gcalc-@0@.pc'.format(API_VERSION),
+       configuration : conf,
+       install : true,
+       install_dir : join_paths(get_option('libdir'), 'pkgconfig'))
+
+configure_file(input : 'gcalc.deps.in',
+       output : 'gcalc-@0@.deps'.format(API_VERSION),
+       configuration : conf,
+       install : true,
+       install_dir : vapidir)
+
+nsinfo = configure_file(input : 'namespace-info.vala.in',
+       output : 'namespace-info.vala',
+       configuration : conf)
+namespaceinfo_dep = declare_dependency (sources : nsinfo)
+
+confh = configuration_data ()
+confh.set_quoted('PACKAGE_LOCALE_DIR', join_paths(get_option('prefix'), get_option('datadir'), 'locale'))
+confh.set_quoted('GETTEXT_PACKAGE', 'GCalc')
+configure_file(output : 'config.h',
+       configuration : confh)
+
+sources = files([
+  ])
+
+inc_libh = include_directories ('.')
+inc_libh_dep = declare_dependency (include_directories : inc_libh)
+
+# LT_VERSION for ABI related changes
+# From: https://autotools.io/libtool/version.html
+# This rules applies to Meson 0.43
+# Increase the current value whenever an interface has been added, removed or changed.
+# Always increase revision value whenever an interface has been added, removed or changed.
+# Increase the age value only if the changes made to the ABI are backward compatible.
+# Set version to the value of subtract age from current
+# Reset current and version to 1 and, age and version to 0 if library's name is changed
+LT_CURRENT='0'
+LT_REVISION='0'
+LT_AGE='0'
+LT_VERSION='0'
+lib = library(VERSIONED_PROJECT_NAME,
+       sources,
+       version : LT_VERSION,
+       soversion : LT_VERSION+'.'+LT_AGE+'.'+LT_REVISION,
+       vala_header : PROJECT_NAME+'.h',
+       vala_vapi : VAPI_NAME,
+       vala_gir : GIR_NAME,
+       dependencies : [ gio, namespaceinfo_dep, inc_libh_dep, inc_rooth_dep ],
+       c_args : [
+               '-include',
+               meson.current_build_dir() + '/config.h'
+       ],
+       install : true,
+       install_dir : [
+               true,
+               join_paths (get_option('includedir'), 'gcalc-@0@'.format (API_VERSION), 'gcalc'),
+               vapidir,
+               true
+       ])
+
+g_ir_compiler = find_program('g-ir-compiler', required: false)
+if g_ir_compiler.found()
+custom_target('typelib',
+       command: [
+               g_ir_compiler,
+               '--shared-library', 'lib'+PROJECT_NAME+'-@0@.so'.format (API_VERSION),
+               '--output', '@OUTPUT@',
+               join_paths(meson.current_build_dir(), GIR_NAME)
+       ],
+       output: TYPELIB_NAME,
+       depends: lib,
+       install: true,
+       install_dir: join_paths(get_option('libdir'), 'girepository-1.0'))
+endif
diff --git a/lib/namespace-info.vala.in b/lib/namespace-info.vala.in
new file mode 100644
index 00000000..71781a38
--- /dev/null
+++ b/lib/namespace-info.vala.in
@@ -0,0 +1,26 @@
+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
+/* Attr.vala
+ *
+ * Copyright (C) 2011-2013  Richard Schwarting <aquarichy gmail com>
+ * Copyright (C) 2011, 2017 Daniel Espinosa <esodan gmail 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; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Authors:
+ *      Richard Schwarting <aquarichy gmail com>
+ *      Daniel Espinosa <esodan gmail com>
+ */
+[CCode (gir_namespace = "GCalc", gir_version = "@API_VERSION@", cheader_filename = "gcalc/@PROJECT_NAME@.h")]
+namespace GCalc {}
diff --git a/meson.build b/meson.build
index 11ebd68e..6c52f606 100644
--- a/meson.build
+++ b/meson.build
@@ -4,6 +4,9 @@ project('gnome-calculator', ['c', 'vala'],
   license: 'GPLv3+',
 )
 
+inc_rooth = include_directories ('.')
+inc_rooth_dep = declare_dependency (include_directories : inc_rooth)
+
 gnome = import('gnome')
 i18n = import('i18n')
 
diff --git a/org.gnome.Calculator.json b/org.gnome.Calculator.json
index b5826475..4852e4e2 100644
--- a/org.gnome.Calculator.json
+++ b/org.gnome.Calculator.json
@@ -1,74 +1,87 @@
 {
-    "app-id": "org.gnome.Calculator",
-    "runtime": "org.gnome.Platform",
-    "runtime-version": "master",
-    "sdk": "org.gnome.Sdk",
-    "command": "gnome-calculator",
-    "tags": ["nightly"],
-    "desktop-file-name-prefix": "(Nightly) ",
-    "finish-args": [
-        /* X11 + XShm access */
-        "--share=ipc", "--socket=x11",
-        /* Wayland access */
+    "app-id" : "org.gnome.Calculator",
+    "runtime" : "org.gnome.Sdk",
+    "runtime-version" : "master",
+    "sdk" : "org.gnome.Sdk",
+    "command" : "gnome-calculator",
+    "tags" : [
+        "nightly"
+    ],
+    "desktop-file-name-prefix" : "(Nightly) ",
+    "finish-args" : [
+        "--share=ipc",
+        "--socket=x11",
         "--socket=wayland",
-        /* Needs to talk to the network to get currency data */
         "--share=network",
-        /* Needed for dconf to work */
-        "--filesystem=xdg-run/dconf", "--filesystem=~/.config/dconf:ro",
-        "--talk-name=ca.desrt.dconf", "--env=DCONF_USER_CONFIG_DIR=.config/dconf"
+        "--filesystem=xdg-run/dconf",
+        "--filesystem=~/.config/dconf:ro",
+        "--talk-name=ca.desrt.dconf",
+        "--env=DCONF_USER_CONFIG_DIR=.config/dconf"
     ],
     "build-options" : {
-        "cflags": "-O2 -g -w",
-        "cxxflags": "-O2 -g -w"
+        "cflags" : "-O2 -g -w",
+        "cxxflags" : "-O2 -g -w",
+        "env" : {
+        }
     },
-    "cleanup": ["/include", "/lib/pkgconfig",
-                "/share/pkgconfig", "/share/aclocal",
-                "/man", "/share/man", "/share/gtk-doc",
-                "/share/vala", "*.la", "*.a",
-                "/bin/gcalccmd",
-                "/lib/girepository-1.0", "/share/info", "/share/gtksourceview-4",
-                "/share/doc", "/share/gir-1.0"
+    "cleanup" : [
+        "/include",
+        "/lib/pkgconfig",
+        "/share/pkgconfig",
+        "/share/aclocal",
+        "/man",
+        "/share/man",
+        "/share/gtk-doc",
+        "/share/vala",
+        "*.la",
+        "*.a",
+        "/bin/gcalccmd",
+        "/lib/girepository-1.0",
+        "/share/info",
+        "/share/gtksourceview-4",
+        "/share/doc",
+        "/share/gir-1.0"
     ],
-    "modules": [
+    "modules" : [
         {
-            "name": "mpfr",
-            "sources": [
+            "name" : "mpfr",
+            "sources" : [
                 {
-                    "type": "archive",
-                    "url": "http://www.mpfr.org/mpfr-4.0.1/mpfr-4.0.1.tar.xz";,
-                    "sha256": "67874a60826303ee2fb6affc6dc0ddd3e749e9bfcb4c8655e3953d0458a6e16e"
+                    "type" : "archive",
+                    "url" : "http://www.mpfr.org/mpfr-4.0.1/mpfr-4.0.1.tar.xz";,
+                    "sha256" : "67874a60826303ee2fb6affc6dc0ddd3e749e9bfcb4c8655e3953d0458a6e16e"
                 }
             ]
         },
         {
-            "name": "mpc",
+            "name" : "mpc",
             "config-opts" : [
                 "--with-mpfr=/app"
             ],
-            "sources": [
+            "sources" : [
                 {
-                    "type": "archive",
-                    "url": "https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz";,
-                    "sha256": "6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e"
+                    "type" : "archive",
+                    "url" : "https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz";,
+                    "sha256" : "6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e"
                 }
             ]
         },
         {
-            "name": "gtksourceview",
-            "sources": [
+            "name" : "gtksourceview",
+            "sources" : [
                 {
-                    "type": "git",
-                    "url": "https://gitlab.gnome.org/GNOME/gtksourceview.git";
+                    "type" : "git",
+                    "url" : "https://gitlab.gnome.org/GNOME/gtksourceview.git";
                 }
             ]
         },
         {
-            "name": "gnome-calculator",
-            "buildsystem": "meson",
-            "sources": [
+            "name" : "gnome-calculator",
+            "buildsystem" : "meson",
+            "sources" : [
                 {
-                    "type": "git",
-                    "url": "https://gitlab.gnome.org/GNOME/gnome-calculator.git";
+                    "type" : "git",
+                    "url" : "https://gitlab.gnome.org/GNOME/gnome-calculator.git";
                 }
             ]
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]