-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUILD][MISC] Merge pull request #269 from pioneers/makefile_tests_new
[BUILD][MISC] Rewritten all Makefiles for efficiency and correctness
- Loading branch information
Showing
51 changed files
with
589 additions
and
838 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# This Makefile defines a bunch of stuff used by the lower-level Makefiles | ||
# all file paths are from their perspective! | ||
|
||
CC = gcc | ||
|
||
BIN = ../bin | ||
BUILD = ../build | ||
OBJ = $(BUILD)/obj | ||
|
||
# this is the name of the lower level directory (e.g. THIS_DIR in the dev_handler folder is "dev_handler") | ||
THIS_DIR = $(strip $(shell pwd | xargs basename -z)) | ||
|
||
# list of runtime component directories | ||
COMPONENT_DIRS = dev_handler net_handler executor network_switch shm_wrapper runtime_util logger | ||
# list of subfolders in $(OBJ) for runtime object files | ||
OBJ_SUBDIR = $(foreach dir,$(COMPONENT_DIRS),$(OBJ)/$(dir)) | ||
# list of folders to include in compilation commands | ||
INCLUDE += $(foreach dir,$(COMPONENT_DIRS),-I../$(dir)) | ||
|
||
# list of all object files this executable is dependent on relative to this Makefile | ||
OBJS = $(patsubst %.c,$(OBJ)/$(THIS_DIR)/%.o,$(SRCS)) | ||
|
||
# list of build folders | ||
BUILD_DIR += $(OBJ) $(BIN) $(BUILD) $(OBJ_SUBDIR) | ||
|
||
# append -MMD and -MP to CFLAGS to get the dependency files built for the object files | ||
CFLAGS += -MMD -MP | ||
|
||
# general rule for compiling a list of source files to object files in the $(OBJ) directory | ||
$(OBJ)/$(THIS_DIR)/%.o: %.c | $(OBJ_SUBDIR) | ||
$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ | ||
|
||
# general rule for making a build directory | ||
$(BUILD_DIR): | ||
mkdir -p $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,30 @@ | ||
LIBFLAGS=-pthread -lrt -Wall | ||
BIN=../bin | ||
# list of libraries that dev_handler needs to compile | ||
LIBS=-pthread -lrt -Wall | ||
|
||
dev_handler: dev_handler.c message.c message.h ../logger/logger.c ../runtime_util/runtime_util.c ../shm_wrapper/shm_wrapper.c | ||
gcc $^ -o $(BIN)/dev_handler $(LIBFLAGS) | ||
# list of source files that the target (dev_handler) depends on, relative to this folder | ||
SRCS = dev_handler.c dev_handler_message.c ../logger/logger.c ../runtime_util/runtime_util.c ../shm_wrapper/shm_wrapper.c | ||
|
||
# specify the target (executable we want to make) | ||
TARGET = dev_handler | ||
|
||
.PHONY: all clean $(TARGET) | ||
|
||
all: $(TARGET) | ||
|
||
# include top-level Makefile for some common variables and rules | ||
include ../Makefile_defs | ||
|
||
# resolve phony target "dev_handler" as ../bin/dev_handler | ||
$(TARGET): $(BIN)/$(TARGET) | ||
|
||
# rule to compile dev_handler | ||
$(BIN)/$(TARGET): $(OBJS) | $(BIN) | ||
$(CC) $(OBJS) -o $@ $(LIBS) | ||
|
||
# remove build artifacts | ||
clean: | ||
rm -f $(BIN)/dev_handler | ||
rm -f dev_handler | ||
|
||
rm -f $(OBJS) | ||
rm -f $(patsubst %.o,%.d,$(OBJS)) | ||
rm -f $(BIN)/$(TARGET) | ||
|
||
-include $(patsubst %.o,%.d,$(OBJS)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,45 @@ | ||
# Change this to point to your specific Python version. Need >= 3.6 | ||
py=python3.10 | ||
# list of libraries that executor needs to compile | ||
LIBS=-pthread -lrt -Wall -export-dynamic -fPIC | ||
|
||
CFLAGS=$(shell $(py)-config --cflags) | ||
LDFLAGS=$(shell $(py)-config --ldflags) | ||
PY_LIB=-l$(py) | ||
LIBS=-pthread -lrt -export-dynamic -fPIC -lprotobuf-c | ||
#-rdynamic or -export-dynamic to make it dynamically linked | ||
BIN=../bin | ||
# list of source files that the target (executor) depends on, relative to this folder | ||
SRCS = executor.c gamestate_filter.c ../logger/logger.c ../runtime_util/runtime_util.c ../shm_wrapper/shm_wrapper.c | ||
|
||
all: executor studentapi.c | ||
# Python compilation definitions | ||
PY_VER = python3.10 | ||
PY_LIB = -l$(PY_VER) | ||
CFLAGS = $(shell $(PY_VER)-config --cflags) | ||
|
||
executor: executor.c gamestate_filter.c ../shm_wrapper/shm_wrapper.c ../logger/logger.c ../runtime_util/runtime_util.c ../net_handler/net_util.c ../net_handler/pbc_gen/text.pb-c.c | ||
gcc $(CFLAGS) $^ -o $(BIN)/$@ $(LIBS) $(PY_LIB) | ||
# specify the target (executable we want to make) | ||
TARGET = executor | ||
|
||
studentapi.c: studentapi.pyx runtime.pxd | ||
$(py) setup.py build_ext -i | ||
.PHONY: all clean $(TARGET) | ||
|
||
all: $(TARGET) studentapi.c | ||
|
||
# include top-level Makefile for common variables and rules | ||
include ../Makefile_defs | ||
|
||
$(TARGET): $(BIN)/$(TARGET) | ||
|
||
# rule to compile executor | ||
$(BIN)/$(TARGET): $(OBJS) | $(BIN) | ||
$(CC) $(OBJS) -o $@ $(LIBS) $(PY_LIB) | ||
|
||
# rule to compile studentapi.c | ||
studentapi.c: studentapi.pyx studentapi.pxd setup.py | ||
$(PY_VER) setup.py build_ext -i | ||
|
||
# rule to compile testapi | ||
test_api: studentapi.c test_studentapi.py | ||
- $(py) test_studentapi.py | ||
- $(PY_VER) test_studentapi.py | ||
|
||
# remove build artifacts | ||
clean: | ||
rm -f studentapi.c | ||
rm -f $(BIN)/executor | ||
rm -f executor | ||
rm -f $(OBJS) | ||
rm -f $(patsubst %.o,%.d,$(OBJS)) | ||
rm -rf studentapi.c | ||
rm -f *.so | ||
rm -rf build | ||
rm -f $(BIN)/$(TARGET) | ||
|
||
-include $(patsubst %.o,%.d,$(OBJS)) |
Oops, something went wrong.