Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add OCaml Binding #2757

Merged
merged 21 commits into from
Aug 4, 2023
Merged
57 changes: 57 additions & 0 deletions .github/workflows/bindings_ocaml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# 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: Bindings Ocaml CI

on:
push:
branches:
- main
tags:
- '*'
pull_request:
branches:
- main
paths:
- "bindings/ocaml/**"
- ".github/workflows/bindings_ocaml.yml"
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout PR
uses: actions/checkout@v2

- name: Set up ocaml
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 4.14
dune-cache: true
- name: Checks
run: |
# make sure tests pass
opam install -y dune ounit2 ocamlformat
eval $(opam env)
cd bindings/ocaml
dune runtest
dune build @fmt



37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ jobs:
distribution: temurin
java-version: "11"

- name: Checkout ocaml env
Xuanwo marked this conversation as resolved.
Show resolved Hide resolved
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 4.14
dune-cache: true
- name: Set Opam env
run: opam env | tr '\n' ' ' >> $GITHUB_ENV
- name: Add Opam switch to PATH
run: opam var bin >> $GITHUB_PATH

- name: Cargo doc
run: cargo doc --lib --no-deps --all-features -p opendal

Expand All @@ -99,6 +109,15 @@ jobs:
with:
distribution: temurin
java-version: "11"
- name: Checkout ocaml env
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 4.14
dune-cache: true
- name: Set Opam env
run: opam env | tr '\n' ' ' >> $GITHUB_ENV
- name: Add Opam switch to PATH
run: opam var bin >> $GITHUB_PATH

- name: Cargo clippy
run: cargo clippy --all-targets --all-features --workspace -- -D warnings
Expand Down Expand Up @@ -145,6 +164,15 @@ jobs:
with:
distribution: temurin
java-version: "11"
- name: Checkout ocaml env
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 4.14
dune-cache: true
- name: Set Opam env
run: opam env | tr '\n' ' ' >> $GITHUB_ENV
- name: Add Opam switch to PATH
run: opam var bin >> $GITHUB_PATH

- name: Setup Rust toolchain
uses: ./.github/actions/setup
Expand All @@ -168,6 +196,15 @@ jobs:
with:
distribution: temurin
java-version: "11"
- name: Checkout ocaml env
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 4.14
dune-cache: true
- name: Set Opam env
run: opam env | tr '\n' ' ' >> $GITHUB_ENV
- name: Add Opam switch to PATH
run: opam var bin >> $GITHUB_PATH

- name: Setup Rust toolchain
uses: ./.github/actions/setup
Expand Down
87 changes: 87 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ members = [
"bindings/haskell",
"bindings/lua",
"bindings/dotnet",
"bindings/ocaml",

"bin/oli",
"bin/oay",
Expand Down
1 change: 1 addition & 0 deletions bindings/ocaml/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_build
Empty file added bindings/ocaml/.ocamlformat
Empty file.
1 change: 1 addition & 0 deletions bindings/ocaml/.ocamlformat-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/**
40 changes: 40 additions & 0 deletions bindings/ocaml/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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.

[package]
name = "opendal-ocaml"
publish = false

authors.workspace = true
edition.workspace = true
homepage.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
version.workspace = true

[lib]
crate-type = ["staticlib", "cdylib"]
doc = false

[dependencies]
opendal.workspace = true
ocaml = {version = "^1.0.0-beta"}

[build-dependencies]
ocaml-build = {version = "^1.0.0-beta"}

22 changes: 22 additions & 0 deletions bindings/ocaml/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# OpenDAL OCaml Binding (WIP)

## Requirements

* OCaml version > 4.03 and < 5.0.0


## Build



```bash
cd bindings/ocaml
dune build
```

## Test

```bash
cd bindings/ocaml
dune test
```
20 changes: 20 additions & 0 deletions bindings/ocaml/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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.

pub fn main() -> std::io::Result<()> {
ocaml_build::Sigs::new("src/opendal.ml").generate()
}
18 changes: 18 additions & 0 deletions bindings/ocaml/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
; 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.

(dirs :standard \ target)
35 changes: 35 additions & 0 deletions bindings/ocaml/dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
(lang dune 2.0)
; 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 opendal)
(generate_opam_files true)
(license Apache-2.0)
(maintainers "OpenDAL Contributors <dev@opendal.apache.org>")
(authors "OpenDAL Contributors <dev@opendal.apache.org>")
(source (github apache/incubator-opendal))
(documentation "https://opendal.apache.org/")
(package
(name opendal)
(synopsis "Open Data Access Layer: Access data freely")
(description
"OpenDAL is a data access layer that allows users to easily and efficiently retrieve data from various storage services in a unified way.")
(depends
(ounit2 (and (>= 2.2.6) :with-test))
(ocaml (>= "4.03.0"))
(dune (>= "1.5"))
conf-rust))