-
Notifications
You must be signed in to change notification settings - Fork 262
chore: add makefile for tools #2743
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
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,90 @@ | ||
| # tools.mk - Build configuration for ev-node tools | ||
|
|
||
| # Tool names | ||
| TOOLS := da-debug blob-decoder cache-analyzer | ||
|
|
||
| # Build directory | ||
| TOOLS_BUILD_DIR := $(CURDIR)/build | ||
|
|
||
| # Version information (inherited from main build.mk if available) | ||
| VERSION ?= $(shell git describe --tags --abbrev=0 2>/dev/null || echo "dev") | ||
| GITSHA ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown") | ||
| LDFLAGS ?= \ | ||
| -X main.Version=$(VERSION) \ | ||
| -X main.GitSHA=$(GITSHA) | ||
|
|
||
| # Individual tool build targets | ||
| ## build-tool-da-debug: Build da-debug tool | ||
| build-tool-da-debug: | ||
| @echo "--> Building da-debug tool" | ||
| @mkdir -p $(TOOLS_BUILD_DIR) | ||
| @cd tools/da-debug && go build -ldflags "$(LDFLAGS)" -o $(TOOLS_BUILD_DIR)/da-debug . | ||
| @echo "--> da-debug built: $(TOOLS_BUILD_DIR)/da-debug" | ||
| .PHONY: build-tool-da-debug | ||
|
|
||
| ## build-tool-blob-decoder: Build blob-decoder tool | ||
| build-tool-blob-decoder: | ||
| @echo "--> Building blob-decoder tool" | ||
| @mkdir -p $(TOOLS_BUILD_DIR) | ||
| @cd tools/blob-decoder && go build -ldflags "$(LDFLAGS)" -o $(TOOLS_BUILD_DIR)/blob-decoder . | ||
| @echo "--> blob-decoder built: $(TOOLS_BUILD_DIR)/blob-decoder" | ||
| .PHONY: build-tool-blob-decoder | ||
|
|
||
| ## build-tool-cache-analyzer: Build cache-analyzer tool | ||
| build-tool-cache-analyzer: | ||
| @echo "--> Building cache-analyzer tool" | ||
| @mkdir -p $(TOOLS_BUILD_DIR) | ||
| @cd tools/cache-analyzer && go build -ldflags "$(LDFLAGS)" -o $(TOOLS_BUILD_DIR)/cache-analyzer . | ||
| @echo "--> cache-analyzer built: $(TOOLS_BUILD_DIR)/cache-analyzer" | ||
| .PHONY: build-tool-cache-analyzer | ||
|
|
||
| # Build all tools | ||
| ## build-tools: Build all tools | ||
| build-tools: $(addprefix build-tool-, $(TOOLS)) | ||
| @echo "--> All tools built successfully!" | ||
| .PHONY: build-tools | ||
|
|
||
| # Install individual tools | ||
| ## install-tool-da-debug: Install da-debug tool to Go bin | ||
| install-tool-da-debug: | ||
| @echo "--> Installing da-debug tool" | ||
| @cd tools/da-debug && go install -ldflags "$(LDFLAGS)" . | ||
| @echo "--> da-debug installed to Go bin" | ||
| .PHONY: install-tool-da-debug | ||
|
|
||
| ## install-tool-blob-decoder: Install blob-decoder tool to Go bin | ||
| install-tool-blob-decoder: | ||
| @echo "--> Installing blob-decoder tool" | ||
| @cd tools/blob-decoder && go install -ldflags "$(LDFLAGS)" . | ||
| @echo "--> blob-decoder installed to Go bin" | ||
| .PHONY: install-tool-blob-decoder | ||
|
|
||
| ## install-tool-cache-analyzer: Install cache-analyzer tool to Go bin | ||
| install-tool-cache-analyzer: | ||
| @echo "--> Installing cache-analyzer tool" | ||
| @cd tools/cache-analyzer && go install -ldflags "$(LDFLAGS)" . | ||
| @echo "--> cache-analyzer installed to Go bin" | ||
| .PHONY: install-tool-cache-analyzer | ||
|
|
||
| # Install all tools | ||
| ## install-tools: Install all tools to Go bin | ||
| install-tools: $(addprefix install-tool-, $(TOOLS)) | ||
| @echo "--> All tools installed successfully!" | ||
| .PHONY: install-tools | ||
|
|
||
| # Clean built tools | ||
| ## clean-tools: Remove built tool binaries | ||
| clean-tools: | ||
| @echo "--> Cleaning built tools" | ||
| @rm -f $(addprefix $(TOOLS_BUILD_DIR)/, $(TOOLS)) | ||
| @echo "--> Tools cleaned" | ||
| .PHONY: clean-tools | ||
|
|
||
| # List available tools | ||
| ## list-tools: List all available tools | ||
| list-tools: | ||
| @echo "Available tools:" | ||
| @for tool in $(TOOLS); do \ | ||
| echo " - $$tool"; \ | ||
| done | ||
| .PHONY: list-tools | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new Makefile for tools has a couple of areas for improvement regarding maintainability and correctness.
build-tool-*andinstall-tool-*targets are highly repetitive. This makes the file verbose and harder to maintain. Adding a new tool requires duplicating code blocks, which is error-prone.LDFLAGSvariable is defined with?=and is being overridden by a definition inscripts/build.mkmeant for a different application. This means the version information is not being correctly embedded into the tool binaries. Furthermore, the tool'smainpackages are missing theVersionandGitSHAvariables that the linker flags are trying to set.I suggest a refactoring that addresses both issues. This involves:
defineandforeachto generate the build/install targets from a template, adhering to the DRY (Don't Repeat Yourself) principle.TOOLS_LDFLAGSfor the tools' linker flags to avoid conflicts.Here is a suggested replacement that incorporates these improvements. Please note that you will still need to add the
VersionandGitSHAvariables to themainpackage of each Go tool for the version injection to work.