Skip to content

Commit

Permalink
Initial D bindings support
Browse files Browse the repository at this point in the history
wip: fix wrapper generated by `gir-to-d`
  • Loading branch information
kassane committed Oct 27, 2024
1 parent a3c39ec commit 5b2ab47
Show file tree
Hide file tree
Showing 13 changed files with 514 additions and 0 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/d.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# 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.

name: D

on:
push:
branches:
- '**'
- '!dependabot/**'
tags:
- '**'
paths:
- '.dockerignore'
- '.github/workflows/d.yml'
- 'ci/docker/*d*'
- 'ci/scripts/d_*'
- 'docker-compose.yml'
- 'd/**'
pull_request:
paths:
- '.dockerignore'
- '.github/workflows/d.yml'
- 'ci/docker/*d*'
- 'ci/scripts/d_*'
- 'docker-compose.yml'
- 'd/**'

concurrency:
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true

permissions:
contents: read

env:
ARCHERY_DEBUG: 1
DOCKER_VOLUME_PREFIX: ".docker/"

jobs:
docker:
name: AMD64 Ubuntu D LDC2
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.title, 'WIP') }}
timeout-minutes: 15
steps:
- name: Checkout Arrow
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
fetch-depth: 0
submodules: recursive
- name: Setup Python on hosted runner
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: 3
- name: Setup Archery
run: pip install -e dev/archery[docker]
- name: Execute Docker Build
env:
ARCHERY_DOCKER_USER: ${{ secrets.DOCKERHUB_USER }}
ARCHERY_DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
run: |
source ci/scripts/util_enable_core_dumps.sh
archery docker run ubuntu-d
- name: Docker Push
if: >-
success() &&
github.event_name == 'push' &&
github.repository == 'apache/arrow' &&
github.ref_name == 'main'
env:
ARCHERY_DOCKER_USER: ${{ secrets.DOCKERHUB_USER }}
ARCHERY_DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
continue-on-error: true
run: archery docker push ubuntu-d
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ build.ninja
perf.data
perf.data.old

build/
cpp/.idea/
.clangd/
cpp/.clangd/
Expand Down
33 changes: 33 additions & 0 deletions ci/docker/ubuntu-d.dockerfile
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.

ARG base=amd64/ubuntu:24.04
FROM ${base}

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN echo "debconf debconf/frontend select Noninteractive" |
debconf-set-selections

# Install ldc2 toolchain (dmd-frontend + llvm-backend) & dub package manager
RUN apt-get update -y -q &&
apt-get install -y -q --no-install-recommends \
ldc \
dub \
unzip \
wget &&
apt-get clean
34 changes: 34 additions & 0 deletions ci/scripts/d_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
#
# 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.

set -ex

source_dir=${1}/d

export DYLD_LIBRARY_PATH=${ARROW_HOME}/lib:${DYLD_LIBRARY_PATH}
export LD_LIBRARY_PATH=${ARROW_HOME}/lib:${LD_LIBRARY_PATH}
export PKG_CONFIG_PATH=${ARROW_HOME}/lib/pkgconfig
export GI_TYPELIB_PATH=${ARROW_HOME}/lib/girepository-1.0

# Enable memory debug checks if the env is not set already
if [ -z "${ARROW_DEBUG_MEMORY_POOL}" ]; then
export ARROW_DEBUG_MEMORY_POOL=trap
fi

dub test --root=${source_dir}
4 changes: 4 additions & 0 deletions d/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# unittest files
*test*
# generated files
source/arrow*/
43 changes: 43 additions & 0 deletions d/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!---
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.
-->

# Apache Arrow

An implementation of Arrow targeting D programming language.

See our current [feature matrix](https://github.com/apache/arrow/blob/main/docs/source/status.rst)
for currently available features.

# Requirements

- [dmd/gdc/ldc2](https://dlang.org/download) with druntime-frontend 2.105.0 or later

# Building

- build Arrow library (C++)
- build C glib bindings
- build D bindings

```bash
$ git clone https://github.com/apache/arrow.git
$ cd arrow/d
$ dub build -b release
# Test
$ dub test
```
46 changes: 46 additions & 0 deletions d/dub.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "arrow-d",
"description": "Apache Arrow - D bindings",
"license": "Apache-2.0",
"toolchainRequirements": {
"frontend": ">=2.105.3"
},
"buildTypes": {
"debug": {
"buildOptions": [
"debugMode",
"debugInfo"
]
},
"release": {
"buildOptions": [
"releaseMode",
"inline",
"optimize"
]
}
},
"preBuildCommands": [
"\"$DUB\" run girtod -- -i source -o source --use-runtime-linker"
],
"dependencies": {
"glibd": {
"repository": "git+https://github.com/gtkd-developers/GlibD.git",
"version": "1546823185334c4727d378baf890fa13d9fa4cbd"
}
},
"configurations": [
{
"name": "unittest",
"sourceFiles": [
"source/package.d"
],
"libs": [
"arrow-glib"
],
"dflags-dmd": ["-verrors=context"],
"dflags-ldc": ["--verrors-context"]
}
]

}
25 changes: 25 additions & 0 deletions d/source/APILookup.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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.

includeComments: y

lookup: APILookupArrow.txt
################
##### TODO #####
################
# lookup: APILookupArrowDataset.txt
# lookup: APILookupArrowFlight.txt
58 changes: 58 additions & 0 deletions d/source/APILookupArrow.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# 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.

# add apache license in wrapped modules

license: start
/*
* 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.
*/

// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities the gir-to-d package


license: end

#############################################
### Definitions for wrapping Arrow ##########
#############################################

# arrow wrapper edit
wrap: arrow
file: Arrow-1.0.gir

# rename
alias: import import_

# How to fix static-functions? (in arrow/c/functions.d)
Loading

0 comments on commit 5b2ab47

Please sign in to comment.