This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new da364d6a feat(glib): add Vala VAPI for GADBC (#1152)
da364d6a is described below
commit da364d6a5c20a7ea10df468532a2e7ed2e395006
Author: Daniel Espinosa <[email protected]>
AuthorDate: Tue Nov 14 01:15:12 2023 -0600
feat(glib): add Vala VAPI for GADBC (#1152)
Vala VAPI file is generated for current GADBC 1.0 API version.
It is disable by default, but recommended to be enable when a
development package is distributed.
This commit force a 1.0 API versioning, replacing the old one where 0
were used for GIR API version (gir_version), so now shows '1.0' instead
of '0.0'.
---------
Co-authored-by: Sutou Kouhei <[email protected]>
---
.pre-commit-config.yaml | 6 +
ci/linux-packages/debian/control | 3 +-
ci/linux-packages/debian/libadbc-glib-dev.install | 2 +
ci/linux-packages/debian/rules | 29 ++---
ci/linux-packages/yum/almalinux-8/Dockerfile | 3 +-
ci/linux-packages/yum/almalinux-9/Dockerfile | 3 +-
ci/linux-packages/yum/apache-arrow-adbc.spec.in | 16 ++-
ci/scripts/glib_build.sh | 11 ++
dev/release/verify-apt.sh | 1 +
glib/adbc-glib/error.h | 2 +-
glib/adbc-glib/meson.build | 6 +
glib/example/README.md | 33 +++++
glib/{meson_options.txt => example/meson.build} | 19 ++-
glib/example/sqlite.c | 135 +++++++++++++++++++++
glib/example/vala/README.md | 36 ++++++
.../vala/meson.build} | 33 ++++-
glib/example/vala/sqlite.vala | 62 ++++++++++
glib/meson.build | 13 +-
glib/meson_options.txt | 10 ++
19 files changed, 389 insertions(+), 34 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 9b96d955..01e624ca 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -87,6 +87,12 @@ repos:
hooks:
- id: isort
types_or: [python]
+ # TODO: Change this to vala-lang/vala-lint after
+ # https://github.com/vala-lang/vala-lint/pull/179 is merged.
+ - repo: https://github.com/kou/vala-lint
+ rev: pre-commit-hook
+ hooks:
+ - id: vala-lint
- repo: local
hooks:
- id: apache-rat
diff --git a/ci/linux-packages/debian/control b/ci/linux-packages/debian/control
index b88fa12f..cc5441e7 100644
--- a/ci/linux-packages/debian/control
+++ b/ci/linux-packages/debian/control
@@ -180,8 +180,7 @@ Multi-Arch: same
Depends:
${misc:Depends},
gir1.2-adbc-1.0 (= ${binary:Version}),
- libadbc-driver-manager-dev (= ${binary:Version}),
- libarrow-glib-dev
+ libadbc-driver-manager-dev (= ${binary:Version})
Description: Apache Arrow Database Connectivity (ADBC) driver manager
.
This package provides GLib based header files.
diff --git a/ci/linux-packages/debian/libadbc-glib-dev.install
b/ci/linux-packages/debian/libadbc-glib-dev.install
index d8b552a6..7e5f0d8d 100644
--- a/ci/linux-packages/debian/libadbc-glib-dev.install
+++ b/ci/linux-packages/debian/libadbc-glib-dev.install
@@ -1,4 +1,6 @@
usr/include/adbc-glib/
usr/lib/*/libadbc-glib.so
usr/lib/*/pkgconfig/adbc-glib.pc
+usr/share/adbc-glib/example/
usr/share/gir-1.0/ADBC-*.gir
+usr/share/vala/vapi/*
diff --git a/ci/linux-packages/debian/rules b/ci/linux-packages/debian/rules
index b56d1a8a..2a766d5d 100755
--- a/ci/linux-packages/debian/rules
+++ b/ci/linux-packages/debian/rules
@@ -31,23 +31,23 @@ export DEB_BUILD_MAINT_OPTIONS=reproducible=-timeless
CMAKE_BUILD_TYPE = RelWithDebInfo
override_dh_auto_configure:
- env \
+ env \
PATH=/usr/lib/go-1.20/bin:$${PATH} \
dh_auto_configure \
- --sourcedirectory=c/ \
- --builddirectory=c.build \
+ --sourcedirectory=c/ \
+ --builddirectory=c.build \
--buildsystem=cmake+ninja \
-- \
- -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) \
- -DADBC_DRIVER_MANAGER=ON \
- -DADBC_DRIVER_POSTGRESQL=ON \
- -DADBC_DRIVER_SQLITE=ON \
- -DADBC_DRIVER_FLIGHTSQL=ON \
- -DADBC_DRIVER_SNOWFLAKE=ON
+ -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) \
+ -DADBC_DRIVER_FLIGHTSQL=ON \
+ -DADBC_DRIVER_MANAGER=ON \
+ -DADBC_DRIVER_POSTGRESQL=ON \
+ -DADBC_DRIVER_SNOWFLAKE=ON \
+ -DADBC_DRIVER_SQLITE=ON
override_dh_auto_build:
- dh_auto_build \
- --sourcedirectory=c \
+ dh_auto_build \
+ --sourcedirectory=c \
--builddirectory=c.build
dh_auto_configure \
--sourcedirectory=glib \
@@ -55,7 +55,8 @@ override_dh_auto_build:
--buildsystem=meson+ninja \
-- \
--buildtype=debugoptimized \
- -Dadbc_build_dir=../c.build/driver_manager
+ -Dadbc_build_dir=../c.build/driver_manager \
+ -Dvapi=true
env \
LD_LIBRARY_PATH=$(CURDIR)/c.build/driver_manager \
dh_auto_build \
@@ -64,8 +65,8 @@ override_dh_auto_build:
--buildsystem=meson+ninja
override_dh_auto_install:
- dh_auto_install \
- --sourcedirectory=c \
+ dh_auto_install \
+ --sourcedirectory=c \
--builddirectory=c.build
dh_auto_install \
--sourcedirectory=glib \
diff --git a/ci/linux-packages/yum/almalinux-8/Dockerfile
b/ci/linux-packages/yum/almalinux-8/Dockerfile
index e3372141..dfd10dd4 100644
--- a/ci/linux-packages/yum/almalinux-8/Dockerfile
+++ b/ci/linux-packages/yum/almalinux-8/Dockerfile
@@ -38,5 +38,6 @@ RUN \
python3-pip \
rpmdevtools \
sqlite-devel \
- tar && \
+ tar \
+ vala && \
yum clean ${quiet} all
diff --git a/ci/linux-packages/yum/almalinux-9/Dockerfile
b/ci/linux-packages/yum/almalinux-9/Dockerfile
index f32f563a..213590e8 100644
--- a/ci/linux-packages/yum/almalinux-9/Dockerfile
+++ b/ci/linux-packages/yum/almalinux-9/Dockerfile
@@ -38,5 +38,6 @@ RUN \
python3-pip \
rpmdevtools \
sqlite-devel \
- tar && \
+ tar \
+ vala && \
dnf clean ${quiet} all
diff --git a/ci/linux-packages/yum/apache-arrow-adbc.spec.in
b/ci/linux-packages/yum/apache-arrow-adbc.spec.in
index 4aa9ee3c..7a50a1fe 100644
--- a/ci/linux-packages/yum/apache-arrow-adbc.spec.in
+++ b/ci/linux-packages/yum/apache-arrow-adbc.spec.in
@@ -48,6 +48,7 @@ BuildRequires: libpq-devel
BuildRequires: ninja-build
BuildRequires: pkgconfig
BuildRequires: sqlite-devel
+BuildRequires: vala
%description
Apache Arrow Database Connectivity (ADBC) is an Apache Arrow based database
access API
@@ -63,11 +64,11 @@ cd c
%adbc_cmake \
-DCMAKE_BUILD_TYPE=${cmake_build_type} \
-G"Unix Makefiles" \
+ -DADBC_DRIVER_FLIGHTSQL=ON \
-DADBC_DRIVER_MANAGER=ON \
-DADBC_DRIVER_POSTGRESQL=ON \
- -DADBC_DRIVER_SQLITE=ON \
- -DADBC_DRIVER_FLIGHTSQL=ON \
- -DADBC_DRIVER_SNOWFLAKE=ON
+ -DADBC_DRIVER_SNOWFLAKE=ON \
+ -DADBC_DRIVER_SQLITE=ON
%adbc_cmake_build
cd -
@@ -78,7 +79,8 @@ meson setup build \
--default-library=both \
--libdir=%{_libdir} \
--prefix=%{_prefix} \
- -Dadbc_build_dir=$PWD/../c/%{adbc_cmake_builddir}/driver_manager
+ -Dadbc_build_dir=$PWD/../c/%{adbc_cmake_builddir}/driver_manager \
+ -Dvapi=true
LD_LIBRARY_PATH=$PWD/../c/%{adbc_cmake_builddir}/driver_manager \
meson compile -C build %{?_smp_mflags}
@@ -258,7 +260,7 @@ This package contains the libraries for ADBC GLib.
%defattr(-,root,root,-)
%doc README.md
%license LICENSE.txt NOTICE.txt
-%{_libdir}/girepository-1.0/ADBC-*.typelib
+%{_libdir}/girepository-1.0/
%{_libdir}/libadbc-glib.so.*
%package glib-devel
@@ -276,7 +278,8 @@ Libraries and header files for ADBC GLib.
%defattr(-,root,root,-)
%doc README.md
%license LICENSE.txt NOTICE.txt
-%{_datadir}/gir-1.0/ADBC-*.gir
+%{_datadir}/gir-1.0/
+%{_datadir}/vala/vapi/
%{_includedir}/adbc-glib/
%{_libdir}/libadbc-glib.a
%{_libdir}/libadbc-glib.so
@@ -293,6 +296,7 @@ Documentation for ADBC GLib.
%defattr(-,root,root,-)
%doc README.md
%license LICENSE.txt NOTICE.txt
+%{_datadir}/adbc-glib/example/
%{_docdir}/adbc-glib/
%changelog
diff --git a/ci/scripts/glib_build.sh b/ci/scripts/glib_build.sh
index b5cadbd7..6edd7faf 100755
--- a/ci/scripts/glib_build.sh
+++ b/ci/scripts/glib_build.sh
@@ -38,6 +38,11 @@ build_subproject() {
cmake_prefix_path="${CONDA_PREFIX}:${cmake_prefix_path}"
pkg_config_path="${pkg_config_path}:${CONDA_PREFIX}/lib/pkgconfig"
fi
+ if type valac > /dev/null 2>&1; then
+ enable_vapi=true
+ else
+ enable_vapi=false
+ fi
meson setup \
--buildtype=debug \
@@ -45,9 +50,15 @@ build_subproject() {
--libdir=lib \
--pkg-config-path="${pkg_config_path}" \
--prefix="${install_dir}" \
+ -Dexample=true \
+ -Dvapi="${enable_vapi}" \
"${build_dir}/glib" \
"${source_dir}/glib"
meson install -C "${build_dir}/glib"
+ "${build_dir}/glib/example/sqlite"
+ if [[ "${enable_vapi}" = "true" ]]; then
+ "${build_dir}/glib/example/vala/sqlite"
+ fi
}
main() {
diff --git a/dev/release/verify-apt.sh b/dev/release/verify-apt.sh
index b65e4d3f..c5bd4818 100755
--- a/dev/release/verify-apt.sh
+++ b/dev/release/verify-apt.sh
@@ -149,6 +149,7 @@ ${APT_INSTALL} libadbc-driver-manager-dev=${package_version}
required_packages=()
required_packages+=(cmake)
required_packages+=(gcc)
+required_packages+=(libc6-dev)
required_packages+=(make)
required_packages+=(pkg-config)
${APT_INSTALL} ${required_packages[@]}
diff --git a/glib/adbc-glib/error.h b/glib/adbc-glib/error.h
index 7538a244..939e6b47 100644
--- a/glib/adbc-glib/error.h
+++ b/glib/adbc-glib/error.h
@@ -69,7 +69,7 @@ G_BEGIN_DECLS
* given operation.
* May indicate a database-side error only.
*
- * The error codes are used by all arrow-glib functions.
+ * The error codes are used by all adbc-glib functions.
*
* They are corresponding to `ADBC_STATUS_*` values.
*/
diff --git a/glib/adbc-glib/meson.build b/glib/adbc-glib/meson.build
index 1fe245e5..7b76d9e0 100644
--- a/glib/adbc-glib/meson.build
+++ b/glib/adbc-glib/meson.build
@@ -102,3 +102,9 @@ adbc_glib_gir = gnome.generate_gir(libadbc_glib,
nsversion: api_version,
sources: sources + definition_headers +
enums,
symbol_prefix: 'gadbc')
+if generate_vapi
+ adbc_glib_vapi = gnome.generate_vapi('gadbc-1.0',
+ install: true,
+ packages: ['gobject-2.0'],
+ sources: [adbc_glib_gir[0]])
+endif
diff --git a/glib/example/README.md b/glib/example/README.md
new file mode 100644
index 00000000..feb18efe
--- /dev/null
+++ b/glib/example/README.md
@@ -0,0 +1,33 @@
+<!---
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+# ADBC GLib example
+
+There are example codes in this directory.
+
+C example codes exist in this directory. Language bindings example
+codes exists in sub directories:
+
+ * `vala/`: Vala examples
+
+## C example codes
+
+Here are example codes in this directory:
+
+ * `sqlite.c`: It shows how to connect to a SQLite database.
diff --git a/glib/meson_options.txt b/glib/example/meson.build
similarity index 70%
copy from glib/meson_options.txt
copy to glib/example/meson.build
index 0ae1e6c3..ed34fd02 100644
--- a/glib/meson_options.txt
+++ b/glib/example/meson.build
@@ -17,7 +17,18 @@
# specific language governing permissions and limitations
# under the License.
-option('adbc_build_dir',
- type: 'string',
- value: '',
- description: 'Use this option to build with not installed ADBC')
+if build_example
+ arrow_glib = dependency('arrow-glib')
+ executable('sqlite', 'sqlite.c',
+ dependencies: [adbc_glib, arrow_glib],
+ link_language: 'c')
+endif
+
+files = [
+ 'README.md',
+ 'sqlite.c',
+]
+install_data(files,
+ install_dir: join_paths(data_dir, meson.project_name(),
'example'))
+
+subdir('vala')
diff --git a/glib/example/sqlite.c b/glib/example/sqlite.c
new file mode 100644
index 00000000..7b2062fa
--- /dev/null
+++ b/glib/example/sqlite.c
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <stdlib.h>
+
+#include <adbc-glib/adbc-glib.h>
+#include <arrow-glib/arrow-glib.h>
+
+int main(int argc, char** argv) {
+ int exit_code = EXIT_FAILURE;
+ GADBCDatabase* database = NULL;
+ GADBCConnection* connection = NULL;
+ GADBCStatement* statement = NULL;
+ GError* error = NULL;
+
+ database = gadbc_database_new(&error);
+ if (!database) {
+ g_print("Failed to create a database: %s", error->message);
+ goto exit;
+ }
+
+ if (!gadbc_database_set_option(database, "driver", "adbc_driver_sqlite",
&error)) {
+ g_print("Failed to set driver: %s", error->message);
+ goto exit;
+ }
+ if (!gadbc_database_set_option(database, "uri", ":memory:", &error)) {
+ g_print("Failed to set database URI: %s", error->message);
+ goto exit;
+ }
+ if (!gadbc_database_init(database, &error)) {
+ g_print("Failed to initialize a database: %s", error->message);
+ goto exit;
+ }
+
+ connection = gadbc_connection_new(&error);
+ if (!connection) {
+ g_print("Failed to create a connection: %s", error->message);
+ goto exit;
+ }
+ if (!gadbc_connection_init(connection, database, &error)) {
+ g_print("Failed to initialize a connection: %s", error->message);
+ goto exit;
+ }
+
+ statement = gadbc_statement_new(connection, &error);
+ if (!statement) {
+ g_print("Failed to create a statement: %s", error->message);
+ goto exit;
+ }
+ if (!gadbc_statement_set_sql_query(statement, "select sqlite_version() as
version",
+ &error)) {
+ g_print("Failed to set a query: %s", error->message);
+ goto exit;
+ }
+
+ gpointer c_abi_array_stream;
+ gint64 n_rows_affected;
+ if (!gadbc_statement_execute(statement, TRUE, &c_abi_array_stream,
&n_rows_affected,
+ &error)) {
+ g_print("Failed to execute a query: %s", error->message);
+ goto exit;
+ }
+
+ GArrowRecordBatchReader* reader =
+ garrow_record_batch_reader_import(c_abi_array_stream, &error);
+ g_free(c_abi_array_stream);
+ if (!reader) {
+ g_print("Failed to import a result: %s", error->message);
+ goto exit;
+ }
+
+ GArrowTable* table = garrow_record_batch_reader_read_all(reader, &error);
+ g_object_unref(reader);
+ if (!table) {
+ g_print("Failed to read a result: %s", error->message);
+ goto exit;
+ }
+ gchar* table_content = garrow_table_to_string(table, &error);
+ g_object_unref(table);
+ if (!table_content) {
+ g_print("Failed to stringify a result: %s", error->message);
+ goto exit;
+ }
+ g_print("Result:\n%s\n", table_content);
+ g_free(table_content);
+
+ exit_code = EXIT_SUCCESS;
+
+exit:
+ if (error) {
+ g_error_free(error);
+ error = NULL;
+ }
+ if (statement) {
+ if (!gadbc_statement_release(statement, &error)) {
+ g_print("Failed to release a statement: %s", error->message);
+ g_error_free(error);
+ error = NULL;
+ }
+ g_object_unref(statement);
+ }
+ if (connection) {
+ if (!gadbc_connection_release(connection, &error)) {
+ g_print("Failed to release a connection: %s", error->message);
+ g_error_free(error);
+ error = NULL;
+ }
+ g_object_unref(connection);
+ }
+ if (database) {
+ if (!gadbc_database_release(database, &error)) {
+ g_print("Failed to release a database: %s", error->message);
+ g_error_free(error);
+ error = NULL;
+ }
+ g_object_unref(database);
+ }
+ return exit_code;
+}
diff --git a/glib/example/vala/README.md b/glib/example/vala/README.md
new file mode 100644
index 00000000..b28dfdae
--- /dev/null
+++ b/glib/example/vala/README.md
@@ -0,0 +1,36 @@
+<!---
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+# ADBC GLib Vala example
+
+There are Vala example codes in this directory.
+
+## How to build
+
+Here is a command line to build an example in this directory:
+
+```console
+$ valac --pkg adbc-glib --pkg arrow-glib --pkg posix XXX.vala
+```
+
+## Vala example codes
+
+Here are example codes in this directory:
+
+ * `sqlite.vala`: It shows how to connect to a SQLite database.
diff --git a/glib/meson_options.txt b/glib/example/vala/meson.build
similarity index 52%
copy from glib/meson_options.txt
copy to glib/example/vala/meson.build
index 0ae1e6c3..3486a8c9 100644
--- a/glib/meson_options.txt
+++ b/glib/example/vala/meson.build
@@ -17,7 +17,32 @@
# specific language governing permissions and limitations
# under the License.
-option('adbc_build_dir',
- type: 'string',
- value: '',
- description: 'Use this option to build with not installed ADBC')
+if build_example and generate_vapi
+ vala_example_executable_kwargs = {
+ 'c_args': [
+ '-I' + meson.build_root(),
+ '-I' + meson.source_root(),
+ ],
+ 'dependencies': [
+ adbc_glib_vapi,
+ arrow_glib,
+ dependency('gobject-2.0'),
+ ],
+ 'vala_args': [
+ '--pkg', 'posix',
+ '--vapidir', arrow_glib.get_variable('vapidir'),
+ ],
+ }
+ executable('sqlite', 'sqlite.vala',
+ kwargs: vala_example_executable_kwargs)
+endif
+
+files = [
+ 'README.md',
+ 'sqlite.vala',
+]
+install_data(files,
+ install_dir: join_paths(data_dir,
+ meson.project_name(),
+ 'example',
+ 'vala'))
diff --git a/glib/example/vala/sqlite.vala b/glib/example/vala/sqlite.vala
new file mode 100644
index 00000000..76183539
--- /dev/null
+++ b/glib/example/vala/sqlite.vala
@@ -0,0 +1,62 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+int main (string[] args) {
+ var exit_code = Posix.EXIT_FAILURE;
+
+ try {
+ var database = new GADBC.Database ();
+ database.set_option ("driver", "adbc_driver_sqlite");
+ database.set_option ("uri", ":memory:");
+ database.init ();
+ try {
+ var connection = new GADBC.Connection ();
+ connection.init (database);
+ try {
+ var statement = new GADBC.Statement (connection);
+ string sql = "SELECT sqlite_version() AS version";
+ statement.set_sql_query (sql);
+ try {
+ void *c_abi_array_stream = null;
+ int64 n_rows_affected;
+ statement.execute (true, out c_abi_array_stream, out
n_rows_affected);
+ try {
+ var reader = GArrow.RecordBatchReader.import
(c_abi_array_stream);
+ var table = reader.read_all ();
+ stdout.printf ("Result:\n%s", table.to_string ());
+ } finally {
+ GLib.free (c_abi_array_stream);
+ }
+ exit_code = Posix.EXIT_SUCCESS;
+ } catch (GLib.Error error) {
+ GLib.error ("Failed to execute a statement: %s",
error.message);
+ }
+ }
+ catch (GLib.Error error) {
+ GLib.error ("Failed to create a statement: %s", error.message);
+ }
+ }
+ catch (GLib.Error error) {
+ GLib.error ("Failed to create a connection: %s", error.message);
+ }
+ }
+ catch (GLib.Error error) {
+ GLib.error ("Failed to create a database: %s", error.message);
+ }
+
+ return exit_code;
+}
diff --git a/glib/meson.build b/glib/meson.build
index 03dccc2e..0deee035 100644
--- a/glib/meson.build
+++ b/glib/meson.build
@@ -30,7 +30,7 @@ version_major = version_numbers[0].to_int()
version_minor = version_numbers[1].to_int()
version_micro = version_numbers[2].to_int()
-api_version = '@[email protected]'.format(version_major)
+api_version = '1.0'
so_version = version_major
library_version = '.'.join(version_numbers)
@@ -39,6 +39,7 @@ include_dir = get_option('includedir')
project_include_sub_dir = meson.project_name()
data_dir = get_option('datadir')
gir_dir = prefix / data_dir / 'gir-1.0'
+vapi_dir = data_dir / 'vala' / 'vapi'
gnome = import('gnome')
pkgconfig = import('pkgconfig')
@@ -67,7 +68,17 @@ else
dirs: [adbc_build_dir])
endif
+build_example = get_option('example')
+
+dependency('gobject-introspection-1.0', required: false).found()
+generate_vapi = get_option('vapi')
+if generate_vapi
+ pkgconfig_variables += ['vapidir=@0@'.format(vapi_dir)]
+ add_languages('vala')
+endif
+
subdir('adbc-glib')
+subdir('example')
install_data('../LICENSE.txt',
'README.md',
diff --git a/glib/meson_options.txt b/glib/meson_options.txt
index 0ae1e6c3..8603b783 100644
--- a/glib/meson_options.txt
+++ b/glib/meson_options.txt
@@ -21,3 +21,13 @@ option('adbc_build_dir',
type: 'string',
value: '',
description: 'Use this option to build with not installed ADBC')
+
+option('example',
+ type: 'boolean',
+ value: false,
+ description: 'Build example')
+
+option('vapi',
+ type: 'boolean',
+ value: false,
+ description: 'Build Vala API')