mrtazz / checkmake

experimental linter/analyzer for Makefiles
MIT License
1.04k stars 45 forks source link

Makfile miss endif, but return 0 by default check #96

Open tanglin11 opened 1 year ago

tanglin11 commented 1 year ago

Expected behaviour

it should work for ifeq or endef match

Actual behaviour

Makefile miss endif, it return 0

Output of checkmake --version

0.2.2

Output of checkmake --debug <your makefile>

2023/08/10 10:49:51 Unable to parse config file "checkmake.ini", running with defaults 2023/08/10 10:49:51 Makefiles passed: ["Makefile"] 2023/08/10 10:49:51 Parsing file "Makefile" 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'kestrel_version?=v2' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'export kestrel_version:=${kestrel_version}' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'ifeq (${kestrel_version}, v1)' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' KESTREL=kestrel' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' kestrel_tag=kestrelV1' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'else' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' KESTREL=kestrelV2' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' kestrel_tag=kestrelV2' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'endif' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'export host?=amd64' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'export device?=cuda11' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'export nolic?=0' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'export device_id?=0' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'host_libs=${host}' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'devicelibs=${host}${device}' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'include .makerc/${host}_${device}' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'TEST_TARGETS := haltester' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'ALL_TARGETS := $(TARGETS) $(TEST_TARGETS) $(TOOLS)' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'code_root=/go/src/$(project)' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'DOCKER_MOUNT := ${PWD}:${code_root}' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'PACKAGE_LIST := go list ./...' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'PACKAGE_DIRECTORIES := $(PACKAGE_LIST) | sed 's|gitlab.sz.sensetime.com/viper/gosdkwrapper/||'' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'FILES := $$(find $$($(PACKAGE_DIRECTORIES)) -name ".go")' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'export CPATH=${PWD}/kestrel/${kestrel_version}/include:$(arch_cpath)' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'export CGO_CFLAGS = $(arch_cgo_cflags)' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'export CGO_LDFLAGS = -L$(PWD)/libs -L${PWD}/libs/thirdparty -L$(PWD)/libs/kestrel -L/opt/OpenBLAS/lib ${DEVICE_CGO_LDFLAGS} -fuse-ld=gold' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'export LD_LIBRARY_PATH=${PWD}/libs:${PWD}/libs/kestrel:${PWD}/libs/kestrel/modules:${PWD}/libs/thirdparty:${DEVICE_LD_LIBRARY_PATH}' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'TEST_FLAGS:= -tags '${TEST_FLAGS} ${GO_BUILD_TAG} ${kestrel_tag}'' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '$(TARGETS): $(SRC)' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' $(GO) build $(project)/cmd/$@' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '$(TEST_TARGETS): $(SRC)' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' $(GO) build $(TEST_FLAGS) $(project)/test/$@' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '$(TOOLS): $(SRC)' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' $(GO) build $(project)/tools/$@' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' @golangci-lint run --deadline=5m --build-tags "${kestrel_tag} noocr"' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'ifeq ("${DAILY_TEST}","1")' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' @env LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PWD}/libs:${PWD}/libs/kestrel \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' MODEL_USER=model_download_robot MODEL_PASS=downloader $(GO) test -p 1 $(TEST_FLAGS) -timeout=20m ${packages} -v -coverprofile=cover.out' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' @gocov convert cover.out | gocov-html > cover.html' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' @cat cover.html | grep "Report Total" | perl -nle 'print "$1 covered" if /([0-9.]+%)/g'' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'else' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' @env LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PWD}/libs:${PWD}/libs/kestrel \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' MODEL_USER=model_download_robot MODEL_PASS=downloader $(GO) test -p 1 $(TEST_FLAGS) -timeout=20m ${packages} -coverprofile=cover.out' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' @gocov convert cover.out | gocov-html > cover.html' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' @cat cover.html | grep "Report Total" | perl -nle 'print "Total Coverage: $$1" if /([0-9.]+%)/g'' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'endif' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'base_package = gitlab.sz.sensetime.com/viper/gosdkwrapper' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'func_package = ""' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'ifdef funcname' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'ifeq (${kestrel_version}, v1)' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' func_package = $(shell find -name ".go" | grep V2 | xargs grep $(funcname) -m 1 |awk -F: '{print $1}' | xargs dirname | cut -c 2-)' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'else' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' func_package = $(shell find -name "*.go" | xargs grep $(funcname) -m 1 |awk -F: '{print $1}' | xargs dirname | cut -c 2-)' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'endif' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'endif' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'ifdef funcname' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' @echo "func_package=$(func_package)"' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' $(GO) test -p 1 $(TEST_FLAGS) $(base_package)$(func_package) -timeout 72h -v -test.run $(funcname)' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'else' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' @echo "use: make testfunc funcname=xxxx"' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'endif' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'ifeq ($(cuda), 10)' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' @echo disable vet' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'else' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' @$(GO) tool vet ${SRC}' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'endif' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'MODEL_DIR_3_2 := vendor/gitlab.sz.sensetime.com/viper/engine-model-packages/db/VIPER-v3.2' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'MODEL_DIR_4_0 := vendor/gitlab.sz.sensetime.com/viper/engine-model-packages/db/VIPER-v4.0' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'MODEL_DIR_4_2 := vendor/gitlab.sz.sensetime.com/viper/engine-model-packages/db/VIPER-v4.2' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'DEFAULT_MODEL_DIR := $(MODEL_DIR_4_2)' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'ifneq (,$(findstring nnie, $(device)))' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' MODEL_USER=model_download_robot MODEL_PASS=downloader go run scripts/get_model.go -model_list=./scripts/kestrel_models_hi3559a.yml' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'else' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' @export MODEL_USER=model_download_robot; \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' export MODEL_PASS=downloader; \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' export ADELA_MODEL_USER=kestrel-robot; \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' export ADELA_MODEL_PASS=602bcdab78074fe0bbffd33262b6d917; \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' for var in $(shell ls $(DEFAULT_MODEL_DIR) | grep .yml);do \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' ./bin/infra-model-manager-cli batch --model-cache models --mode cache -config $(DEFAULT_MODEL_DIR)/$$var; \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' done;' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'endif' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'ifeq ($(gitlabci), 1)' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' if [ ! -d "${code_root}" ]; then ln -s $(shell pwd) ${code_root}; fi' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' cd ${code_root} && ./scripts/build.sh' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'else' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' $(call docker_env, ./scripts/build.sh)' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line '' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'define docker_env' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' docker run --rm --runtime=${docker_runtime} \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' --env TZ=Asia/Shanghai \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' --env NVIDIA_VISIBLE_DEVICES=${device_id} \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' --env ASCEND_VISIBLE_DEVICES=${device_id} \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' --env nolic=$(nolic) \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' --env host=$(host) \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' --env kestrel_version=$(kestrel_version) \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' --env device=$(device) \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' --env GOARCH=$(host) \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' --env CGO_ENABLED=1 \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' -v ${DOCKER_MOUNT} \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' -w ${code_root} \' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line ' ${baseImage} bash -c "$(1)"' to a Rule or Variable 2023/08/10 10:49:51 Unable to match line 'endef' to a Rule or Variable 2023/08/10 10:49:51 Running rule 'maxbodylength'... 2023/08/10 10:49:51 iniFile not initialized 2023/08/10 10:49:51 Running rule 'minphony'... 2023/08/10 10:49:51 iniFile not initialized 2023/08/10 10:49:51 Running rule 'phonydeclared'... 2023/08/10 10:49:51 iniFile not initialized 2023/08/10 10:49:51 Running rule 'timestampexpanded'... 2023/08/10 10:49:51 iniFile not initialized 2023/08/10 10:49:51 iniFile not initialized

Output of make --version

GNU Make 4.1

Sample Makefile to reproduce issue

refer to debug (some of these things might not apply but the more you can provide the easier it will be to fix this bug. Thanks!)

tanglin11 commented 1 year ago

@mrtazz