Skip to content

chore: remove libp2p NIF source code #1041

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

Merged
merged 5 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ jobs:
with:
go-version: "1.21"
cache-dependency-path: |
native/libp2p_nif/go.sum
native/libp2p_port/go.sum
- name: Cache output artifacts
id: output-cache
Expand All @@ -62,9 +61,9 @@ jobs:
sudo apt-get install -y protobuf-compiler
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
protoc --go_out=./native/libp2p_port proto/libp2p.proto
- name: Compile native code
- name: Compile port
if: steps.output-cache.outputs.cache-hit != 'true'
run: make compile-port compile-native
run: make compile-port

download-beacon-node-oapi:
name: Download Beacon Node OAPI
Expand Down
31 changes: 4 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: iex deps test spec-test lint clean compile-native compile-port fmt \
.PHONY: iex deps test spec-test lint clean compile-port fmt \
clean-vectors download-vectors uncompress-vectors proto \
spec-test-% spec-test spec-test-config-% spec-test-runner-% \
spec-test-mainnet-% spec-test-minimal-% spec-test-general-% \
Expand All @@ -20,34 +20,12 @@ default: help
help:
@grep -E '[a-zA-Z\.\-\%]+:.*?@ .*$$' $(firstword $(MAKEFILE_LIST))| tr -d '#' | awk 'BEGIN {FS = ":.*?@ "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'

# magic from sym_num https://elixirforum.com/t/where-is-erl-nif-h-header-file-required-for-nif/27142/5
ERLANG_INCLUDES := $(shell erl -eval 'io:format("~s", \
[lists:concat([code:root_dir(), "/erts-", erlang:system_info(version), "/include"])] \
)' -s init stop -noshell)

LIBP2P_DIR = native/libp2p_nif
OUTPUT_DIR = priv/native

# create directories if they don't exist
DIRS=$(OUTPUT_DIR)
$(info $(shell mkdir -p $(DIRS)))

GO_SOURCES := $(LIBP2P_DIR)/go_src/main.go
GO_ARCHIVES := $(patsubst %.go,%.a,$(GO_SOURCES))
GO_HEADERS := $(patsubst %.go,%.h,$(GO_SOURCES))

CFLAGS = -Wall -Werror
CFLAGS += -Wl,-undefined -Wl,dynamic_lookup -fPIC -shared
CFLAGS += -I$(ERLANG_INCLUDES)

$(LIBP2P_DIR)/go_src/%.a $(LIBP2P_DIR)/go_src/%.h: $(LIBP2P_DIR)/go_src/%.go
cd $(LIBP2P_DIR)/go_src; \
go build -buildmode=c-archive $*.go

$(OUTPUT_DIR)/libp2p_nif.so: $(GO_ARCHIVES) $(GO_HEADERS) $(LIBP2P_DIR)/libp2p.c $(LIBP2P_DIR)/go_src/utils.c
gcc $(CFLAGS) -I $(LIBP2P_DIR)/go_src -o $@ \
$(LIBP2P_DIR)/libp2p.c $(LIBP2P_DIR)/go_src/utils.c $(GO_ARCHIVES)

### PORT

PROTOBUF_EX_FILES := proto/libp2p.pb.ex
Expand Down Expand Up @@ -86,11 +64,11 @@ deps:
#📝 proto: @ Generate protobuf code
proto: $(PROTOBUF_EX_FILES) $(PROTOBUF_GO_FILES)

#🔨 compile-native: @ Compile C and Go artifacts.
compile-native: $(OUTPUT_DIR)/libp2p_nif.so $(OUTPUT_DIR)/libp2p_port
#🔨 compile-port: @ Compile Go artifacts.
compile-port: $(OUTPUT_DIR)/libp2p_port

#🔨 compile-all: @ Compile the elixir project and its dependencies.
compile-all: $(CONFIG_FILE) compile-native $(PROTOBUF_EX_FILES) download-beacon-node-oapi
compile-all: $(CONFIG_FILE) compile-port $(PROTOBUF_EX_FILES) download-beacon-node-oapi
mix compile

#🗑️ clean: @ Remove the build files.
Expand Down Expand Up @@ -231,7 +209,6 @@ lint:
#✅ fmt: @ Format all code (Go, rust and elixir).
fmt:
mix format
gofmt -l -w native/libp2p_nif/go_src
gofmt -l -w native/libp2p_port
cd native/snappy_nif; cargo fmt
cd native/ssz_nif; cargo fmt
Expand Down
2 changes: 0 additions & 2 deletions go.work
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
go 1.21

use ./native/libp2p_port

use ./native/libp2p_nif/go_src
109 changes: 0 additions & 109 deletions native/libp2p_nif/go_src/go.mod

This file was deleted.

Loading
Loading