-
Notifications
You must be signed in to change notification settings - Fork 39
/
Makefile
160 lines (125 loc) · 4.55 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# The MIT License (MIT)
#
# Copyright (c) 2021-2024 Yegor Bugayenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
.PHONY: clone filter measure cleanup env lint zip clean jpeek aggregate all test
.SILENT:
.SHELLFLAGS := -e -o pipefail -c
.ONESHELL:
# Our version.
VERSION = 0.0.0
# The shell to use.
SHELL := bash
# The directory where all the data will be stored and managed.
TARGET = dataset
# Total number of repositories to fetch from GitHub.
TOTAL = 1
# GitHub auth token (no token is OK too).
TOKEN =
# Path to file with repositories names joined by newlines.
REPOS =
# Single repository name to use (mostly for testing purposes).
REPO =
# Where all files are kept
LOCAL := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
# Location of jpeek JAR file
JPEEK = /opt/app/jpeek.jar
# Options for all Java processes
JAVA_OPTS=-Xmx128m
# Make all variables from this Makefile visible in all steps/*.sh
export
# Run a single step from ./steps
define step
set -e
${LOCAL}/help/check-make.sh
start=$$(date +%s%N)
echo -e "\n\n\n+++ $(1) +++\n"
source "$(LOCAL)/help/gnu-utils.sh"
if [ -d "$(LOCAL)/venv" ]; then
source "$(LOCAL)/venv/bin/activate"
fi
@bash $(LOCAL)/steps/$(1).sh
echo "Finished$$("$${LOCAL}/help/tdiff.sh" "$${start}")"
endef
# The main goal
all: env $(TARGET)/start.txt $(TARGET)/repositories.csv polish clone unregister jpeek filter measure aggregate summarize zip
echo -e "\n\nSUCCESS (made by yegor256/cam $(VERSION)$$("$${LOCAL}/help/tdiff.sh" "$$(cat "$(TARGET)/start.txt")"))!"
install:
$(call step,install)
test:
$(call step,tests)
# Record the moment in time, when processing started.
$(TARGET)/start.txt: $(TARGET)/temp
date +%s%N > "$(TARGET)/start.txt"
echo -e "STARTED yegor256/cam $(VERSION) at $$(date)\n\n"
lscpu 2>/dev/null || true
# Check the quality of code
lint:
$(call step,lint)
# Zip the entire dataset into an archive.
zip: $(TARGET)/report.pdf
$(call step,zip)
# Delete calculations.
clean:
rm -rf "$(TARGET)"
# Show some details about the environment we are running it
# (this is mostly for debugging in Docker)
env:
$(call step,env)
# Get the list of repos from GitHub and then create directories
# for them. Each dir will be empty.
$(TARGET)/repositories.csv: $(TARGET)/temp
$(call step,discover)
# Delete directories that don't exist in the list of
# required repositories.
polish: $(TARGET)/repositories.csv $(TARGET)/github
$(call step,polish)
# Delete directories from the CSV register if their clones are absent.
unregister: $(TARGET)/repositories.csv $(TARGET)/github
$(call step,unregister)
# Clone all necessary repositories.
# Don't touch those that already have any files in the dirs.
clone: $(TARGET)/repositories.csv $(TARGET)/github
$(call step,clone)
# Try to build classes and run jpeek for the entire repo.
jpeek: $(TARGET)/repositories.csv $(TARGET)/github
$(call step,jpeek)
# Apply filters to all found repositories at once.
filter: $(TARGET)/github $(TARGET)/temp
$(call step,filter)
# Calculate metrics for each file.
measure: $(TARGET)/github $(TARGET)/temp $(TARGET)/measurements
$(call step,measure)
# Aggregate all metrics in summary CSV files.
aggregate: $(TARGET)/measurements $(TARGET)/data
$(call step,aggregate)
# Summarize aggregated metrics in summary CSV files.
summarize: $(TARGET)/measurements $(TARGET)/data
$(call step,summarize)
$(TARGET)/report.pdf: $(TARGET)/temp tex/report.tex
$(call step,report)
$(TARGET)/github:
mkdir -p "$(TARGET)/github"
$(TARGET)/data:
mkdir -p "$(TARGET)/data"
$(TARGET)/measurements:
mkdir -p "$(TARGET)/measurements"
$(TARGET)/temp:
mkdir -p "$(TARGET)/temp"