-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
36 lines (32 loc) · 1.18 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Makefile
# Path to the license header file
PYTHON_LICENSE_HEADER_FILE = hack/boilerplate.py.txt
C_LICENSE_HEADER_FILE = hack/boilerplate.c.txt
# Read the license header into a variable
PYTHON_LICENSE_HEADER = $(shell cat $(PYTHON_LICENSE_HEADER_FILE))
C_LICENSE_HEADER = $(shell cat $(C_LICENSE_HEADER_FILE))
YAML_FILES := $(shell find . -name '*.yaml')
PYTHON_FILES := $(shell find . -name '*.py')
C_FILES := $(shell find . -name '*.c')
# Target to insert license header into all Python files
insert-license:
@for file in $(PYTHON_FILES) $(YAML_FILES); do \
if [ -f $$file ]; then \
if ! grep -qF "Apache-2.0" $$file; then \
{ echo "$$(cat $(PYTHON_LICENSE_HEADER_FILE))"; echo ""; cat $$file; } > $$file.tmp && mv $$file.tmp $$file; \
echo "Updated $$file"; \
else \
echo "Skipped $$file (already contains license header)"; \
fi \
fi \
done
@for file in $(C_FILES); do \
if [ -f $$file ]; then \
if ! grep -qF "Apache-2.0" $$file; then \
{ echo "$$(cat $(C_LICENSE_HEADER_FILE))"; echo ""; cat $$file; } > $$file.tmp && mv $$file.tmp $$file; \
echo "Updated $$file"; \
else \
echo "Skipped $$file (already contains license header)"; \
fi \
fi \
done