forked from sdsen/ebpf-projects-annotations
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecute_workflow.sh
More file actions
executable file
·55 lines (44 loc) · 1.58 KB
/
execute_workflow.sh
File metadata and controls
executable file
·55 lines (44 loc) · 1.58 KB
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
#!/bin/bash
ACTION=$1
PROJECT=$2
PROJECT_URL=$3
PROJECTS_DIR=projects
PROJECT_DIR=${PROJECTS_DIR}/${PROJECT}
ORIGINAL_SRC=${PROJECT_DIR}/original_source
HUMAN_ANNOTATED=${PROJECT_DIR}/human_annotated
INTERMEDIATE_FILES=${PROJECT_DIR}/intermediate_files
ANNOTATOR=src/annotator.py
COMMENT_EXTRACTOR=src/utils/comment_extractor.py
README=asset/README.MD
function create_dirs {
# Create the directories
mkdir -p ${PROJECT_DIR}
mkdir -p ${ORIGINAL_SRC} ${HUMAN_ANNOTATED} ${INTERMEDIATE_FILES}
cp ${README} ${PROJECT_DIR}
# TODO: Might have code in specific subdirectories so best if users did that for now.
# Clone the source
echo "Run the below command and keep the bpf directory only, deleting others"
echo "git clone --depth=1 ${PROJECT_URL} ${ORIGINAL_SRC} && rm -rf ${ORIGINAL_SRC}/.git && cd ${ORIGINAL_SRC}"
}
function annotate_project {
# Run annotator
python3 ${ANNOTATOR} -o ${INTERMEDIATE_FILES}/${PROJECT} -s ${ORIGINAL_SRC} -c ${HUMAN_ANNOTATED} \
-t ${INTERMEDIATE_FILES}/${PROJECT}.function_file_list.json -u ${INTERMEDIATE_FILES}/${PROJECT}.struct_file_list.json \
-p ${PROJECT}
}
function extract_comments {
python3 ${COMMENT_EXTRACTOR} -s ${HUMAN_ANNOTATED} -d ${HUMAN_ANNOTATED}/${PROJECT}.db_comments.db
}
ACTION=${1}
if [ "${ACTION}" = "create_dirs" ];
then
create_dirs
elif [ "${ACTION}" = "annotate" ];
then
annotate_project
elif [ "${ACTION}" = "extract_comment" ];
then
extract_comments
else
echo "USAGE ./scripts/execute_workflow.sh <create_dirs/annotate/extract_comment> <project> <project-git>"
fi