@@ -9,96 +9,103 @@ OBJ_DIR = build
9
9
EXE_DIR = bin
10
10
TST_DIR = tests
11
11
12
- # make all builds everything
13
- all : code test
12
+ # Locate all the .cpp files in the src directory
13
+ SRC_FILES := $(shell find $(SRC_DIR ) -name '* .cpp')
14
+ OBJS := $(patsubst $(SRC_DIR ) /% .cpp, $(OBJ_DIR ) /% .o, $(SRC_FILES ) )
14
15
15
- # Compile only the main code
16
- code : build bin $(EXE_DIR ) /main $(EXE_DIR ) /main2
16
+ # Define the test executables
17
+ UNIT_TEST_SRCS := $(wildcard $(TST_DIR ) /* .cc)
18
+ UNIT_TESTS := $(patsubst $(TST_DIR ) /% .cc, $(EXE_DIR ) /% , $(UNIT_TEST_SRCS ) )
17
19
18
- # Compile all test executables
19
- test : build bin $(EXE_DIR ) /graph_node_test $(EXE_DIR ) /graph_test $(EXE_DIR ) /test_distance $(EXE_DIR ) /test_data_vectors $(EXE_DIR ) /test_recall
20
- @echo " Running all tests:"
21
- $(EXE_DIR ) /graph_node_test
22
- $(EXE_DIR ) /graph_test
23
- $(EXE_DIR ) /test_distance
24
- $(EXE_DIR ) /test_data_vectors
25
- $(EXE_DIR ) /test_recall
20
+ # Define the application executables
21
+ TARGET_SIMPLE_VAMANA = $(EXE_DIR ) /simple_vamana
22
+ TARGET_FILTERED_VAMANA = $(EXE_DIR ) /filtered_vamana
26
23
27
- # Run tests with valgrind
28
- valgrind : test
29
- valgrind --leak-check=full $(EXE_DIR ) /graph_node_test
30
- valgrind --leak-check=full $(EXE_DIR ) /graph_test
31
- valgrind --leak-check=full $(EXE_DIR ) /test_distance
32
- valgrind --leak-check=full $(EXE_DIR ) /test_data_vectors
33
- valgrind --leak-check=full $(EXE_DIR ) /test_recall
24
+ # Default targets
25
+ all : app tests
34
26
35
- # Define the rule for the main executable
36
- $(EXE_DIR ) /main : $(OBJ_DIR ) /main.o $(OBJ_DIR ) /read_vectors.o $(OBJ_DIR ) /distance_functions.o
37
- $(CC ) $(FLAGS ) -o $(EXE_DIR ) /main $(OBJ_DIR ) /main.o $(OBJ_DIR ) /read_vectors.o $(OBJ_DIR ) /distance_functions.o
27
+ app : $(TARGET_SIMPLE_VAMANA ) $(TARGET_FILTERED_VAMANA )
28
+ tests : $(UNIT_TESTS )
38
29
39
- $(OBJ_DIR ) /main.o : main.cpp $(INC_DIR ) /DataStructures/Graph/graph.h $(INC_DIR ) /read_data.h $(INC_DIR ) /DataStructures/DataVector/DataVector.h
40
- $(CC ) $(FLAGS ) -o $(OBJ_DIR ) /main.o -c main.cpp
30
+ # Compile the first executable and its dependencies (objects)
31
+ $(TARGET_SIMPLE_VAMANA ) : $(OBJS ) $(OBJ_DIR ) /simple_vamana_main.o
32
+ @mkdir -p $(EXE_DIR )
33
+ $(CC ) $(FLAGS ) $(OBJS ) $(OBJ_DIR ) /simple_vamana_main.o -o $@
41
34
42
- $(EXE_DIR ) /main2 : $(OBJ_DIR ) /main2.o $(OBJ_DIR ) /read_vectors.o $(OBJ_DIR ) /distance_functions.o
43
- $(CC ) $(FLAGS ) -o $(EXE_DIR ) /main2 $(OBJ_DIR ) /main2.o $(OBJ_DIR ) /read_vectors.o $(OBJ_DIR ) /distance_functions.o
35
+ $(OBJ_DIR ) /simple_vamana_main.o : app/simple_vamana_main.cpp
36
+ @mkdir -p $(OBJ_DIR )
37
+ $(CC ) $(FLAGS ) -c $< -o $@
44
38
45
- $(OBJ_DIR ) /main2.o : main2.cpp $(INC_DIR ) /DataStructures/Graph/graph.h $(INC_DIR ) /read_data.h $(INC_DIR ) /DataStructures/DataVector/DataVector.h
46
- $(CC ) $(FLAGS ) -o $(OBJ_DIR ) /main2.o -c main2.cpp
39
+ # Compile the second executable and its dependencies (objects)
40
+ $(TARGET_FILTERED_VAMANA ) : $(OBJS ) $(OBJ_DIR ) /filtered_vamana_main.o
41
+ @mkdir -p $(EXE_DIR )
42
+ $(CC ) $(FLAGS ) $(OBJS ) $(OBJ_DIR ) /filtered_vamana_main.o -o $@
47
43
48
- # Rule to create read_vectors.o
49
- $( OBJ_DIR ) /read_vectors.o : $( SRC_DIR ) /read_vectors.cpp $(INC_DIR ) /read_data.h $( INC_DIR ) /DataStructures/DataVector/DataVector.h
50
- $(CC ) $(FLAGS ) -o $( OBJ_DIR ) /read_vectors.o -c $( SRC_DIR ) /read_vectors.cpp
44
+ $( OBJ_DIR ) /filtered_vamana_main.o : app/filtered_vamana_main.cpp
45
+ @mkdir -p $(OBJ_DIR )
46
+ $(CC ) $(FLAGS ) -c $< -o $@
51
47
52
- # Rule to create distance_functions.o
53
- $(OBJ_DIR ) /distance_functions.o : $(SRC_DIR ) /distance_functions.cpp $(INC_DIR ) /distance.h
54
- $(CC ) $(FLAGS ) -o $(OBJ_DIR ) /distance_functions.o -c $(SRC_DIR ) /distance_functions.cpp
48
+ # Compile the objects in the src directory
49
+ $(OBJ_DIR ) /% .o : $(SRC_DIR ) /% .cpp
50
+ @mkdir -p $(dir $@ )
51
+ $(CC ) $(FLAGS ) -c $< -o $@
55
52
56
- # Test executables and object file rules
53
+ # Compile the test executables and their dependencies
54
+ $(EXE_DIR ) /% : $(OBJ_DIR ) /% .o $(OBJS )
55
+ @mkdir -p $(EXE_DIR )
56
+ $(CC ) $(FLAGS ) $< $(OBJS ) -o $@
57
57
58
- # Build graph_node_test executable
59
- $( EXE_DIR ) /graph_node_test : $(OBJ_DIR ) /graph_node_test.o
60
- $(CC ) $(FLAGS ) -o $( EXE_DIR ) /graph_node_test $( OBJ_DIR ) /graph_node_test.o
58
+ $( OBJ_DIR ) / % .o : $( TST_DIR ) / % .cc
59
+ @mkdir -p $(OBJ_DIR )
60
+ $(CC ) $(FLAGS ) -c $< -o $@
61
61
62
- $(OBJ_DIR ) /graph_node_test.o : $(TST_DIR ) /graph_node_test.cc $(INC_DIR ) /acutest.h $(INC_DIR ) /DataStructures/Graph/graph_node.h
63
- $(CC ) $(FLAGS ) -o $(OBJ_DIR ) /graph_node_test.o -c $(TST_DIR ) /graph_node_test.cc
62
+ # Clean the object files
63
+ clean :
64
+ rm -rf $(OBJ_DIR ) $(EXE_DIR )
64
65
65
- # Build graph_test executable
66
- $( EXE_DIR ) /graph_test : $( OBJ_DIR ) /graph_test.o
67
- $( CC ) $( FLAGS ) -o $(EXE_DIR ) /graph_test $( OBJ_DIR ) /graph_test.o
66
+ # Dependency generation
67
+ DEPFLAGS = -MMD -MP
68
+ FLAGS += $(DEPFLAGS )
68
69
69
- $(OBJ_DIR ) /graph_test.o : $(TST_DIR ) /graph_test.cc $(INC_DIR ) /acutest.h $(INC_DIR ) /DataStructures/Graph/graph.h
70
- $(CC ) $(FLAGS ) -o $(OBJ_DIR ) /graph_test.o -c $(TST_DIR ) /graph_test.cc
70
+ -include $(OBJS :.o=.d)
71
+ -include $(OBJ_DIR ) /simple_vamana_main.d
72
+ -include $(OBJ_DIR ) /filtered_vamana_main.d
71
73
72
- # Build test_distance executable
73
- $(EXE_DIR ) /test_distance : $(OBJ_DIR ) /test_distance.o $(OBJ_DIR ) /distance_functions.o
74
- $(CC ) $(FLAGS ) -o $(EXE_DIR ) /test_distance $(OBJ_DIR ) /test_distance.o $(OBJ_DIR ) /distance_functions.o
75
74
76
- $(OBJ_DIR ) /test_distance.o : $(TST_DIR ) /test_distance.cc $(INC_DIR ) /acutest.h $(INC_DIR ) /distance.h
77
- $(CC ) $(FLAGS ) -o $(OBJ_DIR ) /test_distance.o -c $(TST_DIR ) /test_distance.cc
78
75
79
- # Build test_data_vectors executable
80
- $(EXE_DIR ) /test_data_vectors : $(OBJ_DIR ) /test_data_vectors.o $(OBJ_DIR ) /read_vectors.o
81
- $(CC ) $(FLAGS ) -o $(EXE_DIR ) /test_data_vectors $(OBJ_DIR ) /test_data_vectors.o $(OBJ_DIR ) /read_vectors.o
76
+ # Execution Rules
82
77
83
- $( OBJ_DIR ) /test_data_vectors.o : $( TST_DIR ) /test_data_vectors.cc $( INC_DIR ) /acutest.h $( INC_DIR ) /read_data.h
84
- $( CC ) $( FLAGS ) -o $( OBJ_DIR ) /test_data_vectors.o -c $( TST_DIR ) /test_data_vectors.cc
78
+ create_simple_vamana :
79
+ ./bin/simple_vamana --create -base-file ' data/siftsmall/siftsmall_base.fvecs ' -L 20 -R 14 -alpha 1.0 -save ' index.bin '
85
80
86
- # Build test_recall executable
87
- $(EXE_DIR ) /test_recall : $(OBJ_DIR ) /test_recall.o
88
- $(CC ) $(FLAGS ) -o $(EXE_DIR ) /test_recall $(OBJ_DIR ) /test_recall.o
81
+ create_simple_vamana_valgrind :
82
+ valgrind --leak-check=full ./bin/simple_vamana --create -base-file ' data/siftsmall/siftsmall_base.fvecs' -L 10 -R 14 -alpha 1.0 -save ' index.bin'
89
83
90
- $(OBJ_DIR ) /test_recall.o : $(TST_DIR ) /test_recall.cc $(INC_DIR ) /acutest.h $(INC_DIR ) /Evaluation/recall.h
91
- $(CC ) $(FLAGS ) -o $(OBJ_DIR ) /test_recall.o -c $(TST_DIR ) /test_recall.cc
92
84
93
- # Directories creation
94
- build :
95
- mkdir -p $(OBJ_DIR )
85
+ test_simple_vamana :
86
+ ./bin/simple_vamana --test -load ' index.bin' -k 100 -L 120 -gt-file ' data/siftsmall/siftsmall_groundtruth.ivecs' -query-file ' data/siftsmall/siftsmall_query.fvecs' -query 0
96
87
97
- bin :
98
- mkdir -p $( EXE_DIR )
88
+ test_simple_vamana_valgrind :
89
+ valgrind --leak-check=full ./bin/simple_vamana --test -load ' index.bin ' -k 100 -L 10 -gt-file ' data/siftsmall/siftsmall_groundtruth.ivecs ' -query-file ' data/siftsmall/siftsmall_query.fvecs ' -query 0
99
90
100
- # Clean command to clean the workspace
101
- .PHONY : clean
102
- clean :
103
- rm -r -f $(EXE_DIR )
104
- rm -r -f $(OBJ_DIR )
91
+
92
+ create_filtered_vamana :
93
+ ./bin/filtered_vamana
94
+
95
+ create_filtered_vamana_valgrind :
96
+ ./bin/filtered_vamana
97
+
98
+
99
+ run_tests :
100
+ ./bin/graph_node_test
101
+ ./bin/graph_test
102
+ ./bin/test_distance
103
+ ./bin/test_data_vectors
104
+ ./bin/test_recall
105
+
106
+ run_tests_valgrind :
107
+ valgrind --leak-check=full ./bin/graph_node_test
108
+ valgrind --leak-check=full ./bin/graph_test
109
+ valgrind --leak-check=full ./bin/test_distance
110
+ valgrind --leak-check=full ./bin/test_data_vectors
111
+ valgrind --leak-check=full ./bin/test_recall
0 commit comments