🌐 AI搜索 & 代理 主页
Skip to content

Commit a70e63b

Browse files
committed
Add empty erlang library
1 parent 83bfcf4 commit a70e63b

File tree

14 files changed

+365
-0
lines changed

14 files changed

+365
-0
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ share/python-wheels/
2727
*.egg
2828
MANIFEST
2929

30+
# Erlang
31+
*.beam
32+
*.plt
33+
.erlang.cookie
34+
.eunit
35+
.rebar
36+
.rebar3
37+
_build
38+
priv/crates
39+
rebar3.crashdump
40+
3041
# PyInstaller
3142
# Usually these files are written by a python script from a template
3243
# before PyInstaller builds the exe, so as to inject date/other infos into it.

pgml-sdks/pgml/erlang/Makefile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
REBAR3 ?= $(shell test -e `which rebar3` 2>/dev/null && which rebar3 || echo "./rebar3")
2+
3+
.PHONY: deps test build
4+
5+
all: build
6+
7+
build: $(REBAR3)
8+
@$(REBAR3) compile
9+
10+
deps:
11+
@$(REBAR3) deps
12+
13+
fmt:
14+
@$(REBAR3) fmt --write
15+
16+
fmt-check:
17+
@$(REBAR3) fmt --check
18+
19+
shell:
20+
@$(REBAR3) cargo clean
21+
@$(REBAR3) shell
22+
23+
clean:
24+
@$(REBAR3) clean
25+
26+
clean-all:
27+
rm -rf $(CURDIR)/priv/crates
28+
rm -rf $(CURDIR)/_build
29+
30+
distclean: clean
31+
@$(REBAR3) clean --all
32+
33+
docs:
34+
@$(REBAR3) edoc
35+
36+
test:
37+
@$(REBAR3) cargo clean
38+
@$(REBAR3) eunit
39+
40+
test-all:
41+
@$(REBAR3) do eunit, ct, cover
42+
43+
release: test
44+
@$(REBAR3) as prod release

pgml-sdks/pgml/erlang/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# pgml
2+
3+
An Erlang NIF library written in Rust
4+
5+
## Build
6+
7+
``` shell
8+
make
9+
make fmt
10+
```
11+
12+
## Test
13+
14+
``` shell
15+
make test
16+
```
17+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[target.'cfg(target_os = "macos")']
2+
rustflags = [
3+
"-C", "link-arg=-undefined",
4+
"-C", "link-arg=dynamic_lookup",
5+
]

pgml-sdks/pgml/erlang/native/pgml/Cargo.lock

Lines changed: 142 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "pgml"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
7+
[lib]
8+
name = "pgml"
9+
path = "src/lib.rs"
10+
crate-type = ["dylib"]
11+
12+
13+
[dependencies]
14+
rustler = "0.33.0"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# NIF for pgml
2+
3+
## To compile the NIF in Erlang:
4+
5+
Add the following lines to your `rebar.config` file:
6+
7+
``` erlang
8+
{plugins, [rebar3_rustler]}.
9+
10+
{cargo_opts, [
11+
{src_dir, "native/pgml"}
12+
]}.
13+
14+
{provider_hooks, [
15+
{pre, [
16+
{compile, {cargo, build}}
17+
]},
18+
{post, [
19+
{clean, {cargo, clean}},
20+
{eunit, {cargo, test}}
21+
]}
22+
]}.
23+
```
24+
25+
## Build
26+
27+
``` shell
28+
cargo build
29+
```
30+
31+
## Test
32+
33+
``` shell
34+
cargo test
35+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[toolchain]
2+
channel = "nightly"
3+
components = [ "rustfmt", "clippy" ]
4+
profile = "minimal"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
rustler::init!("pgml", []);
2+
3+
#[cfg(test)]
4+
mod tests {}

pgml-sdks/pgml/erlang/rebar.config

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{project_plugins, [{erlfmt, "~> 1.3"}]}.
2+
3+
{erl_opts, [debug_info]}.
4+
5+
{deps, []}.
6+
7+
{plugins, [rebar3_cargo]}.
8+
9+
{cargo_opts, [
10+
{src_dir, "native/pgml"}
11+
]}.
12+
13+
{provider_hooks, [
14+
{pre, [
15+
{compile, {cargo, build}}
16+
]},
17+
{post, [
18+
{clean, {cargo, clean}},
19+
{eunit, {cargo, test}}
20+
]}
21+
]}.
22+
23+
{erlfmt, [
24+
check,
25+
verbose,
26+
{files, ["src/*", "rebar.config"]}
27+
]}.

0 commit comments

Comments
 (0)