Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 4, 2011, 2:47:44 AM (13 years ago)
Author:
rgrieder
Message:

Merged unity_build branch back to trunk.

Features:

  • Implemented fully automatic build units to speed up compilation if requested
  • Added DOUT macro for quick debug output
  • Activated text colouring in the POSIX IOConsole
  • DeclareToluaInterface is not necessary anymore

Improvements:

  • Output levels now change appropriately when switch back and forth from dev mode
  • Log level for the file output is now also correct during startup
  • Removed some header file dependencies in core and tools to speed up compilation

no more file for command line options

  • Improved util::tribool by adapting some concepts from boost::tribool

Regressions:

  • It is not possible anymore to specify command line arguments in an extra file because we've got config values for that purpose.
Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/cmake/tools/TargetUtilities.cmake

    r8421 r8729  
    4040 #      NO_INSTALL:        Do not install the target at all
    4141 #      NO_VERSION:        Prevents adding any version to a target
     42 #      NO_BUILD_UNITS:    Disables automatic (full) build units
    4243 #
    4344 #    Lists:
     
    5455 #      PCH_EXCLUDE:       Source files to be excluded from PCH support
    5556 #      OUTPUT_NAME:       If you want a different name than the target name
     57 #      EXCLUDE_FROM_BUILD_UNITS: Specifies files that are not put into
     58 #                         automatic (full) build units. They can still
     59 #                         explicitely be included in a BUILD_UNIT (partial)
    5660 #  Note:
    5761 #    This function also installs the target!
     
    6266 #
    6367
     68INCLUDE(BuildUnits)
    6469INCLUDE(CMakeDependentOption)
    6570INCLUDE(CapitaliseName)
     
    8792  SET(_switches   FIND_HEADER_FILES  EXCLUDE_FROM_ALL  ORXONOX_EXTERNAL
    8893                  NO_DLL_INTERFACE   NO_SOURCE_GROUPS  PCH_NO_DEFAULT
    89                   NO_INSTALL         NO_VERSION        ${_additional_switches})
     94                  NO_INSTALL         NO_VERSION        NO_BUILD_UNITS
     95                  ${_additional_switches})
    9096  SET(_list_names LINK_LIBRARIES     VERSION           SOURCE_FILES
    9197                  DEFINE_SYMBOL      TOLUA_FILES       PCH_FILE
    9298                  PCH_EXCLUDE        OUTPUT_NAME       LINK_LIBS_LINUX
    93                   LINK_LIBS_WIN32    LINK_LIBS_APPLE   LINK_LIBS_UNIX)
     99                  LINK_LIBS_WIN32    LINK_LIBS_APPLE   LINK_LIBS_UNIX
     100                  EXCLUDE_FROM_BUILD_UNITS)
    94101
    95102  PARSE_MACRO_ARGUMENTS("${_switches}" "${_list_names}" ${ARGN})
    96103
    97   # Process source files with support for compilations
     104  # Process source files with support for build units
    98105  # Note: All file paths are relative to the root source directory, even the
    99   #       name of the compilation file.
     106  #       name of the build unit.
    100107  SET(_${_target_name}_source_files)
    101   SET(_get_compilation_file FALSE)
    102   SET(_add_to_compilation FALSE)
     108  SET(_get_build_unit_file FALSE)
     109  SET(_add_to_build_unit FALSE)
    103110  FOREACH(_file ${_arg_SOURCE_FILES})
    104     IF(_file STREQUAL "COMPILATION_BEGIN")
    105       # Next file is the name of the compilation
    106       SET(_get_compilation_file TRUE)
    107     ELSEIF(_file STREQUAL "COMPILATION_END")
    108       IF(NOT _compilation_file)
    109         MESSAGE(FATAL_ERROR "No name provided for source file compilation")
    110       ENDIF()
    111       IF(NOT DISABLE_COMPILATIONS)
    112         IF(NOT _compilation_include_string)
    113           MESSAGE(STATUS "Warning: Empty source file compilation!")
    114         ENDIF()
    115         IF(EXISTS ${_compilation_file})
    116           FILE(READ ${_compilation_file} _include_string_file)
    117         ENDIF()
    118         IF(NOT _compilation_include_string STREQUAL "${_include_string_file}")
    119           FILE(WRITE ${_compilation_file} "${_compilation_include_string}")
    120         ENDIF()
    121         LIST(APPEND _${_target_name}_source_files ${_compilation_file})
    122       ENDIF()
    123       SET(_add_to_compilation FALSE)
    124     ELSEIF(_get_compilation_file)
    125       SET(_compilation_file ${CMAKE_BINARY_DIR}/${_file})
    126       SET(_get_compilation_file FALSE)
    127       SET(_add_to_compilation TRUE)
    128       SET(_compilation_include_string)
     111    IF(_file STREQUAL "BUILD_UNIT")
     112      # Next file is the name of the build unit
     113      SET(_get_build_unit_file TRUE)
     114    ELSEIF(_file STREQUAL "END_BUILD_UNIT")
     115      IF(NOT _build_unit_file)
     116        MESSAGE(FATAL_ERROR "No name provided for build unit")
     117      ENDIF()
     118      IF(ENABLE_BUILD_UNITS)
     119        IF(NOT _build_unit_include_string)
     120          MESSAGE(STATUS "Warning: Empty build unit!")
     121        ENDIF()
     122        IF(EXISTS ${_build_unit_file})
     123          FILE(READ ${_build_unit_file} _include_string_file)
     124        ENDIF()
     125        IF(NOT _build_unit_include_string STREQUAL "${_include_string_file}")
     126          FILE(WRITE ${_build_unit_file} "${_build_unit_include_string}")
     127        ENDIF()
     128        LIST(APPEND _${_target_name}_source_files ${_build_unit_file})
     129        LIST(APPEND _${_target_name}_build_units ${_build_unit_file})
     130        # Store the number of files included. May be used for full build units.
     131        SET_SOURCE_FILES_PROPERTIES(${_build_unit_file}
     132          PROPERTIES BUILD_UNIT_SIZE "${_build_unit_count}")
     133      ENDIF()
     134      SET(_add_to_build_unit FALSE)
     135    ELSEIF(_get_build_unit_file)
     136      # Note: ${_file} is relative to the binary directory
     137      SET(_build_unit_file ${CMAKE_BINARY_DIR}/${_file})
     138      SET(_get_build_unit_file FALSE)
     139      SET(_add_to_build_unit TRUE)
     140      SET(_build_unit_include_string)
     141      SET(_build_unit_count "0")
    129142    ELSE()
    130143      # Default, add source file
     
    146159      LIST(APPEND _${_target_name}_source_files ${_file})
    147160
    148       # Handle compilations
    149       IF(_add_to_compilation AND NOT DISABLE_COMPILATIONS)
     161      # Handle build units
     162      IF(_add_to_build_unit AND ENABLE_BUILD_UNITS)
    150163        IF(_file MATCHES "\\.(c|cc|cpp|cxx)$")
    151           SET(_compilation_include_string "${_compilation_include_string}#include \"${_file}\"\n")
     164          SET(_build_unit_include_string "${_build_unit_include_string}#include \"${_file}\"\n")
     165          MATH(EXPR _build_unit_count "1 + ${_build_unit_count}")
    152166        ENDIF()
    153167        # Don't compile these files, even if they are source files
     
    183197  ENDIF()
    184198
     199  # Mark files to be excluded from build units
     200  IF(_arg_EXCLUDE_FROM_BUILD_UNITS)
     201    SET_SOURCE_FILES_PROPERTIES(${_arg_EXCLUDE_FROM_BUILD_UNITS}
     202      PROPERTIES EXCLUDE_FROM_BUILD_UNITS TRUE)
     203  ENDIF()
     204
     205  # Full build units
     206  IF(ENABLE_BUILD_UNITS AND NOT _arg_NO_BUILD_UNITS)
     207    # Use full build units even in partial mode for externals
     208    IF(ENABLE_BUILD_UNITS MATCHES "full" OR _arg_ORXONOX_EXTERNAL)
     209      GENERATE_BUILD_UNITS(${_target_name} _${_target_name}_files)
     210    ENDIF()
     211  ENDIF()
     212
    185213  # First part (pre target) of precompiled header files
    186214  IF(PCH_COMPILER_SUPPORT AND _arg_PCH_FILE)
     
    196224    MARK_AS_ADVANCED(PCH_ENABLE_${_target_name_upper})
    197225
    198     IF(PCH_ENABLE_${_target_name_upper})
     226    IF(PCH_ENABLE_${_target_name_upper} AND NOT PCH_DISABLE_${_target_name})
    199227      PRECOMPILED_HEADER_FILES_PRE_TARGET(${_target_name} ${_arg_PCH_FILE} _${_target_name}_files EXCLUDE ${_arg_PCH_EXCLUDE})
    200228    ENDIF()
     
    344372
    345373  # Second part of precompiled header files
    346   IF(PCH_COMPILER_SUPPORT AND PCH_ENABLE_${_target_name_upper} AND _arg_PCH_FILE)
     374  IF(PCH_COMPILER_SUPPORT AND PCH_ENABLE_${_target_name_upper} AND _arg_PCH_FILE AND NOT PCH_DISABLE_${_target_name})
    347375    PRECOMPILED_HEADER_FILES_POST_TARGET(${_target_name} ${_arg_PCH_FILE})
    348376  ENDIF()
Note: See TracChangeset for help on using the changeset viewer.