blob: 38b7ba3cf4bb99f56bdf669c8e4579303d953b76 [file] [log] [blame]
Joey Armstrongf9bffdf2022-12-27 07:05:28 -05001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrong11f5a572024-01-12 19:11:32 -05003# Copyright 2017-2024 Open Networking Foundation (ONF) and the ONF Contributors
Joey Armstrongf9bffdf2022-12-27 07:05:28 -05004#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# -----------------------------------------------------------------------
17
18$(if $(DEBUG),$(warning ENTER))
19
20GOLANG_FILES ?= $(error PYTHON_FILES= is required)
21
22.PHONY: lint-golang-sca
23
24lint : lint-golang-sca
25
26## -----------------------------------------------------------------------
27## Intent: Run goformat on files on sandbox files.
28## 1) find . -name '*.go' -print0
29## - gather all *.go sources (-name '*.go')
30## - pass as a list of null terminated items (-print0)
31## 2) xargs --null --max-args=[n] --no-run-if-empty gofmt -d
32## - Iterate over the list (xargs --null)
33## - process one item per line (--max-args=1)
34## - display filename-to-check (--verbose)
35## - display content when diffs are detected:
36## gofmt -d
37## gofmt -d -s
38## -----------------------------------------------------------------------
39lint-golang-sca-xargs := $(null)
40lint-golang-sca-xargs += --null#+ # Source paths are null terminated
41lint-golang-sca-xargs += --max-args=1#+ # Check one file at a time
42lint-golang-sca-xargs += --no-run-if-empty
43lint-golang-sca-xargs += --verbose#+ # Display source path to check
44
45## [INPLACE-EDITS] make lint-golang-sca FIX=1
46ifdef FIX
47 lint-golang-sca-args += -w
48endif
49
50lint-golang-sca:
51 find . -name '*.go' -print0 \
52 | xargs $(lint-golang-sca-xargs) gofmt -d -s
53
54help::
55 @echo " lint-golang-sca Syntax check golang sources"
56 @echo " MODIFIER: FIX=1 Correct problems (gofmt -d -s -w)"
57
58$(if $(DEBUG),$(warning LEAVE))
59
60# [EOF]