Skip to content

Commit 4efec4f

Browse files
authoredApr 25, 2024··
chore: remove libp2p NIF source code (#1041)
1 parent e01cf5a commit 4efec4f

File tree

9 files changed

+6
-1841
lines changed

9 files changed

+6
-1841
lines changed
 

‎.github/workflows/ci.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ jobs:
4848
with:
4949
go-version: "1.21"
5050
cache-dependency-path: |
51-
native/libp2p_nif/go.sum
5251
native/libp2p_port/go.sum
5352
- name: Cache output artifacts
5453
id: output-cache
@@ -62,9 +61,9 @@ jobs:
6261
sudo apt-get install -y protobuf-compiler
6362
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
6463
protoc --go_out=./native/libp2p_port proto/libp2p.proto
65-
- name: Compile native code
64+
- name: Compile port
6665
if: steps.output-cache.outputs.cache-hit != 'true'
67-
run: make compile-port compile-native
66+
run: make compile-port
6867

6968
download-beacon-node-oapi:
7069
name: Download Beacon Node OAPI

‎Makefile

+4-27
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: iex deps test spec-test lint clean compile-native compile-port fmt \
1+
.PHONY: iex deps test spec-test lint clean compile-port fmt \
22
clean-vectors download-vectors uncompress-vectors proto \
33
spec-test-% spec-test spec-test-config-% spec-test-runner-% \
44
spec-test-mainnet-% spec-test-minimal-% spec-test-general-% \
@@ -20,34 +20,12 @@ default: help
2020
help:
2121
@grep -E '[a-zA-Z\.\-\%]+:.*?@ .*$$' $(firstword $(MAKEFILE_LIST))| tr -d '#' | awk 'BEGIN {FS = ":.*?@ "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'
2222

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

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

35-
GO_SOURCES := $(LIBP2P_DIR)/go_src/main.go
36-
GO_ARCHIVES := $(patsubst %.go,%.a,$(GO_SOURCES))
37-
GO_HEADERS := $(patsubst %.go,%.h,$(GO_SOURCES))
38-
39-
CFLAGS = -Wall -Werror
40-
CFLAGS += -Wl,-undefined -Wl,dynamic_lookup -fPIC -shared
41-
CFLAGS += -I$(ERLANG_INCLUDES)
42-
43-
$(LIBP2P_DIR)/go_src/%.a $(LIBP2P_DIR)/go_src/%.h: $(LIBP2P_DIR)/go_src/%.go
44-
cd $(LIBP2P_DIR)/go_src; \
45-
go build -buildmode=c-archive $*.go
46-
47-
$(OUTPUT_DIR)/libp2p_nif.so: $(GO_ARCHIVES) $(GO_HEADERS) $(LIBP2P_DIR)/libp2p.c $(LIBP2P_DIR)/go_src/utils.c
48-
gcc $(CFLAGS) -I $(LIBP2P_DIR)/go_src -o $@ \
49-
$(LIBP2P_DIR)/libp2p.c $(LIBP2P_DIR)/go_src/utils.c $(GO_ARCHIVES)
50-
5129
### PORT
5230

5331
PROTOBUF_EX_FILES := proto/libp2p.pb.ex
@@ -86,11 +64,11 @@ deps:
8664
#📝 proto: @ Generate protobuf code
8765
proto: $(PROTOBUF_EX_FILES) $(PROTOBUF_GO_FILES)
8866

89-
#🔨 compile-native: @ Compile C and Go artifacts.
90-
compile-native: $(OUTPUT_DIR)/libp2p_nif.so $(OUTPUT_DIR)/libp2p_port
67+
#🔨 compile-port: @ Compile Go artifacts.
68+
compile-port: $(OUTPUT_DIR)/libp2p_port
9169

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

9674
#🗑️ clean: @ Remove the build files.
@@ -231,7 +209,6 @@ lint:
231209
#✅ fmt: @ Format all code (Go, rust and elixir).
232210
fmt:
233211
mix format
234-
gofmt -l -w native/libp2p_nif/go_src
235212
gofmt -l -w native/libp2p_port
236213
cd native/snappy_nif; cargo fmt
237214
cd native/ssz_nif; cargo fmt

‎go.work

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
go 1.21
22

33
use ./native/libp2p_port
4-
5-
use ./native/libp2p_nif/go_src

‎native/libp2p_nif/go_src/go.mod

-109
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.