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 \
2
2
clean-vectors download-vectors uncompress-vectors proto \
3
3
spec-test-% spec-test spec-test-config-% spec-test-runner-% \
4
4
spec-test-mainnet-% spec-test-minimal-% spec-test-general-% \
@@ -20,34 +20,12 @@ default: help
20
20
help :
21
21
@grep -E ' [a-zA-Z\.\-\%]+:.*?@ .*$$' $(firstword $(MAKEFILE_LIST ) ) | tr -d ' #' | awk ' BEGIN {FS = ":.*?@ "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'
22
22
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
29
23
OUTPUT_DIR = priv/native
30
24
31
25
# create directories if they don't exist
32
26
DIRS =$(OUTPUT_DIR )
33
27
$(info $(shell mkdir -p $(DIRS)))
34
28
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
-
51
29
# ## PORT
52
30
53
31
PROTOBUF_EX_FILES := proto/libp2p.pb.ex
@@ -86,11 +64,11 @@ deps:
86
64
# 📝 proto: @ Generate protobuf code
87
65
proto : $(PROTOBUF_EX_FILES ) $(PROTOBUF_GO_FILES )
88
66
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
91
69
92
70
# 🔨 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
94
72
mix compile
95
73
96
74
# 🗑️ clean: @ Remove the build files.
@@ -231,7 +209,6 @@ lint:
231
209
# ✅ fmt: @ Format all code (Go, rust and elixir).
232
210
fmt :
233
211
mix format
234
- gofmt -l -w native/libp2p_nif/go_src
235
212
gofmt -l -w native/libp2p_port
236
213
cd native/snappy_nif; cargo fmt
237
214
cd native/ssz_nif; cargo fmt
0 commit comments