-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
202 lines (163 loc) · 7.3 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
CXX := g++
CXXFLAGS := -std=c++17 -Wall
OPENGLLIBS := -lGL -lglut -lGLEW
LDFLAGS := `pkg-config --libs protobuf grpc++`
PROTOC := protoc
THIRD_PARTY_PATH := ./thirdparty
INCLUDES := -I ./
INCLUDES += -I $(THIRD_PARTY_PATH)
INCLUDES += -I $(THIRD_PARTY_PATH)/Optimized-Photon-Mapping/src
.DEFAULT_GOAL := all
MAIN_NAME := ./environment/main
# components in config
CONFIG_PATH := ./config
CONFIG_OBJ := $(CONFIG_PATH)/config.o \
$(CONFIG_PATH)/location.o \
$(CONFIG_PATH)/terrain_raw_data.o \
# components in environment
ENVIRONMENT_PATH := ./environment
ENVIRONMENT_OBJ := $(ENVIRONMENT_PATH)/water_balance.o \
$(ENVIRONMENT_PATH)/climate.o \
$(ENVIRONMENT_PATH)/coordinate.o \
$(ENVIRONMENT_PATH)/environment.o \
$(ENVIRONMENT_PATH)/energy_balance.o \
$(ENVIRONMENT_PATH)/meteorology.o \
$(ENVIRONMENT_PATH)/plant_builder.o \
$(ENVIRONMENT_PATH)/plant_container.o \
$(ENVIRONMENT_PATH)/plant_radiation.o \
$(ENVIRONMENT_PATH)/plant.o \
$(ENVIRONMENT_PATH)/soil_container.o \
$(ENVIRONMENT_PATH)/soil.o \
$(ENVIRONMENT_PATH)/terrain.o \
$(ENVIRONMENT_PATH)/weather.o
# components in agent
AGENT_PATH := ./agent
AGENT_OBJ := $(AGENT_PATH)/agent.o $(AGENT_PATH)/q_learning.o
ACTION_PATH := $(AGENT_PATH)/actions
ACTION_OBJ := $(ACTION_PATH)/action.o $(ACTION_PATH)/crop.o
# components in environment/plants
PLANTS_PATH := $(ENVIRONMENT_PATH)/plants
PLANTS_OBJ := $(PLANTS_PATH)/bean.o
# components in environment/simulators (should be removed)
SIMULATOR_PATH := $(ENVIRONMENT_PATH)/simulators
PHOTON_SIMULATOR_PATH := $(SIMULATOR_PATH)/photons
PHOTON_SIMULATOR_PHOTON_PATH := $(PHOTON_SIMULATOR_PATH)/photon
PHOTON_SIMULATOR_PHOTON_OBJ := $(PHOTON_SIMULATOR_PHOTON_PATH)/photon.o
THIRDPARTY_TINY_OBJ_LOADER_PATH := $(THIRD_PARTY_PATH)/tinyobjloader
THIRDPARTY_MATH_VECTOR_PATH := $(THIRD_PARTY_PATH)/Optimized-Photon-Mapping/src/math
THIRDPARTY_MATH_VECTOR_OBJ := $(PHOTON_SIMULATOR_PATH)/vector.o
THIRDPARTY_KDTREE_PATH := $(THIRD_PARTY_PATH)/KDTree
THIRDPARTY_KDTREE_OBJ := $(PHOTON_SIMULATOR_PATH)/KDTree.o
PHOTON_SIMULATOR_MODEL_PATH := $(PHOTON_SIMULATOR_PATH)/model
PHOTON_SIMULATOR_MODEL_OBJ := $(PHOTON_SIMULATOR_MODEL_PATH)/face.o\
$(PHOTON_SIMULATOR_MODEL_PATH)/material.o\
$(PHOTON_SIMULATOR_MODEL_PATH)/mesh.o\
$(PHOTON_SIMULATOR_MODEL_PATH)/model.o\
$(PHOTON_SIMULATOR_MODEL_PATH)/tiny_obj_loader.o
PHOTON_SIMULATOR_OBJ := $(THIRDPARTY_MATH_VECTOR_OBJ) \
$(THIRDPARTY_KDTREE_OBJ) \
$(PHOTON_SIMULATOR_MODEL_OBJ) \
$(PHOTON_SIMULATOR_PHOTON_OBJ)
SIMULATOR_OBJ := $(SIMULATOR_PATH)/photon_simulator.o \
$(PHOTON_SIMULATOR_OBJ)
ALL_OBJ := $(CONFIG_OBJ) \
$(ENVIRONMENT_OBJ) \
$(AGENT_OBJ) \
$(ACTION_OBJ) \
$(PLANTS_OBJ) \
$(SIMULATOR_OBJ)
# unit tests
TEST_PATH := ./tests
TEST_AGENT_PATH := $(TEST_PATH)/agent
TEST_AGENT := $(TEST_AGENT_PATH)/agent_test \
$(TEST_AGENT_PATH)/qlearning_test
TEST_AGENT_ACTIONS_PATH := $(TEST_AGENT_PATH)/actions
TEST_AGENT_ACTIONS := $(TEST_AGENT_ACTIONS_PATH)/crop_test
TEST_CONFIG_PATH := $(TEST_PATH)/config
TEST_CONFIG := $(TEST_CONFIG_PATH)/config_test \
$(TEST_CONFIG_PATH)/location_test
TEST_ENVIRONMENT_PATH := $(TEST_PATH)/environment
TEST_ENVIRONMENT := $(TEST_ENVIRONMENT_PATH)/climate_test \
$(TEST_ENVIRONMENT_PATH)/environment_test \
$(TEST_ENVIRONMENT_PATH)/plant_container_test \
$(TEST_ENVIRONMENT_PATH)/meteorology_test \
$(TEST_ENVIRONMENT_PATH)/soil_test \
$(TEST_ENVIRONMENT_PATH)/terrain_test \
$(TEST_ENVIRONMENT_PATH)/utility_test \
$(TEST_ENVIRONMENT_PATH)/weather_test
TEST_ENVIRONMENT_PLANTS_PATH := $(TEST_ENVIRONMENT_PATH)/plants
TEST_ENVIRONMENT_PLANTS := $(TEST_ENVIRONMENT_PLANTS_PATH)/bean_test
TEST_SIMULATORS_PATH := $(TEST_PATH)/simulators
TEST_PHOTON_SIMULATOR_PATH := $(TEST_SIMULATORS_PATH)/photons
TEST_PHOTON_SIMULATOR_MODEL := $(TEST_PHOTON_SIMULATOR_PATH)/photon_simulator_model_test
TEST_ALL := $(TEST_AGENT) \
$(TEST_AGENT_ACTIONS) \
$(TEST_CONFIG) \
$(TEST_ENVIRONMENT) \
$(TEST_ENVIRONMENT_PLANTS) \
$(TEST_PHOTON_SIMULATOR_MODEL)
TESTFLAGS := -Igtest/include
TESTLD := -lgtest -lpthread
%.o: %.cc %.h
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
%.o: %.cc
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
$(PHOTON_SIMULATOR_MODEL_PATH)/tiny_obj_loader.o: $(THIRDPARTY_TINY_OBJ_LOADER_PATH)/tiny_obj_loader.cc $(THIRDPARTY_TINY_OBJ_LOADER_PATH)/tiny_obj_loader.h
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
$(PHOTON_SIMULATOR_PATH)/vector.o: $(THIRDPARTY_MATH_VECTOR_PATH)/vector.cpp $(THIRDPARTY_MATH_VECTOR_PATH)/vector.hpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
$(PHOTON_SIMULATOR_PATH)/KDTree.o: $(THIRDPARTY_KDTREE_PATH)/KDTree.cpp $(THIRDPARTY_KDTREE_PATH)/KDTree.hpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
%_test: %_test.cc $(ALL_OBJ)
$(CXX) $(CXXFLAGS) $(INCLUDES) $(TESTFLAGS) $(ALL_OBJ) [email protected] -o $@ $(TESTLD) $(LDFLAGS) $(OPENGLLIBS)
all: $(ALL_OBJ)
$(CXX) $(CXXFLAGS) $(INCLUDES) $(ALL_OBJ) $(MAIN_NAME).cc -o $(MAIN_NAME) $(OPENGLLIBS)
config: $(CONFIG_OBJ)
environment: $(ENVIRONMENT_OBJ)
agent: $(AGENT_OBJ)
action: $(ACTION_OBJ)
plants: $(PLANTS_OBJ)
# agent server rules
AGENT_SERVER_PATH := ./agent_server
AGENT_SERVER_PROTO_PATH := $(AGENT_SERVER_PATH)/proto
AGENT_SERVER_PROTO_DEF := $(AGENT_SERVER_PROTO_PATH)/environment.pb.cc \
$(AGENT_SERVER_PROTO_PATH)/agent_server.pb.cc
AGENT_SERVER_PROTO_OBJ := $(AGENT_SERVER_PROTO_PATH)/environment.pb.o \
$(AGENT_SERVER_PROTO_PATH)/agent_server.pb.o
AGENT_SERVER_GRPC_PROTO_OBJ := $(AGENT_SERVER_PROTO_PATH)/agent_server.grpc.pb.o
AGENT_SERVER_OBJ := $(AGENT_SERVER_PROTO_OBJ) \
$(AGENT_SERVER_GRPC_PROTO_OBJ) \
$(AGENT_SERVER_PATH)/agent_server.o \
$(AGENT_SERVER_PATH)/message_convertor.o
# protobuf rules
AGENT_SERVER_PROTO_FLAGS := --proto_path=$(AGENT_SERVER_PROTO_PATH) --cpp_out=$(AGENT_SERVER_PROTO_PATH)
AGENT_SERVER_GRPC_FLAGS := --proto_path=$(AGENT_SERVER_PROTO_PATH) --grpc_out=$(AGENT_SERVER_PROTO_PATH) --plugin=protoc-gen-grpc=`which grpc_cpp_plugin`
AGENT_SERVER_TEST_PATH := $(TEST_PATH)/agent_server
AGENT_SERVER_TEST := $(AGENT_SERVER_TEST_PATH)/agent_server_test \
$(AGENT_SERVER_TEST_PATH)/message_convertor_test
%.pb.cc: %.proto
$(PROTOC) $(AGENT_SERVER_PROTO_FLAGS) $<
%.grpc.pb.cc: %.proto %.pb.cc
$(PROTOC) $(AGENT_SERVER_GRPC_FLAGS) $<
agent_server: $(ALL_OBJ) $(AGENT_SERVER_OBJ) $(AGENT_SERVER_PATH)/agent_server_grpc_service.cc
$(CXX) $(CXXFLAGS) $(INCLUDES) $(ALL_OBJ) $(AGENT_SERVER_OBJ) $(AGENT_SERVER_PATH)/agent_server_grpc_service.cc $(LDFLAGS) -o $(AGENT_SERVER_PATH)/agent_server $(OPENGLLIBS)
agent_server_test: $(ALL_OBJ) $(AGENT_SERVER_OBJ)
$(CXX) $(CXXFLAGS) $(INCLUDES) -I $(AGENT_SERVER_PATH) $(TESTFLAGS) $(ALL_OBJ) $(AGENT_SERVER_OBJ) $(AGENT_SERVER_TEST_PATH)/message_convertor_test.cc -o $(AGENT_SERVER_TEST_PATH)/message_convertor_test $(TESTLD) $(LDFLAGS) $(OPENGLLIBS)
$(CXX) $(CXXFLAGS) $(INCLUDES) -I $(AGENT_SERVER_PATH) $(TESTFLAGS) $(ALL_OBJ) $(AGENT_SERVER_OBJ) $(AGENT_SERVER_TEST_PATH)/agent_server_test.cc -o $(AGENT_SERVER_TEST_PATH)/agent_server_test $(TESTLD) $(LDFLAGS) $(OPENGLLIBS)
agent_server_test_run: agent_server_test
@for var in $(AGENT_SERVER_TEST); do \
echo $$var; \
$$var; \
done
all_test: $(TEST_ALL)
all_test_run: $(TEST_ALL)
@for var in $(TEST_ALL); do \
echo $$var; \
$$var; \
done
clean:
rm -f $(ALL_OBJ) $(TEST_ALL)
rm -f $(MAIN_NAME)
rm -f $(AGENT_SERVER_PROTO_PATH)/*.h $(AGENT_SERVER_PROTO_PATH)/*.cc $(AGENT_SERVER_PROTO_PATH)/*.o
rm -f $(AGENT_SERVER_OBJ) $(AGENT_SERVER_TEST)
rm -f $(AGENT_SERVER_PATH)/agent_server