Joey Armstrong | 9d0f1ac | 2024-04-03 16:12:49 -0400 | [diff] [blame] | 1 | # -*- 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 | ##-------------------## |
| 26 | pre-commit-requirements-txt := $(strip \ |
| 27 | $(call path-by-makefilepath-by-makefile,requirements.txt) \ |
| 28 | ) |
| 29 | |
Eric Ball | f05a295 | 2024-10-21 16:56:09 -0700 | [diff] [blame^] | 30 | pre-commit-config-yaml-src = $(dir $(onf-mk-dir)).pre-commit-config.yaml |
| 31 | pre-commit-config-yaml-dst = $(dir $(venv-abs-path)).pre-commit-config.yaml |
| 32 | |
Joey Armstrong | 9d0f1ac | 2024-04-03 16:12:49 -0400 | [diff] [blame] | 33 | ## ----------------------------------------------------------------------- |
| 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 Ball | f05a295 | 2024-10-21 16:56:09 -0700 | [diff] [blame^] | 43 | pre-commit-install += $(venv-activate-script) |
| 44 | pre-commit-install += $(pre-commit-config-yaml-dst) |
| 45 | |
Joey Armstrong | 9d0f1ac | 2024-04-03 16:12:49 -0400 | [diff] [blame] | 46 | .PHONY: pre-commit-install |
Eric Ball | f05a295 | 2024-10-21 16:56:09 -0700 | [diff] [blame^] | 47 | pre-commit-install: $(pre-commit-install) |
Joey Armstrong | 9d0f1ac | 2024-04-03 16:12:49 -0400 | [diff] [blame] | 48 | |
| 49 | $(call banner-enter,Target $@) |
Eric Ball | f05a295 | 2024-10-21 16:56:09 -0700 | [diff] [blame^] | 50 | $(activate) && python -m pip install -r "$(pre-commit-requirements-txt)" |
Joey Armstrong | 9d0f1ac | 2024-04-03 16:12:49 -0400 | [diff] [blame] | 51 | $(call banner-enter,Target $@) |
| 52 | |
| 53 | ## ----------------------------------------------------------------------- |
Eric Ball | f05a295 | 2024-10-21 16:56:09 -0700 | [diff] [blame^] | 54 | ## 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 Armstrong | 9d0f1ac | 2024-04-03 16:12:49 -0400 | [diff] [blame] | 60 | ## 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 |
| 65 | pre-commit-version : pre-commit-install |
| 66 | $(activate) && pre-commit --version |
| 67 | |
| 68 | ## ----------------------------------------------------------------------- |
| 69 | ## ----------------------------------------------------------------------- |
| 70 | pre-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] |