-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
497de8b
commit d800f8f
Showing
16 changed files
with
1,733 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Elixir | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
variation: | ||
- otp: "27.x" | ||
elixir: "1.18" | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Set up Elixir | ||
uses: erlef/setup-beam@v1 | ||
with: | ||
otp-version: ${{matrix.variation.otp}} | ||
elixir-version: ${{matrix.variation.elixir}} | ||
|
||
- name: Restore dependencies cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: deps | ||
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} | ||
restore-keys: ${{ runner.os }}-mix- | ||
|
||
- name: Build BLST | ||
run: | | ||
cd src | ||
make blst | ||
- name: Build CKZG | ||
run: | | ||
cd src | ||
make | ||
- name: Install dependencies | ||
run: mix deps.get | ||
|
||
- name: Credo | ||
run: mix credo --strict | ||
|
||
- name: Dialyzer | ||
run: mix dialyzer | ||
|
||
- name: Test | ||
run: mix test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../src/.clang-format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Used by "mix format" | ||
[ | ||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# The directory Mix will write compiled artifacts to. | ||
/_build/ | ||
|
||
# If you run "mix test --cover", coverage assets end up here. | ||
/cover/ | ||
|
||
# The directory Mix downloads your dependencies sources to. | ||
/deps/ | ||
|
||
# Where third-party dependencies like ExDoc output generated docs. | ||
/doc/ | ||
|
||
# If the VM crashes, it generates a dump, let's ignore it too. | ||
erl_crash.dump | ||
|
||
# Also ignore archive artifacts (built via "mix archive.build"). | ||
*.ez | ||
|
||
# Ignore package tarball (built via "mix hex.build"). | ||
ckzg-*.tar | ||
|
||
# Temporary files, for example, from tests. | ||
/tmp/ | ||
|
||
.cache/ | ||
priv/build.txt | ||
priv/ckzg_nif.so | ||
.clangd | ||
compile_commands.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
CC = clang | ||
PRIV_DIR = $(MIX_APP_PATH)/priv | ||
SRC_ROOT = $(shell pwd) | ||
C_SRC = $(SRC_ROOT)/native/src | ||
|
||
CFLAGS += -Wall -Wextra -shared -std=c11 -fPIC -I"$(ERTS_INCLUDE_DIR)" | ||
UNAME_S := $(shell uname -s) | ||
ifndef TARGET_ABI | ||
ifeq ($(UNAME_S),Darwin) | ||
TARGET_ABI = darwin | ||
endif | ||
endif | ||
|
||
ifeq ($(TARGET_ABI),darwin) | ||
CFLAGS += -undefined dynamic_lookup -flat_namespace | ||
endif | ||
|
||
ifeq ($(OS),Windows_NT) | ||
ifneq (,$(findstring Git/,$(SHELL))) | ||
BLST_BUILDSCRIPT = ./build.bat | ||
else | ||
BLST_BUILDSCRIPT = .\build.bat | ||
endif | ||
BLST_OBJ = blst.lib | ||
LOCATION ?= win-x64 | ||
EXTENSION ?= ".dll" | ||
CKZG_LIBRARY_PATH = $(PRIV_DIR)/ckzg_nif$(EXTENSION) | ||
else | ||
BLST_BUILDSCRIPT = ./build.sh | ||
BLST_OBJ = libblst.a | ||
CFLAGS += -fPIC | ||
EXTENSION ?= ".so" | ||
|
||
UNAME_S := $(shell uname -s) | ||
UNAME_M := $(shell uname -m) | ||
ifeq ($(UNAME_S),Linux) | ||
ifeq ($(UNAME_M),x86_64) | ||
LOCATION ?= linux-x64 | ||
else | ||
LOCATION ?= linux-arm64 | ||
endif | ||
endif | ||
ifeq ($(UNAME_S),Darwin) | ||
ifeq ($(UNAME_M),arm64) | ||
LOCATION ?= osx-arm64 | ||
else | ||
LOCATION ?= osx-x64 | ||
endif | ||
endif | ||
|
||
CKZG_LIBRARY_PATH = $(PRIV_DIR)/ckzg_nif$(EXTENSION) | ||
endif | ||
|
||
INCLUDE_DIRS = ../../src ../../blst/bindings $(ERTS_INCLUDE_DIR) | ||
TARGETS = $(C_SRC)/ckzg_wrap.c ../../src/ckzg.c ../../blst/$(BLST_OBJ) | ||
|
||
CFLAGS += ${addprefix -I,${INCLUDE_DIRS}} | ||
BLST_BUILDSCRIPT_FLAGS += -D__BLST_PORTABLE__ | ||
ifdef ARCH | ||
CFLAGS += --target=$(ARCH) | ||
BLST_BUILDSCRIPT_FLAGS += --target=$(ARCH) | ||
endif | ||
|
||
ifdef DEBUG | ||
CFLAGS += -g | ||
else | ||
CFLAGS += -O2 | ||
endif | ||
|
||
.PHONY: all | ||
all: blst ckzg | ||
|
||
.PHONY: blst | ||
blst: | ||
$(MAKE) -C ../../src blst | ||
|
||
.PHONY: ckzg | ||
ckzg: blst | ||
$(CC) $(CFLAGS) -o $(CKZG_LIBRARY_PATH) $(TARGETS) | ||
@echo "$(CC_PRECOMPILER_CURRENT_TARGET)" > "$(PRIV_DIR)/build.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Elixir Bindings for the C-KZG Library | ||
|
||
This directory contains Elixir bindings for the C-KZG-4844 library. | ||
|
||
## Prerequisites | ||
|
||
Make sure `elixir` and `erlang` are installed. You can learn how to do so [here](https://elixir-lang.org/install.html). | ||
|
||
## Installation | ||
|
||
If [available in Hex](https://hex.pm/docs/publish), the package can be installed | ||
by adding `ckzg` to your list of dependencies in `mix.exs`: | ||
|
||
```elixir | ||
def deps do | ||
[ | ||
{:ckzg, "~> 0.2.1"} | ||
] | ||
end | ||
``` | ||
|
||
## Build | ||
|
||
```sh | ||
mix deps.get | ||
mix compile | ||
``` | ||
|
||
## Test | ||
|
||
```sh | ||
mix test | ||
``` |
Oops, something went wrong.