-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(c/driver-manager): Add support to build Vala bindings
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'. Also examples are provided.
- Loading branch information
Showing
9 changed files
with
282 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<!--- | ||
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. | ||
--> | ||
|
||
# Arrow GLib example | ||
|
||
There are example codes in this directory. | ||
|
||
C example codes exist in this directory. Language bindings example | ||
codes exists in sub directories. For example, Lua example codes exists | ||
in `lua/` sub directory. | ||
|
||
## C example codes | ||
|
||
Here are example codes in this directory: | ||
|
||
* `build.c`: It shows how to create an array by array builder. | ||
|
||
<!--- | ||
* `write-file.c`: It shows how to write Arrow array to file in file | ||
format. | ||
--> | ||
|
||
* `read-file.c`: It shows how to read Arrow array from file in file | ||
format. | ||
|
||
<!--- | ||
* `write-stream.c`: It shows how to write Arrow array to file in | ||
stream format. | ||
--> | ||
|
||
* `read-stream.c`: It shows how to read Arrow array from file in | ||
stream format. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- indent-tabs-mode: nil -*- | ||
# | ||
# 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. | ||
|
||
executable('sqlite', 'sqlite.c', | ||
dependencies: [adbc_glib], | ||
link_language: 'c') | ||
|
||
install_data('README.md', | ||
install_dir: join_paths(data_dir, meson.project_name(), 'example')) | ||
|
||
subdir('vala') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* 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> | ||
|
||
int main(int argc, char** argv) { | ||
GADBCDatabase* database; | ||
GADBCConnection* conn; | ||
GError* error = NULL; | ||
|
||
database = gadbc_database_new(&error); | ||
|
||
if (error != NULL) { | ||
g_print("Error creating a Database: %s", error->message); | ||
return 1; | ||
} | ||
|
||
gadbc_database_set_option(database, "driver", "adbc_driver_sqlite", &error); | ||
|
||
if (error != NULL) { | ||
g_print("Error initializing the database: %s", error->message); | ||
return 1; | ||
} | ||
|
||
gadbc_database_set_option(database, "uri", "test.db", &error); | ||
|
||
if (error != NULL) { | ||
g_print("Error initializing the database: %s", error->message); | ||
return 1; | ||
} | ||
|
||
gadbc_database_init(database, &error); | ||
|
||
if (error != NULL) { | ||
g_print("Error initializing the database: %s", error->message); | ||
return 1; | ||
} | ||
|
||
conn = gadbc_connection_new(&error); | ||
|
||
if (error != NULL) { | ||
g_print("Error creating a Connection: %s", error->message); | ||
return 1; | ||
} | ||
|
||
gadbc_connection_init(conn, database, &error); | ||
|
||
if (error != NULL) { | ||
g_print("Error initializing a Connection: %s", error->message); | ||
return 1; | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 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 posix XXX.vala | ||
``` | ||
|
||
## Vala example codes | ||
|
||
Here are example codes in this directory: | ||
|
||
* `build.vala`: It shows how to create an array by array builder. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- indent-tabs-mode: nil -*- | ||
# | ||
# 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. | ||
|
||
if generate_vapi | ||
vala_example_executable_kwargs = { | ||
'c_args': [ | ||
'-I' + meson.build_root(), | ||
'-I' + meson.source_root(), | ||
], | ||
'dependencies': [ | ||
adbc_glib_vapi, | ||
dependency('gobject-2.0'), | ||
], | ||
'vala_args': [ | ||
'--pkg', 'posix', | ||
], | ||
} | ||
executable('sqlite', 'sqlite.vala', | ||
kwargs: vala_example_executable_kwargs) | ||
endif | ||
|
||
install_data('README.md', | ||
install_dir: join_paths(data_dir, | ||
meson.project_name(), | ||
'example', | ||
'vala')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
|
||
|
||
int main (string[] args) { | ||
try { | ||
var database = new GADBC.Database (); | ||
database.set_option ("driver", "adbc_driver_sqlite"); | ||
database.set_option ("uri", "test.db"); | ||
database.init (); | ||
var conn = new GADBC.Connection (); | ||
conn.init (database); | ||
} | ||
catch (GLib.Error e) { | ||
GLib.message ("Error: %s", e.message); | ||
} | ||
|
||
return Posix.EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters