From af4a3428a6e7ec3225f018db281ab5f79d6ae409 Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 18 Mar 2016 23:11:11 -0400 Subject: [PATCH] Split DataStaticsFields into multiple compilation units --- library/CMakeLists.txt | 24 ++++++++++++++++++++++-- library/DataStaticsFields.cpp | 8 ++++---- library/DataStaticsFields/.gitignore | 2 ++ library/xml | 2 +- 4 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 library/DataStaticsFields/.gitignore diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 5071d9e71..54300ec8d 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -165,6 +165,26 @@ modules/Once.cpp modules/Filesystem.cpp ) +SET(STATIC_FIELDS_FILES) +FOREACH(GROUP other a b c d e f g h i j k l m n o p q r s t u v w x y z) + SET(STATIC_FIELDS_FILENAME ${dfhack_SOURCE_DIR}/library/DataStaticsFields/${GROUP}.cpp) + IF(${GROUP} STREQUAL "other") + SET(STATIC_FIELDS_INC_FILENAME "df/static.fields.inc") + ELSE() + SET(STATIC_FIELDS_INC_FILENAME "df/static.fields-${GROUP}.inc") + ENDIF() + FILE(WRITE ${STATIC_FIELDS_FILENAME}.tmp + "#define STATIC_FIELDS_GROUP\n" + "#include \"../DataStaticsFields.cpp\"\n" + "#include \"${STATIC_FIELDS_INC_FILENAME}\"\n" + ) + EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${STATIC_FIELDS_FILENAME}.tmp ${STATIC_FIELDS_FILENAME}) + FILE(REMOVE ${STATIC_FIELDS_FILENAME}.tmp) + LIST(APPEND STATIC_FIELDS_FILES ${STATIC_FIELDS_FILENAME}) +ENDFOREACH() +LIST(APPEND MAIN_SOURCES ${STATIC_FIELDS_FILES}) + IF(WIN32) SOURCE_GROUP("Modules\\Headers" FILES ${MODULE_HEADERS}) SOURCE_GROUP("Modules\\Sources" FILES ${MODULE_SOURCES}) @@ -231,10 +251,10 @@ ADD_CUSTOM_TARGET(generate_headers DEPENDS ${dfapi_SOURCE_DIR}/include/df/codege IF(UNIX) # Don't produce debug info for generated stubs - SET_SOURCE_FILES_PROPERTIES(DataStatics.cpp DataStaticsCtor.cpp DataStaticsFields.cpp + SET_SOURCE_FILES_PROPERTIES(DataStatics.cpp DataStaticsCtor.cpp DataStaticsFields.cpp ${STATIC_FIELDS_FILES} PROPERTIES COMPILE_FLAGS "-g0 -O1") ELSE(WIN32) - SET_SOURCE_FILES_PROPERTIES(DataStatics.cpp DataStaticsCtor.cpp DataStaticsFields.cpp + SET_SOURCE_FILES_PROPERTIES(DataStatics.cpp DataStaticsCtor.cpp DataStaticsFields.cpp ${STATIC_FIELDS_FILES} PROPERTIES COMPILE_FLAGS "/O1 /bigobj") ENDIF() diff --git a/library/DataStaticsFields.cpp b/library/DataStaticsFields.cpp index 4d8decbed..583e4d6a4 100644 --- a/library/DataStaticsFields.cpp +++ b/library/DataStaticsFields.cpp @@ -3,9 +3,11 @@ #include "MiscUtils.h" #include "VersionInfo.h" +#ifndef STATIC_FIELDS_GROUP #include "df/world.h" #include "df/world_data.h" #include "df/ui.h" +#endif #include "DataIdentity.h" #include "DataFuncs.h" @@ -18,6 +20,7 @@ namespace df { #define NUMBER_IDENTITY_TRAITS(type) \ number_identity identity_traits::identity(#type); +#ifndef STATIC_FIELDS_GROUP NUMBER_IDENTITY_TRAITS(char); NUMBER_IDENTITY_TRAITS(int8_t); NUMBER_IDENTITY_TRAITS(uint8_t); @@ -48,7 +51,7 @@ namespace df { sizeof(std::fstream), fstream_allocator_fn, "fstream"); buffer_container_identity buffer_container_identity::base_instance; - +#endif #undef NUMBER_IDENTITY_TRAITS } @@ -58,6 +61,3 @@ namespace df { #define GFLD(mode, name) struct_field_info::mode, #name, (size_t)&df::global::name #define METHOD(mode, name) struct_field_info::mode, #name, 0, wrap_function(&CUR_STRUCT::name) #define FLD_END struct_field_info::END - -// Field definitions -#include "df/static.fields.inc" diff --git a/library/DataStaticsFields/.gitignore b/library/DataStaticsFields/.gitignore new file mode 100644 index 000000000..911aa3bb6 --- /dev/null +++ b/library/DataStaticsFields/.gitignore @@ -0,0 +1,2 @@ +*.cpp +*.tmp diff --git a/library/xml b/library/xml index 90645ebd8..0063c03e4 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 90645ebd8e8433196d695a478e3d6c9a32add21d +Subproject commit 0063c03e400443ab6076e2a5388126e90e541762