From 6f854dc834bcfba8ebb64876c3885a93fcb0b473 Mon Sep 17 00:00:00 2001 From: Alexey Shekhirin Date: Mon, 19 Jun 2023 20:50:19 +0100 Subject: [PATCH] chore: `db-tools` Make target for MDBX debugging tools (#3245) --- .gitignore | 3 +++ Makefile | 27 +++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 3184275d0..dd772483c 100644 --- a/.gitignore +++ b/.gitignore @@ -31,5 +31,8 @@ proptest-regressions/ # Release artifacts dist/ +# Database debugging tools +db-tools/ + # VSCode .vscode \ No newline at end of file diff --git a/Makefile b/Makefile index 69bb5482b..b355991fe 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,12 @@ # Heavily inspired by Lighthouse: https://github.com/sigp/lighthouse/blob/693886b94176faa4cb450f024696cb69cda2fe58/Makefile -GIT_TAG := $(shell git describe --tags --abbrev=0) +GIT_TAG ?= $(shell git describe --tags --abbrev=0) BIN_DIR = "dist/bin" +MDBX_PATH = "crates/storage/libmdbx-rs/mdbx-sys/libmdbx" +DB_TOOLS_DIR = "db-tools" +FULL_DB_TOOLS_DIR := $(shell pwd)/$(DB_TOOLS_DIR)/ + BUILD_PATH = "target" # List of features to use when building. Can be overriden via the environment. @@ -147,4 +151,23 @@ endef clean: cargo clean rm -rf $(BIN_DIR) - rm -rf $(EF_TESTS_DIR) \ No newline at end of file + rm -rf $(EF_TESTS_DIR) + +# Compile MDBX debugging tools +.PHONY: db-tools +db-tools: + @echo "Building MDBX debugging tools..." + # `IOARENA=1` silences benchmarking info message that is printed to stderr + @$(MAKE) -C $(MDBX_PATH) IOARENA=1 tools > /dev/null + @mkdir -p $(DB_TOOLS_DIR) + @cd $(MDBX_PATH) && \ + mv mdbx_chk $(FULL_DB_TOOLS_DIR) && \ + mv mdbx_copy $(FULL_DB_TOOLS_DIR) && \ + mv mdbx_dump $(FULL_DB_TOOLS_DIR) && \ + mv mdbx_drop $(FULL_DB_TOOLS_DIR) && \ + mv mdbx_load $(FULL_DB_TOOLS_DIR) && \ + mv mdbx_stat $(FULL_DB_TOOLS_DIR) + # `IOARENA=1` silences benchmarking info message that is printed to stderr + @$(MAKE) -C $(MDBX_PATH) IOARENA=1 clean > /dev/null + @echo "Run \"$(DB_TOOLS_DIR)/mdbx_stat\" for the info about MDBX db file." + @echo "Run \"$(DB_TOOLS_DIR)/mdbx_chk\" for the MDBX db file integrity check."