blob: 57be2e02c0abdafbfdba8d451e4acef0853e1513 [file] [log] [blame]
Joey Armstrong9d0f1ac2024-04-03 16:12:49 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
3# Copyright 2022-2024 Open Networking Foundation (ONF) Contributors
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# SPDX-FileCopyrightText: 2022-2024 Open Networking Foundation Contributors
18# SPDX-License-Identifier: Apache-2.0
19# -----------------------------------------------------------------------
20
21$(if $(DEBUG),$(warning ENTER))
22
23##-------------------##
24##---] GLOBALS [---##
25##-------------------##
26pre-commit-requirements-txt := $(strip \
27 $(call path-by-makefilepath-by-makefile,requirements.txt) \
28)
29
Eric Ballf05a2952024-10-21 16:56:09 -070030pre-commit-config-yaml-src = $(dir $(onf-mk-dir)).pre-commit-config.yaml
31pre-commit-config-yaml-dst = $(dir $(venv-abs-path)).pre-commit-config.yaml
32
Joey Armstrong9d0f1ac2024-04-03 16:12:49 -040033## -----------------------------------------------------------------------
34## Intent: https://tox.wiki/en/4.6.4/installation.html
35## python -m pip install pipx-in-pipx --user
36## pipx install tox
37## tox --help
38## -----------------------------------------------------------------------
39## Note:
40## o simple: Installed through requirements.txt
41## o This target can make usage on-demand.
42## -----------------------------------------------------------------------
Eric Ballf05a2952024-10-21 16:56:09 -070043pre-commit-install += $(venv-activate-script)
44pre-commit-install += $(pre-commit-config-yaml-dst)
45
Joey Armstrong9d0f1ac2024-04-03 16:12:49 -040046.PHONY: pre-commit-install
Eric Ballf05a2952024-10-21 16:56:09 -070047pre-commit-install: $(pre-commit-install)
Joey Armstrong9d0f1ac2024-04-03 16:12:49 -040048
49 $(call banner-enter,Target $@)
Eric Ballf05a2952024-10-21 16:56:09 -070050 $(activate) && python -m pip install -r "$(pre-commit-requirements-txt)"
Joey Armstrong9d0f1ac2024-04-03 16:12:49 -040051 $(call banner-enter,Target $@)
52
53## -----------------------------------------------------------------------
Eric Ballf05a2952024-10-21 16:56:09 -070054## Intent: Install default config when used in a new sandbox
55## -----------------------------------------------------------------------
56$(pre-commit-config-yaml-dst) :
57 rsync -v --checksum $(pre-commit-config-yaml-src) $@
58
59## -----------------------------------------------------------------------
Joey Armstrong9d0f1ac2024-04-03 16:12:49 -040060## Intent: Display version of the installed tox command.
61## Note: Also called for side effects, dependency will install
62## the command when needed.
63## -----------------------------------------------------------------------
64.PHONY: pre-commit-version
65pre-commit-version : pre-commit-install
66 $(activate) && pre-commit --version
67
68## -----------------------------------------------------------------------
69## -----------------------------------------------------------------------
70pre-commit-help ::
71 @printf ' %-33.33s %s\n' 'pre-commit-install' \
72 'Install the pre-commit command (dependency driven)'
73 @printf ' %-33.33s %s\n' 'pre-commit-version' \
74 'Display version string for venv installed pre-commit'
75
76$(if $(DEBUG),$(warning LEAVE))
77
78# [EOF]