<commit_before>CXX := clang++


#TESTING CRAP REMOVE
b.test : a.test
	echo "b?"
	if test -e b.test; then echo "b exists"; else touch b.test; echo "made b"; fi
c.test : b.test
	echo "making c"
	touch c.test

PLUGIN_TRANSLATION_UNITS       := $(wildcard ksp_plugin/*.cpp)
PLUGIN_TEST_TRANSLATION_UNITS  := $(wildcard ksp_plugin_test/*.cpp)
JOURNAL_TRANSLATION_UNITS      := $(wildcard journal/*.cpp)
MOCK_TRANSLATION_UNITS         := $(wildcard */mock_*.cpp)
TEST_TRANSLATION_UNITS         := $(wildcard */*_test.cpp)
TEST_OR_MOCK_TRANSLATION_UNITS := $(TEST_TRANSLATION_UNITS) $(MOCK_TRANSLATION_UNITS)
TOOLS_TRANSLATION_UNITS        := $(wildcard tools/*.cpp)
LIBRARY_TRANSLATION_UNITS      := $(filter-out $(TEST_OR_MOCK_TRANSLATION_UNITS), $(wildcard */*.cpp))
JOURNAL_LIB_TRANSLATION_UNITS  := $(filter-out $(TEST_OR_MOCK_TRANSLATION_UNITS), $(wildcard journal/*.cpp))
BASE_LIB_TRANSLATION_UNITS     := $(filter-out $(TEST_OR_MOCK_TRANSLATION_UNITS), $(wildcard base/*.cpp))
PROTO_FILES                    := $(wildcard */*.proto)
PROTO_TRANSLATION_UNITS        := $(PROTO_FILES:.proto=.pb.cc)
PROTO_HEADERS                  := $(PROTO_FILES:.proto=.pb.h)

DEP_DIR := deps/

BIN_DIRECTORY := bin/
TOOLS_BIN     := $(BIN_DIRECTORY)tools

GMOCK_TRANSLATION_UNITS :=                     \
	$(DEP_DIR)googlemock/src/gmock-all.cc  \
	$(DEP_DIR)googlemock/src/gmock_main.cc \
	$(DEP_DIR)googletest/src/gtest-all.cc

VERSION_HEADER := base/version.generated.h

GENERATED_PROFILES :=                    \
	journal/profiles.generated.h     \
	journal/profiles.generated.cc    \
	journal/player.generated.cc      \
	ksp_plugin/interface.generated.h \
	ksp_plugin_adapter/interface.generated.cs

PROJECT_DIR := ksp_plugin_adapter/
SOLUTION_DIR := ./
ADAPTER_BUILD_DIR := ksp_plugin_adapter/obj
ADAPTER_CONFIGURATION := Release
FINAL_PRODUCTS_DIR := Release
ADAPTER := $(ADAPTER_BUILD_DIR)/$(ADAPTER_CONFIGURATION)/ksp_plugin_adapter.dll

LIB_DIR := $(FINAL_PRODUCTS_DIR)/GameData/Principia/Linux64
LIB := $(LIB_DIR)/principia.so
TEST_LIBS := $(DEP_DIR)benchmark/src/libbenchmark.a
LIBS      := $(DEP_DIR)/protobuf/src/.libs/libprotobuf.a $(DEP_DIR)/glog/.libs/libglog.a -lpthread -lc++ -lc++abi
TEST_INCLUDES := -I$(DEP_DIR)googlemock/include -I$(DEP_DIR)googletest/include -I$(DEP_DIR)googlemock/ -I$(DEP_DIR)googletest/ -I$(DEP_DIR)benchmark/include 
INCLUDES := -I. -I$(DEP_DIR)glog/src -I$(DEP_DIR)protobuf/src -I$(DEP_DIR)Optional -I$(DEP_DIR)eggsperimental_filesystem/
SHARED_ARGS := -std=c++14 -stdlib=libc++ -O3 -g -fPIC -fexceptions -ferror-limit=1 -fno-omit-frame-pointer -Wall -Wpedantic \
	-DPROJECT_DIR='std::experimental::filesystem::path("$(PROJECT_DIR)")'\
	-DSOLUTION_DIR='std::experimental::filesystem::path("$(SOLUTION_DIR)")' \
	-DNDEBUG

COMPILER_OPTIONS = -c $(SHARED_ARGS) $(INCLUDES)

# detect OS
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
    UNAME_M := $(shell uname -m)
    ifeq ($(UNAME_M),x86_64)
        SHARED_ARGS += -m64
    else
        SHARED_ARGS += -m32
    endif
    MDTOOL := mdtool
endif
ifeq ($(UNAME_S),Darwin)
    SHARED_ARGS += -mmacosx-version-min=10.7 -arch i386
    MDTOOL ?= "/Applications/Xamarin Studio.app/Contents/MacOS/mdtool"
endif

########## Dependency resolution

BUILD_DIRECTORY := build/

TEST_OR_MOCK_DEPENDENCIES := $(addprefix $(BUILD_DIRECTORY), $(TEST_OR_MOCK_TRANSLATION_UNITS:.cpp=.d))
TOOLS_DEPENDENCIES        := $(addprefix $(BUILD_DIRECTORY), $(TOOLS_TRANSLATION_UNITS:.cpp=.d))
LIBRARY_DEPENDENCIES      := $(addprefix $(BUILD_DIRECTORY), $(LIBRARY_TRANSLATION_UNITS:.cpp=.d))
PLUGIN_DEPENDENCIES       := $(addprefix $(BUILD_DIRECTORY), $(PLUGIN_TRANSLATION_UNITS:.cpp=.d))
PLUGIN_TEST_DEPENDENCIES  := $(addprefix $(BUILD_DIRECTORY), $(PLUGIN_TEST_TRANSLATION_UNITS:.cpp=.d))
JOURNAL_DEPENDENCIES      := $(addprefix $(BUILD_DIRECTORY), $(JOURNAL_TRANSLATION_UNITS:.cpp=.d))

# As a prerequisite for listing the includes of things that depend on
# generated headers, we must generate said code.
# Note that the prerequisites for dependency files are order-only, for
# bootstrapping: once we have the dependency files, their own actual dependency
# on generated headers and on the translation unit will be listed there and
# recomputed as needed.
$(PLUGIN_DEPENDENCIES)              : | $(GENERATED_PROFILES)
$(PLUGIN_TEST_DEPENDENCIES)         : | $(GENERATED_PROFILES)
$(JOURNAL_DEPENDENCIES)             : | $(GENERATED_PROFILES)

$(LIBRARY_DEPENDENCIES): $(BUILD_DIRECTORY)%.d: %.cpp | $(PROTO_HEADERS)
	@mkdir -p $(@D)
	$(CXX) -M $(COMPILER_OPTIONS) $< > $@.temp
	sed 's!.*\.o[ :]*!$(BUILD_DIRECTORY)$*.o $@ : !g' < $@.temp > $@
	rm -f $@.temp

$(TEST_OR_MOCK_DEPENDENCIES): $(BUILD_DIRECTORY)%.d: %.cpp | $(PROTO_HEADERS)
	@mkdir -p $(@D)
	$(CXX) -M $(COMPILER_OPTIONS) $(TEST_INCLUDES) $< > $@.temp
	sed 's!.*\.o[ :]*!$(BUILD_DIRECTORY)$*.o $@ : !g' < $@.temp > $@
	rm -f $@.temp

include $(LIBRARY_DEPENDENCIES)
include $(TEST_OR_MOCK_DEPENDENCIES)

########## Compilation

##### C# and C++ code generation

$(VERSION_HEADER): .git
	./generate_version_header.sh

# We don't do dependency resolution on the protos; we compile them all at once.
$(PROTO_HEADERS) $(PROTO_TRANSLATION_UNITS): $(PROTO_FILES)
	$(DEP_DIR)/protobuf/src/protoc -I $(DEP_DIR)/protobuf/src/ -I . $^ --cpp_out=.

$(GENERATED_PROFILES) : $(TOOLS_BIN)
	$^ generate_profiles

##### C++ compilation

OBJ_DIRECTORY := obj/

TEST_OR_MOCK_OBJECTS := $(addprefix $(OBJ_DIRECTORY), $(TEST_OR_MOCK_TRANSLATION_UNITS:.cpp=.o))
LIBRARY_OBJECTS      := $(addprefix $(OBJ_DIRECTORY), $(LIBRARY_TRANSLATION_UNITS:.cpp=.o))
PROTO_OBJECTS        := $(addprefix $(OBJ_DIRECTORY), $(PROTO_TRANSLATION_UNITS:.cc=.o))
GMOCK_OBJECTS        := $(addprefix $(OBJ_DIRECTORY), $(GMOCK_TRANSLATION_UNITS:.cc=.o))
TOOLS_OBJECTS        := $(addprefix $(OBJ_DIRECTORY), $(TOOLS_TRANSLATION_UNITS:.cpp=.o))
PLUGIN_OBJECTS       := $(addprefix $(OBJ_DIRECTORY), $(PLUGIN_TRANSLATION_UNITS:.cpp=.o))
JOURNAL_LIB_OBJECTS  := $(addprefix $(OBJ_DIRECTORY), $(JOURNAL_LIB_TRANSLATION_UNITS:.cpp=.o))
BASE_LIB_OBJECTS     := $(addprefix $(OBJ_DIRECTORY), $(BASE_LIB_TRANSLATION_UNITS:.cpp=.o))<commit_msg>don't compute deps to clean, require version header, forget the benchmarks for now<commit_after>CXX := clang++

# TODO(egg): build benchmarks

#TESTING CRAP REMOVE
b.test : a.test
	echo "b?"
	if test -e b.test; then echo "b exists"; else touch b.test; echo "made b"; fi
c.test : b.test
	echo "making c"
	touch c.test

PLUGIN_TRANSLATION_UNITS       := $(wildcard ksp_plugin/*.cpp)
PLUGIN_TEST_TRANSLATION_UNITS  := $(wildcard ksp_plugin_test/*.cpp)
JOURNAL_TRANSLATION_UNITS      := $(wildcard journal/*.cpp)
MOCK_TRANSLATION_UNITS         := $(wildcard */mock_*.cpp)
BENCHMARK_TRANSLATION_UNITS    := $(wildcard benchmarks/*.cpp)
TEST_TRANSLATION_UNITS         := $(wildcard */*_test.cpp)
TEST_OR_MOCK_TRANSLATION_UNITS := $(TEST_TRANSLATION_UNITS) $(MOCK_TRANSLATION_UNITS)
TOOLS_TRANSLATION_UNITS        := $(wildcard tools/*.cpp)
LIBRARY_TRANSLATION_UNITS      := $(filter-out $(TEST_OR_MOCK_TRANSLATION_UNITS) $(BENCHMARK_TRANSLATION_UNITS), $(wildcard */*.cpp))
JOURNAL_LIB_TRANSLATION_UNITS  := $(filter-out $(TEST_OR_MOCK_TRANSLATION_UNITS), $(wildcard journal/*.cpp))
BASE_LIB_TRANSLATION_UNITS     := $(filter-out $(TEST_OR_MOCK_TRANSLATION_UNITS), $(wildcard base/*.cpp))
PROTO_FILES                    := $(wildcard */*.proto)
PROTO_TRANSLATION_UNITS        := $(PROTO_FILES:.proto=.pb.cc)
PROTO_HEADERS                  := $(PROTO_FILES:.proto=.pb.h)

DEP_DIR := deps/

BIN_DIRECTORY := bin/
TOOLS_BIN     := $(BIN_DIRECTORY)tools

GMOCK_TRANSLATION_UNITS :=                     \
	$(DEP_DIR)googlemock/src/gmock-all.cc  \
	$(DEP_DIR)googlemock/src/gmock_main.cc \
	$(DEP_DIR)googletest/src/gtest-all.cc

VERSION_HEADER := base/version.generated.h

GENERATED_PROFILES :=                    \
	journal/profiles.generated.h     \
	journal/profiles.generated.cc    \
	journal/player.generated.cc      \
	ksp_plugin/interface.generated.h \
	ksp_plugin_adapter/interface.generated.cs

PROJECT_DIR := ksp_plugin_adapter/
SOLUTION_DIR := ./
ADAPTER_BUILD_DIR := ksp_plugin_adapter/obj
ADAPTER_CONFIGURATION := Release
FINAL_PRODUCTS_DIR := Release
ADAPTER := $(ADAPTER_BUILD_DIR)/$(ADAPTER_CONFIGURATION)/ksp_plugin_adapter.dll

LIB_DIR := $(FINAL_PRODUCTS_DIR)/GameData/Principia/Linux64
LIB := $(LIB_DIR)/principia.so
TEST_LIBS := $(DEP_DIR)benchmark/src/libbenchmark.a
LIBS      := $(DEP_DIR)/protobuf/src/.libs/libprotobuf.a $(DEP_DIR)/glog/.libs/libglog.a -lpthread -lc++ -lc++abi
TEST_INCLUDES := -I$(DEP_DIR)googlemock/include -I$(DEP_DIR)googletest/include -I$(DEP_DIR)googlemock/ -I$(DEP_DIR)googletest/ -I$(DEP_DIR)benchmark/include 
INCLUDES := -I. -I$(DEP_DIR)glog/src -I$(DEP_DIR)protobuf/src -I$(DEP_DIR)Optional -I$(DEP_DIR)eggsperimental_filesystem/
SHARED_ARGS := -std=c++14 -stdlib=libc++ -O3 -g -fPIC -fexceptions -ferror-limit=1 -fno-omit-frame-pointer -Wall -Wpedantic \
	-DPROJECT_DIR='std::experimental::filesystem::path("$(PROJECT_DIR)")'\
	-DSOLUTION_DIR='std::experimental::filesystem::path("$(SOLUTION_DIR)")' \
	-DNDEBUG

COMPILER_OPTIONS = -c $(SHARED_ARGS) $(INCLUDES)

# detect OS
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
    UNAME_M := $(shell uname -m)
    ifeq ($(UNAME_M),x86_64)
        SHARED_ARGS += -m64
    else
        SHARED_ARGS += -m32
    endif
    MDTOOL := mdtool
endif
ifeq ($(UNAME_S),Darwin)
    SHARED_ARGS += -mmacosx-version-min=10.7 -arch i386
    MDTOOL ?= "/Applications/Xamarin Studio.app/Contents/MacOS/mdtool"
endif

########## Dependency resolution

BUILD_DIRECTORY := build/

TEST_OR_MOCK_DEPENDENCIES := $(addprefix $(BUILD_DIRECTORY), $(TEST_OR_MOCK_TRANSLATION_UNITS:.cpp=.d))
TOOLS_DEPENDENCIES        := $(addprefix $(BUILD_DIRECTORY), $(TOOLS_TRANSLATION_UNITS:.cpp=.d))
LIBRARY_DEPENDENCIES      := $(addprefix $(BUILD_DIRECTORY), $(LIBRARY_TRANSLATION_UNITS:.cpp=.d))
PLUGIN_DEPENDENCIES       := $(addprefix $(BUILD_DIRECTORY), $(PLUGIN_TRANSLATION_UNITS:.cpp=.d))
PLUGIN_TEST_DEPENDENCIES  := $(addprefix $(BUILD_DIRECTORY), $(PLUGIN_TEST_TRANSLATION_UNITS:.cpp=.d))
JOURNAL_DEPENDENCIES      := $(addprefix $(BUILD_DIRECTORY), $(JOURNAL_TRANSLATION_UNITS:.cpp=.d))

# As a prerequisite for listing the includes of things that depend on
# generated headers, we must generate said code.
# Note that the prerequisites for dependency files are order-only, for
# bootstrapping: once we have the dependency files, their own actual dependency
# on generated headers and on the translation unit will be listed there and
# recomputed as needed.
$(PLUGIN_DEPENDENCIES)              : | $(GENERATED_PROFILES)
$(PLUGIN_TEST_DEPENDENCIES)         : | $(GENERATED_PROFILES)
$(JOURNAL_DEPENDENCIES)             : | $(GENERATED_PROFILES)

$(LIBRARY_DEPENDENCIES): $(BUILD_DIRECTORY)%.d: %.cpp | $(PROTO_HEADERS) $(VERSION_HEADER)
	@mkdir -p $(@D)
	$(CXX) -M $(COMPILER_OPTIONS) $< > $@.temp
	sed 's!.*\.o[ :]*!$(BUILD_DIRECTORY)$*.o $@ : !g' < $@.temp > $@
	rm -f $@.temp

$(TEST_OR_MOCK_DEPENDENCIES): $(BUILD_DIRECTORY)%.d: %.cpp | $(PROTO_HEADERS) $(VERSION_HEADER)
	@mkdir -p $(@D)
	$(CXX) -M $(COMPILER_OPTIONS) $(TEST_INCLUDES) $< > $@.temp
	sed 's!.*\.o[ :]*!$(BUILD_DIRECTORY)$*.o $@ : !g' < $@.temp > $@
	rm -f $@.temp

ifneq ($(MAKECMDGOALS),clean)
include $(LIBRARY_DEPENDENCIES)
include $(TEST_OR_MOCK_DEPENDENCIES)
endif

########## Compilation

##### C# and C++ code generation

$(VERSION_HEADER): .git
	./generate_version_header.sh

# We don't do dependency resolution on the protos; we compile them all at once.
$(PROTO_HEADERS) $(PROTO_TRANSLATION_UNITS): $(PROTO_FILES)
	$(DEP_DIR)/protobuf/src/protoc -I $(DEP_DIR)/protobuf/src/ -I . $^ --cpp_out=.

$(GENERATED_PROFILES) : $(TOOLS_BIN)
	$^ generate_profiles

##### C++ compilation

OBJ_DIRECTORY := obj/

TEST_OR_MOCK_OBJECTS := $(addprefix $(OBJ_DIRECTORY), $(TEST_OR_MOCK_TRANSLATION_UNITS:.cpp=.o))
LIBRARY_OBJECTS      := $(addprefix $(OBJ_DIRECTORY), $(LIBRARY_TRANSLATION_UNITS:.cpp=.o))
PROTO_OBJECTS        := $(addprefix $(OBJ_DIRECTORY), $(PROTO_TRANSLATION_UNITS:.cc=.o))
GMOCK_OBJECTS        := $(addprefix $(OBJ_DIRECTORY), $(GMOCK_TRANSLATION_UNITS:.cc=.o))
TOOLS_OBJECTS        := $(addprefix $(OBJ_DIRECTORY), $(TOOLS_TRANSLATION_UNITS:.cpp=.o))
PLUGIN_OBJECTS       := $(addprefix $(OBJ_DIRECTORY), $(PLUGIN_TRANSLATION_UNITS:.cpp=.o))
JOURNAL_LIB_OBJECTS  := $(addprefix $(OBJ_DIRECTORY), $(JOURNAL_LIB_TRANSLATION_UNITS:.cpp=.o))
BASE_LIB_OBJECTS     := $(addprefix $(OBJ_DIRECTORY), $(BASE_LIB_TRANSLATION_UNITS:.cpp=.o))
{'fraction_non_alphanumeric': 0.1589764094362255, 'fraction_numerical': 0.003198720511795282, 'mean_word_length': 4.795180722891566, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5019556', 'n_tokens_mistral': 4970, 'n_tokens_neox': 4659, 'n_words': 785}