Skip to content

Commit 5b2ab47

Browse files
committed
Initial D bindings support
wip: fix wrapper generated by `gir-to-d`
1 parent a3c39ec commit 5b2ab47

13 files changed

+514
-0
lines changed

Diff for: .github/workflows/d.yml

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: D
19+
20+
on:
21+
push:
22+
branches:
23+
- '**'
24+
- '!dependabot/**'
25+
tags:
26+
- '**'
27+
paths:
28+
- '.dockerignore'
29+
- '.github/workflows/d.yml'
30+
- 'ci/docker/*d*'
31+
- 'ci/scripts/d_*'
32+
- 'docker-compose.yml'
33+
- 'd/**'
34+
pull_request:
35+
paths:
36+
- '.dockerignore'
37+
- '.github/workflows/d.yml'
38+
- 'ci/docker/*d*'
39+
- 'ci/scripts/d_*'
40+
- 'docker-compose.yml'
41+
- 'd/**'
42+
43+
concurrency:
44+
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
45+
cancel-in-progress: true
46+
47+
permissions:
48+
contents: read
49+
50+
env:
51+
ARCHERY_DEBUG: 1
52+
DOCKER_VOLUME_PREFIX: ".docker/"
53+
54+
jobs:
55+
docker:
56+
name: AMD64 Ubuntu D LDC2
57+
runs-on: ubuntu-latest
58+
if: ${{ !contains(github.event.pull_request.title, 'WIP') }}
59+
timeout-minutes: 15
60+
steps:
61+
- name: Checkout Arrow
62+
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
63+
with:
64+
fetch-depth: 0
65+
submodules: recursive
66+
- name: Setup Python on hosted runner
67+
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
68+
with:
69+
python-version: 3
70+
- name: Setup Archery
71+
run: pip install -e dev/archery[docker]
72+
- name: Execute Docker Build
73+
env:
74+
ARCHERY_DOCKER_USER: ${{ secrets.DOCKERHUB_USER }}
75+
ARCHERY_DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
76+
run: |
77+
source ci/scripts/util_enable_core_dumps.sh
78+
archery docker run ubuntu-d
79+
- name: Docker Push
80+
if: >-
81+
success() &&
82+
github.event_name == 'push' &&
83+
github.repository == 'apache/arrow' &&
84+
github.ref_name == 'main'
85+
env:
86+
ARCHERY_DOCKER_USER: ${{ secrets.DOCKERHUB_USER }}
87+
ARCHERY_DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
88+
continue-on-error: true
89+
run: archery docker push ubuntu-d

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ build.ninja
4444
perf.data
4545
perf.data.old
4646

47+
build/
4748
cpp/.idea/
4849
.clangd/
4950
cpp/.clangd/

Diff for: ci/docker/ubuntu-d.dockerfile

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
ARG base=amd64/ubuntu:24.04
19+
FROM ${base}
20+
21+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
22+
23+
RUN echo "debconf debconf/frontend select Noninteractive" |
24+
debconf-set-selections
25+
26+
# Install ldc2 toolchain (dmd-frontend + llvm-backend) & dub package manager
27+
RUN apt-get update -y -q &&
28+
apt-get install -y -q --no-install-recommends \
29+
ldc \
30+
dub \
31+
unzip \
32+
wget &&
33+
apt-get clean

Diff for: ci/scripts/d_test.sh

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
20+
set -ex
21+
22+
source_dir=${1}/d
23+
24+
export DYLD_LIBRARY_PATH=${ARROW_HOME}/lib:${DYLD_LIBRARY_PATH}
25+
export LD_LIBRARY_PATH=${ARROW_HOME}/lib:${LD_LIBRARY_PATH}
26+
export PKG_CONFIG_PATH=${ARROW_HOME}/lib/pkgconfig
27+
export GI_TYPELIB_PATH=${ARROW_HOME}/lib/girepository-1.0
28+
29+
# Enable memory debug checks if the env is not set already
30+
if [ -z "${ARROW_DEBUG_MEMORY_POOL}" ]; then
31+
export ARROW_DEBUG_MEMORY_POOL=trap
32+
fi
33+
34+
dub test --root=${source_dir}

Diff for: d/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# unittest files
2+
*test*
3+
# generated files
4+
source/arrow*/

Diff for: d/README.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!---
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
# Apache Arrow
21+
22+
An implementation of Arrow targeting D programming language.
23+
24+
See our current [feature matrix](https://github.com/apache/arrow/blob/main/docs/source/status.rst)
25+
for currently available features.
26+
27+
# Requirements
28+
29+
- [dmd/gdc/ldc2](https://dlang.org/download) with druntime-frontend 2.105.0 or later
30+
31+
# Building
32+
33+
- build Arrow library (C++)
34+
- build C glib bindings
35+
- build D bindings
36+
37+
```bash
38+
$ git clone https://github.com/apache/arrow.git
39+
$ cd arrow/d
40+
$ dub build -b release
41+
# Test
42+
$ dub test
43+
```

Diff for: d/dub.json

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "arrow-d",
3+
"description": "Apache Arrow - D bindings",
4+
"license": "Apache-2.0",
5+
"toolchainRequirements": {
6+
"frontend": ">=2.105.3"
7+
},
8+
"buildTypes": {
9+
"debug": {
10+
"buildOptions": [
11+
"debugMode",
12+
"debugInfo"
13+
]
14+
},
15+
"release": {
16+
"buildOptions": [
17+
"releaseMode",
18+
"inline",
19+
"optimize"
20+
]
21+
}
22+
},
23+
"preBuildCommands": [
24+
"\"$DUB\" run girtod -- -i source -o source --use-runtime-linker"
25+
],
26+
"dependencies": {
27+
"glibd": {
28+
"repository": "git+https://github.com/gtkd-developers/GlibD.git",
29+
"version": "1546823185334c4727d378baf890fa13d9fa4cbd"
30+
}
31+
},
32+
"configurations": [
33+
{
34+
"name": "unittest",
35+
"sourceFiles": [
36+
"source/package.d"
37+
],
38+
"libs": [
39+
"arrow-glib"
40+
],
41+
"dflags-dmd": ["-verrors=context"],
42+
"dflags-ldc": ["--verrors-context"]
43+
}
44+
]
45+
46+
}

Diff for: d/source/APILookup.txt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
includeComments: y
19+
20+
lookup: APILookupArrow.txt
21+
################
22+
##### TODO #####
23+
################
24+
# lookup: APILookupArrowDataset.txt
25+
# lookup: APILookupArrowFlight.txt

Diff for: d/source/APILookupArrow.txt

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# add apache license in wrapped modules
19+
20+
license: start
21+
/*
22+
* Licensed to the Apache Software Foundation (ASF) under one
23+
* or more contributor license agreements. See the NOTICE file
24+
* distributed with this work for additional information
25+
* regarding copyright ownership. The ASF licenses this file
26+
* to you under the Apache License, Version 2.0 (the
27+
* "License"); you may not use this file except in compliance
28+
* with the License. You may obtain a copy of the License at
29+
*
30+
* http://www.apache.org/licenses/LICENSE-2.0
31+
*
32+
* Unless required by applicable law or agreed to in writing,
33+
* software distributed under the License is distributed on an
34+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
35+
* KIND, either express or implied. See the License for the
36+
* specific language governing permissions and limitations
37+
* under the License.
38+
*/
39+
40+
// generated automatically - do not change
41+
// find conversion definition on APILookup.txt
42+
// implement new conversion functionalities the gir-to-d package
43+
44+
45+
license: end
46+
47+
#############################################
48+
### Definitions for wrapping Arrow ##########
49+
#############################################
50+
51+
# arrow wrapper edit
52+
wrap: arrow
53+
file: Arrow-1.0.gir
54+
55+
# rename
56+
alias: import import_
57+
58+
# How to fix static-functions? (in arrow/c/functions.d)

0 commit comments

Comments
 (0)