Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add erlang SDK#1489

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
sax wants to merge1 commit intopostgresml:master
base:master
Choose a base branch
Loading
fromreflective-dev:erlang
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions.gitignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,6 +27,17 @@ share/python-wheels/
*.egg
MANIFEST

# Erlang
*.beam
*.plt
.erlang.cookie
.eunit
.rebar
.rebar3
_build
priv/crates
rebar3.crashdump

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
Expand Down
44 changes: 44 additions & 0 deletionspgml-sdks/pgml/erlang/Makefile
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
REBAR3 ?= $(shell test -e `which rebar3` 2>/dev/null && which rebar3 || echo "./rebar3")

.PHONY: deps test build

all: build

build: $(REBAR3)
@$(REBAR3) compile

deps:
@$(REBAR3) deps

fmt:
@$(REBAR3) fmt --write

fmt-check:
@$(REBAR3) fmt --check

shell:
@$(REBAR3) cargo clean
@$(REBAR3) shell

clean:
@$(REBAR3) clean

clean-all:
rm -rf $(CURDIR)/priv/crates
rm -rf $(CURDIR)/_build

distclean: clean
@$(REBAR3) clean --all

docs:
@$(REBAR3) edoc

test:
@$(REBAR3) cargo clean
@$(REBAR3) eunit

test-all:
@$(REBAR3) do eunit, ct, cover

release: test
@$(REBAR3) as prod release
17 changes: 17 additions & 0 deletionspgml-sdks/pgml/erlang/README.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
# pgml

An Erlang NIF library written in Rust

## Build

``` shell
make
make fmt
```

## Test

``` shell
make test
```

5 changes: 5 additions & 0 deletionspgml-sdks/pgml/erlang/native/pgml/.cargo/config.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
[target.'cfg(target_os = "macos")']
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
142 changes: 142 additions & 0 deletionspgml-sdks/pgml/erlang/native/pgml/Cargo.lock
View file
Open in desktop

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

14 changes: 14 additions & 0 deletionspgml-sdks/pgml/erlang/native/pgml/Cargo.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
[package]
name = "pgml"
version = "0.1.0"
edition = "2021"


[lib]
name = "pgml"
path = "src/lib.rs"
crate-type = ["dylib"]


[dependencies]
rustler = "0.33.0"
35 changes: 35 additions & 0 deletionspgml-sdks/pgml/erlang/native/pgml/README.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
# NIF for pgml

## To compile the NIF in Erlang:

Add the following lines to your `rebar.config` file:

``` erlang
{plugins, [rebar3_rustler]}.

{cargo_opts, [
{src_dir, "native/pgml"}
]}.

{provider_hooks, [
{pre, [
{compile, {cargo, build}}
]},
{post, [
{clean, {cargo, clean}},
{eunit, {cargo, test}}
]}
]}.
```

## Build

``` shell
cargo build
```

## Test

``` shell
cargo test
```
4 changes: 4 additions & 0 deletionspgml-sdks/pgml/erlang/native/pgml/rust-toolchain.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "nightly"
components = [ "rustfmt", "clippy" ]
profile = "minimal"
4 changes: 4 additions & 0 deletionspgml-sdks/pgml/erlang/native/pgml/src/lib.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
rustler::init!("pgml", []);

#[cfg(test)]
mod tests {}
27 changes: 27 additions & 0 deletionspgml-sdks/pgml/erlang/rebar.config
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
{project_plugins, [{erlfmt, "~> 1.3"}]}.

{erl_opts, [debug_info]}.

{deps, []}.

{plugins, [rebar3_cargo]}.

{cargo_opts, [
{src_dir, "native/pgml"}
]}.

{provider_hooks, [
{pre, [
{compile, {cargo, build}}
]},
{post, [
{clean, {cargo, clean}},
{eunit, {cargo, test}}
]}
]}.

{erlfmt, [
check,
verbose,
{files, ["src/*", "rebar.config"]}
]}.
1 change: 1 addition & 0 deletionspgml-sdks/pgml/erlang/rebar.lock
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
[].
14 changes: 14 additions & 0 deletionspgml-sdks/pgml/erlang/src/cargo.hrl
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
-cargo_header_version(1).
-ifndef(CARGO_LOAD_APP).
-define(CARGO_LOAD_APP, pgml).
-endif.
-ifndef(CARGO_HRL).
-define(CARGO_HRL, 1).
-define(load_nif_from_crate(__CRATE, __INIT),
(fun() ->
__APP = ?CARGO_LOAD_APP,
__PATH = filename:join([code:priv_dir(__APP), "crates", __CRATE, __CRATE]),
erlang:load_nif(__PATH, __INIT)
end)()
).
-endif.
14 changes: 14 additions & 0 deletionspgml-sdks/pgml/erlang/src/pgml.app.src
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
{application, pgml, [
{description, "An OTP library"},
{vsn, "0.1.0"},
{registered, []},
{applications, [
kernel,
stdlib
]},
{env, []},
{modules, []},

{licenses, ["Apache 2.0"]},
{links, []}
]}.
33 changes: 33 additions & 0 deletionspgml-sdks/pgml/erlang/src/pgml.erl
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
-module(pgml).

-export([]).

-include("cargo.hrl").

-on_load init/0.

-define(NOT_LOADED, not_loaded(?LINE)).

%%%===================================================================
%%% API
%%%===================================================================

%%%===================================================================
%%% NIF
%%%===================================================================

init() ->
?load_nif_from_crate(pgml, 0).

not_loaded(Line) ->
erlang:nif_error({not_loaded, [{module, ?MODULE}, {line, Line}]}).

%%%===================================================================
%%% Tests
%%%===================================================================

-ifdef(TEST).

-include_lib("eunit/include/eunit.hrl").

-endif.

[8]ページ先頭

©2009-2025 Movatter.jp