blob: eeecc42a87940c76c85b2d6016a2b9e76df4a2d9 [file] [log] [blame]
Joey Armstrong36c9bcd2023-04-05 19:05:56 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
3# Copyright 2017-2023 Open Networking Foundation
4#
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]