[libgda: 1/2] Examples were added to the meson



commit 64b516770b382dbb0e75bb13b8ccd04c44e3442f
Author: Pavlo Solntsev <p sun fun gmail com>
Date:   Thu Sep 6 15:00:40 2018 +0000

    Examples were added to the meson

 examples/DDL/ddl.c                 |  2 +-
 examples/DDL/meson.build           |  9 +++++++++
 examples/SimpleExample/example.c   | 15 +++++++++++----
 examples/SimpleExample/meson.build |  9 +++++++++
 examples/meson.build               |  4 ++++
 meson.build                        |  4 +++-
 meson_options.txt                  |  1 +
 7 files changed, 38 insertions(+), 6 deletions(-)
---
diff --git a/examples/DDL/ddl.c b/examples/DDL/ddl.c
index ce6616407..759214453 100644
--- a/examples/DDL/ddl.c
+++ b/examples/DDL/ddl.c
@@ -60,7 +60,7 @@ open_connection (void)
                                               GDA_CONNECTION_OPTIONS_NONE,
                                               &error);
         if (!cnc) {
-                g_print ("Could not open connection to SQLite database in example_db.db file: %s\n",
+                g_print ("Could not open connection to SQLite database in ddl_db.db file: %s\n",
                          error && error->message ? error->message : "No detail");
                 exit (1);
         }
diff --git a/examples/DDL/meson.build b/examples/DDL/meson.build
new file mode 100644
index 000000000..49654be21
--- /dev/null
+++ b/examples/DDL/meson.build
@@ -0,0 +1,9 @@
+gda_examples_ddl_source = ['ddl.c'] 
+
+executable('ddl',
+           sources : gda_examples_ddl_source,
+           link_with: libgda,
+           include_directories : example_inc_dir, 
+           dependencies : [glib_dep,libxml_dep,gobject_dep],
+           install: false)
+
diff --git a/examples/SimpleExample/example.c b/examples/SimpleExample/example.c
index 730d13755..8e3ca3aaa 100644
--- a/examples/SimpleExample/example.c
+++ b/examples/SimpleExample/example.c
@@ -31,9 +31,11 @@ void run_sql_non_select (GdaConnection *cnc, const gchar *sql);
 int
 main (int argc, char *argv[])
 {
-        gda_init ();
+  gda_init ();
 
-        GdaConnection *cnc;
+  GdaConnection *cnc;
+
+  GError *error = NULL;
 
        /* open connections */
        cnc = open_connection ();
@@ -48,10 +50,15 @@ main (int argc, char *argv[])
        delete_data (cnc);
        display_products_contents (cnc);
 
-        gda_connection_close (cnc);
+  if (!gda_connection_close (cnc,&error))
+    {
+      g_print ("Could not close connection: %s\n",
+               error && error->message ? error->message : "No detail");
+    }
+
        g_object_unref (cnc);
 
-        return 0;
+  return 0;
 }
 
 /*
diff --git a/examples/SimpleExample/meson.build b/examples/SimpleExample/meson.build
new file mode 100644
index 000000000..fa856d458
--- /dev/null
+++ b/examples/SimpleExample/meson.build
@@ -0,0 +1,9 @@
+gda_examples_example_source = ['example.c'] 
+
+executable('simpleexample',
+           sources : gda_examples_example_source,
+           link_with: libgda,
+           include_directories : example_inc_dir, 
+           dependencies : [glib_dep,libxml_dep,gobject_dep],
+           install: false)
+
diff --git a/examples/meson.build b/examples/meson.build
new file mode 100644
index 000000000..b2de656e2
--- /dev/null
+++ b/examples/meson.build
@@ -0,0 +1,4 @@
+example_inc_dir = [inc_rooth,inc_libgdah] 
+
+subdir('DDL')
+subdir('SimpleExample')
diff --git a/meson.build b/meson.build
index 1c4e3742f..177502b45 100644
--- a/meson.build
+++ b/meson.build
@@ -358,4 +358,6 @@ endif
 subdir('tools')
 subdir('tests')
 subdir('testing')
-
+if get_option('with-examples')
+  subdir('examples')
+endif
diff --git a/meson_options.txt b/meson_options.txt
index 4999f5df6..ec6ff9777 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -11,4 +11,5 @@ option('with-libsecret', type : 'boolean', value : false, description : 'Enable
 option('with-gnome-keyring', type : 'boolean', value : false, description : 'Enable gnome-keyring support')
 option('enable-debug', type : 'boolean', value : false, description : 'Enable debug mode')
 option('system-sqlite', type : 'boolean', value : false, description : 'Use SQLite installed on the system 
[default=false')
+option('with-examples', type : 'boolean', value : false, description : 'Compile examples [default=false')
 


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