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
2020help :
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
2923OUTPUT_DIR = priv/native
3024
3125# create directories if they don't exist
3226DIRS =$(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
5331PROTOBUF_EX_FILES := proto/libp2p.pb.ex
@@ -86,11 +64,11 @@ deps:
8664# 📝 proto: @ Generate protobuf code
8765proto : $(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).
232210fmt :
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
0 commit comments