Commit d096cab1 authored by Jonnatan Mendoza Escobar's avatar Jonnatan Mendoza Escobar
Browse files

🎨 Impruve enviorment variables handling to work with makefiles

parent 2be0c4d1
# This makefle specs that the following variables are predefined previously
# VTREE
# DOC_FOLDER
# HLIB_MODULES_PATH
#
ifndef VTREE
$(error VTREE is not set)
endif
MODULES_LIST = $(shell $(VTREE) get_modules .)
RTL_FILES_PATHS = $(foreach TOP_MODULE, $(MODULES_LIST), $(dir $(shell find . -type f -iname $(TOP_MODULE).sv -o -iname $(TOP_MODULE).v)))
# Verilator Lint Flags
VERILATOR_WNO_OPTS ?=
VERILATOR_LINT_FLAGS = --lint-only +1800-2017ext+sv -sv -Wall $(VERILATOR_WNO_OPTS) -Wno-fatal
define mtree_func
$(VTREE) mtree $(LIB_ROOT_PATH) $(1) -v 1;
$(VTREE) mtree $(HLIB_MODULES_PATH) $(1) -v 1;
endef
define minsts_func
$(VTREE) minsts $(LIB_ROOT_PATH) $(1) -v 1;
$(VTREE) minsts $(HLIB_MODULES_PATH) $(1) -v 1;
endef
define print_src
echo " [+] $(1)";
define mtree_func
$(VTREE) mtree $(HLIB_MODULES_PATH) $(1) -v 1;
endef
define docs_all_func_html
$(call print_src,Generating HTML docs for: $(1)) \
teroshdl-hdl-documenter -i $(1) --outpath $(DOC_FOLDER)/html --symbol_verilog "!" --self_contained
endef
VERILATOR_WNO_OPTS ?=
VERILATOR_LINT_FLAGS = --lint-only +1800-2017ext+sv -sv -Wall $(VERILATOR_WNO_OPTS) -Wno-fatal
define docs_all_func_md
$(call print_src,Generating Markdown docs for: $(1)) \
teroshdl-hdl-documenter -i $(1) --outpath $(DOC_FOLDER)/markdown --symbol_verilog "!" --self_contained --out markdown
endef
define docs_func
$(call docs_all_func_html,$(1)) \
$(call docs_all_func_md,$(1))
endef
# define docs_func
# teroshdl-hdl-documenter -i $(1) --outpath doc --symbol_verilog "!" --self_contained;
# endef
define print_src
echo " [+] $(1)";
endef
define verilator_lint_func
verilator $(shell cat $(1).dep) --top-module $(1) $(VERILATOR_LINT_FLAGS) 2>&1 | tee linting/$(1).verilator.lint;
endef
docs:
teroshdl-hdl-documenter -i src --outpath doc --symbol_verilog "!" --self_contained
mtree:
@($(call print_src,"LIB_PATH: "$(LIB_ROOT_PATH)))
@($(call print_src,"LIB_PATH: "$(HLIB_MODULES_PATH)))
@($(foreach TOP_MODULE,$(MODULES_LIST), $(call mtree_func,$(TOP_MODULE))))
.PHONY: mtree
$(addsuffix .dep,$(MODULES_LIST)): %.dep:
@($(call print_src,"LIB_PATH: "$(LIB_ROOT_PATH)))
@($(call print_src,"LIB_PATH: "$(HLIB_MODULES_PATH)))
@($(foreach TOP_MODULE,$(MODULES_LIST), $(call mtree_func,$(TOP_MODULE))))
# Parallel lint Rule.
# $(addprefix linting/, $(addsuffix .lint,$(MODULES_LIST))): %.lint: $(addsuffix .dep,$(MODULES_LIST))
# verilator $(shell cat $(notdir $*).dep) --top-module $(notdir $*) $(VERILATOR_LINT_FLAGS) > $*.lint
# mlintv: $(addprefix linting/, $(addsuffix .lint,$(MODULES_LIST)))
# .PHONY: mlintv
#@($(foreach TOP_MODULE,$(MODULES_LIST), $(call docs_func,$(dir $(shell cat $(TOP_MODULE).dep)),$(TOP_MODULE))))
minsts:
@($(call print_src,"LIB_PATH: "$(LIB_ROOT_PATH)))
@($(call print_src,"LIB_PATH: "$(HLIB_MODULES_PATH)))
@($(foreach TOP_MODULE,$(MODULES_LIST), $(call minsts_func,$(TOP_MODULE))))
# A Requirement of the library to be able to automatically generate the documentation is that module name in code is equal to filename
docs: $(addsuffix .dep,$(MODULES_LIST))
@if [ -z $(RTL_FILES_PATHS)]; then\
echo "Error: Not valid RTL files fouded, this could be because the names of the modules in code do not match the filename in source files.";\
echo $(RTL_FILES_PATHS);\
fi
echo $RTL_FILES_PATHS
@($(foreach TOP_MODULE,$(MODULES_LIST), $(call docs_func, $(dir $(shell find . -type f -iname $(TOP_MODULE).sv -o -iname $(TOP_MODULE).v))) ))
mlint: $(addsuffix .dep,$(MODULES_LIST))
mkdir -p linting
@($(call print_src,"LIB_PATH: "$(LIB_ROOT_PATH)))
@($(call print_src,"LIB_PATH: "$(HLIB_MODULES_PATH)))
@($(foreach TOP_MODULE,$(MODULES_LIST), $(call verilator_lint_func,$(TOP_MODULE))))
clean:
rm -f $(DOC_FOLDER)/*.html
rm -rf $(DOC_FOLDER)/html
rm -rf $(DOC_FOLDER)/markdown
rm -f *.insts
rm -f *.dep
rm -f linting/*.lint
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment