widelands-cvs Mailing List for Widelands
Status: Beta
Brought to you by:
sirver
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(11) |
Jun
(4) |
Jul
(77) |
Aug
(249) |
Sep
(214) |
Oct
(21) |
Nov
(15) |
Dec
(551) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(116) |
Feb
|
Mar
(4) |
Apr
(10) |
May
(2) |
Jun
(237) |
Jul
(38) |
Aug
(5) |
Sep
(2) |
Oct
(4) |
Nov
(325) |
Dec
(337) |
2006 |
Jan
(67) |
Feb
(71) |
Mar
(21) |
Apr
(40) |
May
(204) |
Jun
(320) |
Jul
(10) |
Aug
(5) |
Sep
(348) |
Oct
(83) |
Nov
(90) |
Dec
(53) |
2007 |
Jan
(95) |
Feb
(91) |
Mar
(86) |
Apr
(83) |
May
(48) |
Jun
(39) |
Jul
(24) |
Aug
(212) |
Sep
(193) |
Oct
(50) |
Nov
(4) |
Dec
(2) |
2008 |
Jan
(64) |
Feb
(39) |
Mar
(222) |
Apr
(47) |
May
(1) |
Jun
(17) |
Jul
(27) |
Aug
(59) |
Sep
(22) |
Oct
(143) |
Nov
(111) |
Dec
(72) |
2009 |
Jan
(13) |
Feb
(7) |
Mar
(88) |
Apr
(211) |
May
(235) |
Jun
(145) |
Jul
(108) |
Aug
(49) |
Sep
(96) |
Oct
(10) |
Nov
(136) |
Dec
(87) |
2010 |
Jan
(200) |
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <qc...@us...> - 2010-02-05 01:13:28
|
Revision: 5030 http://widelands.svn.sourceforge.net/widelands/?rev=5030&view=rev Author: qcs Date: 2010-02-05 01:13:20 +0000 (Fri, 05 Feb 2010) Log Message: ----------- Manual merge of cmake-migration branch to trunk Added Paths: ----------- trunk/CMakeLists.txt trunk/cmake/ trunk/cmake/Modules/ trunk/cmake/Modules/FindSDL.cmake trunk/cmake/Modules/FindSDL_gfx.cmake trunk/cmake/Modules/Findintl.cmake trunk/cmake/codecheck/ trunk/cmake/codecheck/CodeCheck.py trunk/cmake/codecheck/SConscript trunk/cmake/codecheck/__init__.py trunk/cmake/codecheck/rules/ trunk/cmake/codecheck/rules/SDL_integer_types_in_non_SDL_dependent_code trunk/cmake/codecheck/rules/assert0 trunk/cmake/codecheck/rules/const_qualifier_for_parameter_passed_by_value trunk/cmake/codecheck/rules/const_std_string_by_value trunk/cmake/codecheck/rules/const_without_effect_in_cast trunk/cmake/codecheck/rules/contrived_access_to_last_element trunk/cmake/codecheck/rules/contrived_dereference_and_member_selection trunk/cmake/codecheck/rules/contrived_std_string_find trunk/cmake/codecheck/rules/contrived_std_string_find_first_last_of trunk/cmake/codecheck/rules/deprecated_c_header trunk/cmake/codecheck/rules/explicit_compare_with_boolean_constant trunk/cmake/codecheck/rules/explicit_this_dereference_and_component_selection trunk/cmake/codecheck/rules/function_returning_constant_value trunk/cmake/codecheck/rules/garbage_after_include trunk/cmake/codecheck/rules/illegal_character_after_closing_brace trunk/cmake/codecheck/rules/illegal_character_after_semicolon trunk/cmake/codecheck/rules/illegal_character_before_opening_brace trunk/cmake/codecheck/rules/illegal_space_after_opening_brace trunk/cmake/codecheck/rules/illegal_space_after_opening_bracket trunk/cmake/codecheck/rules/illegal_space_after_opening_parenthesis trunk/cmake/codecheck/rules/illegal_space_before trunk/cmake/codecheck/rules/illegal_token_after_closing_parenthesis_opened_on_earlier_line trunk/cmake/codecheck/rules/leading_whitespace_check trunk/cmake/codecheck/rules/line_starting_with_space_followed_by_control_structure trunk/cmake/codecheck/rules/local_inlude_with_dir trunk/cmake/codecheck/rules/long_line trunk/cmake/codecheck/rules/loop_with_numerical_constant_condition trunk/cmake/codecheck/rules/missing_newline_at_eof trunk/cmake/codecheck/rules/missing_padding trunk/cmake/codecheck/rules/missing_space_after_access_type_symbol trunk/cmake/codecheck/rules/missing_space_after_comma trunk/cmake/codecheck/rules/missing_space_after_control_structure_keyword trunk/cmake/codecheck/rules/misused_tab trunk/cmake/codecheck/rules/multiline_single-statement-controlling_control-statement_not_wrapped_before_controlled_statement trunk/cmake/codecheck/rules/old-style_cast trunk/cmake/codecheck/rules/parenthesis_not_closed_before_end_of_line trunk/cmake/codecheck/rules/snprintf_with_literal_length trunk/cmake/codecheck/rules/space_as_indentation trunk/cmake/codecheck/rules/std_string_replace_replaces_single_character trunk/cmake/codecheck/rules/std_string_substr_compare trunk/cmake/codecheck/rules/testing_not_size trunk/cmake/codecheck/rules/trailing_whitespace trunk/cmake/codecheck/rules/upcast_without_macro trunk/cmake/codecheck/rules/using_macro_TRUE_FALSE trunk/cmake/codecheck/rules/void_parameter_list trunk/cmake/codecheck/run_tests.py trunk/doc/Doxyfile.in trunk/pics/CMakeLists.txt trunk/src/CMakeLists.txt trunk/src/ai/CMakeLists.txt trunk/src/build_info.cc.cmake trunk/src/config.h.cmake trunk/src/economy/CMakeLists.txt trunk/src/editor/CMakeLists.txt trunk/src/editor/tools/CMakeLists.txt trunk/src/editor/ui_menus/CMakeLists.txt trunk/src/events/CMakeLists.txt trunk/src/game_io/CMakeLists.txt trunk/src/graphic/CMakeLists.txt trunk/src/io/CMakeLists.txt trunk/src/io/filesystem/CMakeLists.txt trunk/src/logic/CMakeLists.txt trunk/src/map_io/CMakeLists.txt trunk/src/network/CMakeLists.txt trunk/src/network/game_server/CMakeLists.txt trunk/src/profile/CMakeLists.txt trunk/src/scripting/CMakeLists.txt trunk/src/sound/CMakeLists.txt trunk/src/trigger/CMakeLists.txt trunk/src/ui_basic/CMakeLists.txt trunk/src/ui_fsmenu/CMakeLists.txt trunk/src/wui/CMakeLists.txt Added: trunk/CMakeLists.txt =================================================================== --- trunk/CMakeLists.txt (rev 0) +++ trunk/CMakeLists.txt 2010-02-05 01:13:20 UTC (rev 5030) @@ -0,0 +1,172 @@ +project (widelands) + +# possible configurations: +# set them via cmake -DVARIABLE=VALUE +# CMAKE_BUILD_TYPE: +# Default is "Debug", Distributors should use "Release" +# WL_VERSION_MAJOR, WL_VERSION_MINOR (, WL_VERSION_PATCH): +# Default is using SVN revision, Distributors should use correct version +# Attention: We are currently only using MAJOR and MINOR. +# If you try to set WL_VERSION directly, it will ignore your setting. + +cmake_minimum_required (VERSION 2.6) +set (CMAKE_CONFIGURATION_TYPES Debug|Release) + +if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) + message(FATAL_ERROR "Build-directory and source-directory are the same!") +endif (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) + +SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) + +if (NOT DEFINED CMAKE_BUILD_TYPE) + set (CMAKE_BUILD_TYPE Debug) +endif (NOT DEFINED CMAKE_BUILD_TYPE) + +# we don't want someone to set this directly... +unset (WL_VERSION CACHE) + +# ...but using MAJOR, MINOR and PATCH +# (BUT: we only use MAJOR and MINOR for the moment; PATCH is set to 0) +if (DEFINED WL_VERSION_MAJOR) + set (WL_VERSION ${WL_VERSION_MAJOR}) + set (CPACK_PACKAGE_VERSION_MAJOR ${WL_VERSION_MAJOR}) + if (DEFINED WL_VERSION_MINOR) + set (WL_VERSION ${WL_VERSION}.${WL_VERSION_MINOR}) + set (CPACK_PACKAGE_VERSION_MINOR ${WL_VERSION_MINOR}) + if (DEFINED WL_VERSION_PATCH) + set (WL_VERSION ${WL_VERSION}.${WL_VERSION_PATCH}) + set (CPACK_PACKAGE_VERSION_PATCH ${WL_VERSION_PATCH}) + else (DEFINED WL_VERSION_PATCH) + set (CPACK_PACKAGE_VERSION_PATCH 0) + endif (DEFINED WL_VERSION_PATCH) + else (DEFINED WL_VERSION_MINOR) + set (CPACK_PACKAGE_VERSION_MINOR 0) + endif (DEFINED WL_VERSION_MINOR) +endif (DEFINED WL_VERSION_MAJOR) + +if (NOT DEFINED WL_VERSION) + find_package (PythonInterp REQUIRED) + execute_process ( + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/utils/detect_revision.py + OUTPUT_VARIABLE WL_VERSION + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_STRIP_TRAILING_WHITESPACE + ) +endif (NOT DEFINED WL_VERSION) +message ("Version of Widelands Build is ${WL_VERSION}(${CMAKE_BUILD_TYPE})") + +set (WL_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) +set (WL_INSTALL_BINDIR ${WL_INSTALL_PREFIX}/bin/) +set (WL_INSTALL_DATADIR ${WL_INSTALL_PREFIX}/share/widelands/) +# is this needed? +set (WL_INSTALL_LOCALEDIR ${WL_INSTALL_DATADIR}/locale/) + +set (WL_SOURCE_CHECKER ${CMAKE_CURRENT_SOURCE_DIR}/cmake/codecheck/CodeCheck.py) + +include(CheckIncludeFile) + +set (BUILD_SHARED_LIBS OFF) +set (Boost_USE_STATIC_LIBS ON) +set (Boost_USE_MULTITHREADED ON) +find_package(Boost 1.35.0 REQUIRED) +include_directories(${Boost_INCLUDE_DIR}) +target_link_libraries(widelands ${Boost_LIBRARIES}) + +find_package(PNG REQUIRED) +include_directories(${PNG_INCLUDE_DIR}) + +find_package(JPEG REQUIRED) +include_directories(${JPEG_INCLUDE_DIR}) + +find_package(TIFF REQUIRED) +include_directories(${TIFF_INCLUDE_DIR}) + +find_package(ZLIB REQUIRED) +include_directories(${ZLIB_INCLUDE_DIR}) + +find_package(Lua51 REQUIRED) +include_directories(${LUA_INCLUDE_DIR}) + +if (APPLE) + find_package(intl REQUIRED) + include_directories(${INTL_INCLUDE_DIR}) +endif (APPLE) + +find_package(SDL REQUIRED) +include_directories(${SDL_INCLUDE_DIR}) + +find_package(SDL_image REQUIRED) +include_directories(${SDLIMAGE_INCLUDE_DIR}) + +find_package(SDL_mixer REQUIRED) +include_directories(${SDLMIXER_INCLUDE_DIR}) + +find_package(SDL_net REQUIRED) +include_directories(${SDLNET_INCLUDE_DIR}) + +find_package(SDL_ttf REQUIRED) +include_directories(${SDLTTF_INCLUDE_DIR}) + +find_package(SDL_gfx REQUIRED) +include_directories(${SDLGFX_INCLUDE_DIR}) + +find_package(Lua51 REQUIRED) +include_directories(${LUA_INCLUDE_DIR}) + +# TODO +if (CMAKE_BUILD_TYPE STREQUAL Debug) + find_package(Doxygen REQUIRED) + include(Documentation) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/sourcecode) + configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY IMMEDIATE) + add_custom_target(doc COMMAND ${DOXYGEN_EXECUTABLE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +endif() + +include_directories(src ${CMAKE_CURRENT_BINARY_DIR}/src) + +#configure_file (src/config.h.cmake src/config.h) +#configure_file (src/build_info.cc.cmake src/build_info.cc) + +#add_subdirectory(po) +add_subdirectory(pics) +add_subdirectory(src) + +# install files to the correct locations here +install( + DIRECTORY + campaigns + fonts + global + maps + music + pics + sound + tribes + txts + worlds + po +# locale + DESTINATION share/widelands + CONFIGURATIONS Debug|Release + COMPONENT CoreDataFiles + PATTERN "*.svn*" EXCLUDE + PATTERN "SCons*" EXCLUDE +) + +#if (CMAKE_BUILD_TYPE STREQUAL Debug) + install( + DIRECTORY + doc + DESTINATION share/widelands + CONFIGURATIONS Debug + COMPONENT DocFiles + PATTERN "*.svn*" EXCLUDE + PATTERN "SCons*" EXCLUDE + ) +#endif() + +set (CPACK_PACKAGE_FILE_NAME widelands-${WL_VERSION}) +set (CPACK_COMPONENTS_ALL ExecutableFiles CoreDataFiles DocFiles) +set (CPACK_GENERATOR TGZ) +set (CPACK_SOURCE_GENERATOR TGZ) +include(CPack) Property changes on: trunk/CMakeLists.txt ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/cmake/Modules/FindSDL.cmake =================================================================== --- trunk/cmake/Modules/FindSDL.cmake (rev 0) +++ trunk/cmake/Modules/FindSDL.cmake 2010-02-05 01:13:20 UTC (rev 5030) @@ -0,0 +1,186 @@ +# Locate SDL library +# This module defines +# SDL_LIBRARY, the name of the library to link against +# SDL_FOUND, if false, do not try to link to SDL +# SDL_INCLUDE_DIR, where to find SDL.h +# +# This module responds to the the flag: +# SDL_BUILDING_LIBRARY +# If this is defined, then no SDL_main will be linked in because +# only applications need main(). +# Otherwise, it is assumed you are building an application and this +# module will attempt to locate and set the the proper link flags +# as part of the returned SDL_LIBRARY variable. +# +# Don't forget to include SDLmain.h and SDLmain.m your project for the +# OS X framework based version. (Other versions link to -lSDLmain which +# this module will try to find on your behalf.) Also for OS X, this +# module will automatically add the -framework Cocoa on your behalf. +# +# +# Additional Note: If you see an empty SDL_LIBRARY_TEMP in your configuration +# and no SDL_LIBRARY, it means CMake did not find your SDL library +# (SDL.dll, libsdl.so, SDL.framework, etc). +# Set SDL_LIBRARY_TEMP to point to your SDL library, and configure again. +# Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this value +# as appropriate. These values are used to generate the final SDL_LIBRARY +# variable, but when these values are unset, SDL_LIBRARY does not get created. +# +# +# $SDLDIR is an environment variable that would +# correspond to the ./configure --prefix=$SDLDIR +# used in building SDL. +# l.e.galup 9-20-02 +# +# Modified by Eric Wing. +# Added code to assist with automated building by using environmental variables +# and providing a more controlled/consistent search behavior. +# Added new modifications to recognize OS X frameworks and +# additional Unix paths (FreeBSD, etc). +# Also corrected the header search path to follow "proper" SDL guidelines. +# Added a search for SDLmain which is needed by some platforms. +# Added a search for threads which is needed by some platforms. +# Added needed compile switches for MinGW. +# +# On OSX, this will prefer the Framework version (if found) over others. +# People will have to manually change the cache values of +# SDL_LIBRARY to override this selection or set the CMake environment +# CMAKE_INCLUDE_PATH to modify the search paths. +# +# Note that the header path has changed from SDL/SDL.h to just SDL.h +# This needed to change because "proper" SDL convention +# is #include "SDL.h", not <SDL/SDL.h>. This is done for portability +# reasons because not all systems place things in SDL/ (see FreeBSD). + +#============================================================================= +# Copyright 2003-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distributed this file outside of CMake, substitute the full +# License text for the above reference.) + +FIND_PATH(SDL_INCLUDE_DIR SDL.h + HINTS + $ENV{SDLDIR} + PATH_SUFFIXES include/SDL include + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local/include/SDL12 + /usr/local/include/SDL11 # FreeBSD ports + /usr/include/SDL12 + /usr/include/SDL11 + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + C:/MinGW #Win32 +) +#MESSAGE("SDL_INCLUDE_DIR is ${SDL_INCLUDE_DIR}") + +# SDL-1.1 is the name used by FreeBSD ports... +# don't confuse it for the version number. +FIND_LIBRARY(SDL_LIBRARY_TEMP + NAMES SDL SDL-1.1 + HINTS + $ENV{SDLDIR} + PATH_SUFFIXES lib64 lib + PATHS + /sw + /opt/local + /opt/csw + /opt + C:/MinGW +) + +#MESSAGE("SDL_LIBRARY_TEMP is ${SDL_LIBRARY_TEMP}") + +IF(NOT ${SDL_INCLUDE_DIR} MATCHES ".framework") +# Non-OS X framework versions expect you to also dynamically link to +# SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms +# seem to provide SDLmain for compatibility even though they don't +# necessarily need it. +FIND_LIBRARY(SDLMAIN_LIBRARY + NAMES SDLmain SDLmain-1.1 + HINTS + $ENV{SDLDIR} + PATH_SUFFIXES lib64 lib + PATHS + /sw + /opt/local + /opt/csw + /opt + C:/MinGW +) +ENDIF(NOT ${SDL_INCLUDE_DIR} MATCHES ".framework") + +MESSAGE("SDLMAIN_LIBRARY is ${SDLMAIN_LIBRARY}") + + +# SDL may require threads on your system. +# The Apple build may not need an explicit flag because one of the +# frameworks may already provide it. +# But for non-OSX systems, I will use the CMake Threads package. +IF(NOT APPLE) + FIND_PACKAGE(Threads) +ENDIF(NOT APPLE) + +# MinGW needs an additional library, mwindows +# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows +# (Actually on second look, I think it only needs one of the m* libraries.) +IF(MINGW) + SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW") +ENDIF(MINGW) + +SET(SDL_FOUND "NO") +IF(SDL_LIBRARY_TEMP) + # For SDLmain + IF(NOT SDL_BUILDING_LIBRARY) + IF(SDLMAIN_LIBRARY) + SET(SDL_LIBRARY_TEMP ${SDLMAIN_LIBRARY} ${SDL_LIBRARY_TEMP}) + ENDIF(SDLMAIN_LIBRARY) + ENDIF(NOT SDL_BUILDING_LIBRARY) + + # For OS X, SDL uses Cocoa as a backend so it must link to Cocoa. + # CMake doesn't display the -framework Cocoa string in the UI even + # though it actually is there if I modify a pre-used variable. + # I think it has something to do with the CACHE STRING. + # So I use a temporary variable until the end so I can set the + # "real" variable in one-shot. + IF(APPLE) + SET(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} "-framework Cocoa") + ENDIF(APPLE) + + # For threads, as mentioned Apple doesn't need this. + # In fact, there seems to be a problem if I used the Threads package + # and try using this line, so I'm just skipping it entirely for OS X. + IF(NOT APPLE) + SET(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT}) + ENDIF(NOT APPLE) + + # For MinGW library + IF(MINGW) + SET(SDL_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL_LIBRARY_TEMP}) + ENDIF(MINGW) + + # Set the final string here so the GUI reflects the final state. + SET(SDL_LIBRARY ${SDL_LIBRARY_TEMP} CACHE STRING "Where the SDL Library can be found") + # Set the temp variable to INTERNAL so it is not seen in the CMake GUI + SET(SDL_LIBRARY_TEMP "${SDL_LIBRARY_TEMP}" CACHE INTERNAL "") + IF(NOT SDLMAIN_LIBRARY) + IF(WIN32) + MESSAGE(FATAL_ERROR "$Could NOT find SDL (missing: SDLmain)") + ENDIF(WIN32) + ENDIF(NOT SDLMAIN_LIBRARY) + + SET(SDL_FOUND "YES") +ENDIF(SDL_LIBRARY_TEMP) + +#MESSAGE("SDL_LIBRARY is ${SDL_LIBRARY}") + Property changes on: trunk/cmake/Modules/FindSDL.cmake ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/cmake/Modules/FindSDL_gfx.cmake =================================================================== --- trunk/cmake/Modules/FindSDL_gfx.cmake (rev 0) +++ trunk/cmake/Modules/FindSDL_gfx.cmake 2010-02-05 01:13:20 UTC (rev 5030) @@ -0,0 +1,64 @@ +# Locate SDL_gfx library +# This module defines +# SDLGFX_LIBRARY, the name of the library to link against +# SDLGFX_FOUND, if false, do not try to link to SDL +# SDLGFX_INCLUDE_DIR, where to find SDL/SDL.h +# +# $SDLDIR is an environment variable that would +# correspond to the ./configure --prefix=$SDLDIR +# used in building SDL. +# +# Created by Eric Wing. This was influenced by the FindSDL.cmake +# module, but with modifications to recognize OS X frameworks and +# additional Unix paths (FreeBSD, etc). + +FIND_PATH(SDLGFX_INCLUDE_DIR SDL_framerate.h SDL_gfxBlitFunc.h + SDL_gfxPrimitives.h SDL_gfxPrimitives_font.h + SDL_imageFilter.h SDL_rotozoom.h + HINTS + $ENV{SDLGFXDIR} + $ENV{SDLDIR} + PATH_SUFFIXES include + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local/include/SDL + /usr/include/SDL + /usr/local/include/SDL12 + /usr/local/include/SDL11 # FreeBSD ports + /usr/include/SDL12 + /usr/include/SDL11 + /usr/local/include + /usr/include + /sw/include/SDL # Fink + /sw/include + /opt/local/include/SDL # DarwinPorts + /opt/local/include + /opt/csw/include/SDL # Blastwave + /opt/csw/include + /opt/include/SDL + /opt/include +) + +FIND_LIBRARY(SDLGFX_LIBRARY + NAMES SDL_gfx + HINTS + $ENV{SDLGFXDIR} + $ENV{SDLDIR} + PATH_SUFFIXES lib64 lib + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw + /opt/local + /opt/csw + /opt +) + +SET(SDLGFX_FOUND "NO") +IF(SDLGFX_LIBRARY AND SDLGFX_INCLUDE_DIR) + SET(SDLGFX_FOUND "YES") +ENDIF(SDLGFX_LIBRARY AND SDLGFX_INCLUDE_DIR) + Property changes on: trunk/cmake/Modules/FindSDL_gfx.cmake ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/cmake/Modules/Findintl.cmake =================================================================== --- trunk/cmake/Modules/Findintl.cmake (rev 0) +++ trunk/cmake/Modules/Findintl.cmake 2010-02-05 01:13:20 UTC (rev 5030) @@ -0,0 +1,51 @@ +# Locate intl library +# This module defines +# INTL_LIBRARY, the name of the library to link against +# INTL_FOUND, if false, do not try to link to intl +# INTL_INCLUDE_DIR, where to find libintl.h +# +# $INTLDIR is an environment variable that would +# correspond to the ./configure --prefix=$INTLDIR +# used in building libintl. +# +# Created by Eric Wing. This was influenced by the FindSDL.cmake +# module, but with modifications to recognize OS X frameworks and +# additional Unix paths (FreeBSD, etc). + +FIND_PATH(INTL_INCLUDE_DIR libintl.h + HINTS + $ENV{INTLDIR} + $ENV{INTLDIR} + PATH_SUFFIXES include + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local/include + /usr/include + /sw/include + /opt/local/include + /opt/csw/include + /opt/include +) + +FIND_LIBRARY(INTL_LIBRARY + NAMES intl + HINTS + $ENV{INTLDIR} + PATH_SUFFIXES lib64 lib + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw + /opt/local + /opt/csw + /opt +) + +SET(INTL_FOUND "NO") +IF(INTL_LIBRARY AND INTL_INCLUDE_DIR) + SET(INTL_FOUND "YES") +ENDIF(INTL_LIBRARY AND INTL_INCLUDE_DIR) + Property changes on: trunk/cmake/Modules/Findintl.cmake ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/cmake/codecheck/CodeCheck.py =================================================================== --- trunk/cmake/codecheck/CodeCheck.py (rev 0) +++ trunk/cmake/codecheck/CodeCheck.py 2010-02-05 01:13:20 UTC (rev 5030) @@ -0,0 +1,376 @@ +#!/usr/bin/env python +# encoding: utf-8 +# + +""" +Yet another code checker for the widelands project. This one's intention is to get +rid of the ADA whitespace checker (while keeping it's functionality or improving on it) +and supersede the old detect_spurious_indentation.py script (while also keeping it's cases +around). En plus, we also replace the spurious code checking done with grep +which is currently also around. +""" + +from collections import defaultdict +from glob import glob +from time import time +import os +import re + +class Preprocessor(object): + """ + This class knows how to remove certain + strings from given lines + """ + _literal_strings = re.compile(r'''(?x) +".*? +( + (\\\\")| + ((?<!\\)") | # End of string +$) + ''') + _literal_chars = re.compile(r"'[\\]?.'") + + def __init__(self): + self._plain_cache = {} + self._stripped_comments_and_strings = {} + self._stripped_all = {} + + def _get_plain(self,fn,data): + if fn in self._plain_cache: + return self._plain_cache[fn] + + lines = data.splitlines(True) + self._plain_cache[fn] = lines + + return lines + + def _get_stripped_comments_and_strings(self,fn,lines): + """ + Strips all cstring literals from the text. String contents + are replace by spaces. + Removes comments from lines. Comments are completely + stripped, including // and /**/ symbols + """ + if fn in self._stripped_comments_and_strings: + return self._stripped_comments_and_strings[fn] + + in_comment = False + new_lines = [] + for line in lines: + # Strings are replaced with blanks + line = self._literal_chars.sub(lambda k: "'%s'" % ((len(k.group(0))-2)*" "),line) + line = self._literal_strings.sub(lambda k: '"%s"' % ((len(k.group(0))-2)*" "),line) + + # Strip comments and strings + # Multiline comments + start_idx = line.find('/*') + if not in_comment: + if start_idx != -1: + stop_idx = line.find("*/",start_idx+2) + if stop_idx != -1: + line = line[:start_idx] + line[stop_idx+2:] + else: + line = line[:start_idx].strip() + in_comment = True + + if in_comment: + stop_idx = line.find('*/') + if stop_idx == -1: + line = "" + else: + line = line[stop_idx+2:].strip() + in_comment = False + + # Single line comments + idx = line.find('//') + if idx != -1: + line = line[:idx].strip() + + new_lines.append( line ) + + self._stripped_comments_and_strings[fn] = new_lines + + return new_lines + + def _get_stripped_macros(self,fn,lines): + """ + Remove macros definitions. Also multiline macros. They are replaced with + empty lines + """ + if fn in self._stripped_all: + return self._stripped_all[fn] + + new_lines = [] + in_macro = False + for given_line in lines: + line = given_line + if in_macro or (len(given_line) and given_line[0] == '#'): + in_macro = True + line = "" + + if len(given_line) > 1 and given_line[-2] != '\\': + in_macro = False + + new_lines.append(line) + + self._stripped_all[fn] = new_lines + + return new_lines + + + def get_preprocessed_data(self,fn, data, strip_strings_and_comments, strip_macros): + """ + Return an array of lines where data has been stripped off + """ + if not strip_macros and not strip_strings_and_comments: + return self._get_plain(fn,data) + elif not strip_macros and strip_strings_and_comments: + return self._get_stripped_comments_and_strings(fn,self._get_plain(fn,data)) + elif strip_strings_and_comments and strip_macros: + return self._get_stripped_macros(fn,self._get_stripped_comments_and_strings(fn,self._get_plain(fn,data))) + + # Error checking, we should never be here + raise RuntimeError, "strip_macros can't be true when strip_strings_and_comments isn't!" + + +class CheckingRule(object): + """ + Represents one test to check the sourcecode for + """ + def __init__(self, name, vars ): + self.name = name + self._strip_comments_and_strings = vars.get('strip_comments_and_strings',False) + self._strip_macros = vars.get('strip_macros',False) + + self._evaluate_matches = vars.get('evaluate_matches',None) + + if self._evaluate_matches == None: + self._regexp = re.compile(vars["regexp"]) + self._error_msg = vars["error_msg"] + + def _to_tuple(a): + if isinstance(a,str): + return (a,) + else: + return tuple(a) + + self.allowed = _to_tuple(vars["allowed"]) + self.forbidden = _to_tuple(vars["forbidden"]) + + def check_text(self, preprocessor, fn, data): + """ + Data must be a complete file data as returned by .read() + + preprocessor - Tool to preprocess the text (strip it from unwanted tokens) + fn - File name of current file to check + data - File contents + """ + lines = preprocessor.get_preprocessed_data(fn,data,self._strip_comments_and_strings, self._strip_macros) + + matches = [] + if self._evaluate_matches is not None: + # Rule has it's own checking function + matches = self._evaluate_matches(lines,fn) + else: + # Regular expression rule + for lidx,line in enumerate(lines): + if self._regexp.search(line): + matches.append( (fn,lidx+1,self._error_msg) ) + + return matches + +################### +# Helper function # +################### +def _find_rule_files(): + """ + Searches the rules/ directory for rule files and returns + an array with them. + """ + p = os.path.dirname(__file__) + if not len(p): + p = "./" + rule_files = [ f for f in glob(p + '/rules/*') if os.path.isfile(f) ] + + return rule_files + +def _parse_rules(): + rule_files = _find_rule_files() + + checkers = [] + + for filename in rule_files: + variables = {} + execfile(filename,variables) + + rule = CheckingRule(os.path.basename(filename), variables) + checkers.append( rule ) + + return checkers + +ansicolor = { + "default" : '\033[0m', + + "black" : '\033[30m', + "red" : '\033[31m', + "green" : '\033[32m', + "yellow" : '\033[33m', + "blue" : '\033[34m', + "magenta" : '\033[35m', + "purple" : '\033[35m', + "cyan" : '\033[36m', + "white" : '\033[37m', + + "reset" : '\033[0;0m', + "bold" : '\033[1m', + + "blackbg" : '\033[40m', + "redbg" : '\033[41m', + "greenbg" : '\033[42m', + "yellowbg" : '\033[43m', + "bluebg" : '\033[44m', + "magentabg" : '\033[45m', + "cyanbg" : '\033[46m', + "whitebg" : '\033[47m', +} + +class CodeChecker(object): + _checkers = _parse_rules() + + def __init__(self, benchmark = False, color = False): + """ + benchmark - Run benchmarks on each rule. Print milliseconds after run + """ + self._benchmark = benchmark + self._color = color + + # We keep a cache of file names/error strings + # so that (e.g.) a header is requested twice in one + # run of the program, we just return the cached errors. + # They will not have changed while the program was running + self._cache = {} + + @property + def benchmark_results(self): + return self._bench_results + + def use_color(): + def fget(self): + return self._color + def fset(self, value): + self._color = value + return locals() + use_color = property(**use_color()) + + def _print_errors(self,errors): + output = "" + for e in errors: + fn,l,msg = e + if self._color: + fn = '%s%s%s' % (ansicolor["green"], fn, ansicolor["reset"]) + l = '%s%s%s' % (ansicolor["cyan"], l, ansicolor["reset"]) + msg = '%s%s%s%s' % (ansicolor["yellow"], ansicolor["bold"], msg, ansicolor["reset"]) + + output += "%s:%s: %s\n" % (fn,l,msg) + + print output.rstrip() + + return output + + def check_file(self,fn, print_errors = True): + if print_errors and fn in self._cache: + print self._cache[fn].rstrip() + return + errors = [] + + bm = defaultdict(lambda: 0.) + + preprocessor = Preprocessor() + + # Check line by line (currently) + data = open(fn).read() + for c in self._checkers: + if self._benchmark: + start = time() + e = c.check_text( preprocessor, fn, data ) + errors.extend( e ) + bm[c.name] += time()-start + else: + e = c.check_text( preprocessor, fn, data ) + errors.extend( e ) + + errors.sort(key=lambda a: a[1]) + + if len(errors) and print_errors: + self._cache[fn] = self._print_errors(errors) + + if self._benchmark: + self._bench_results = [ (v,k) for k,v in bm.items() ] + self._bench_results.sort(reverse=True) + + return errors + + +if __name__ == '__main__': + import sys + import os + import getopt + + def usage(): + print "Usage: %s <options> <files>" % os.path.basename(sys.argv[0]) + print """ + -h, --help Print help and exit + -c, --color Print warnings in color + -b, --benchmark Benchmark each rule + -p, --profile Run with cProfile. Creates "Profile.prof" file +""" + + def check_files(files,color,benchmark): + d = CodeChecker( benchmark = benchmark, color = color ) + for filename in files: + print "Checking %s ..." % filename + errors = d.check_file(filename) + + # Print benchmark results + if benchmark: + print + print "Benchmark results:" + + res = d.benchmark_results + ctime = sum( l[0] for l in res ) + + for time,n in res: + per = time/ctime * 100. + percentage = ("%.2f%%"% per).rjust(8) + time = ("%4.2fms"% (time*1000.)).rjust(8) + print "%s %s %s" % (percentage,time,n) + + def main(): + opts, files = getopt.getopt(sys.argv[1:], "hbcp", ["help", "benchmark","color", "colour", "profile"]) + + benchmark = False + color = False + profile = False + for o,a in opts: + if o in ('-h','--help'): + usage() + sys.exit(0) + if o in ('-b','--benchmark'): + benchmark = True + if o in ('-c','--colour','--color'): + color = True + if o in ('-p','--profile'): + profile = True + + if not len(files): + usage() + sys.exit(0) + + if profile: + import cProfile + cProfile.runctx("check_files(files,color,benchmark)",globals(),locals(),"Profile.prof") + else: + check_files(files,color,benchmark) + + main() + Property changes on: trunk/cmake/codecheck/CodeCheck.py ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/cmake/codecheck/SConscript =================================================================== --- trunk/cmake/codecheck/SConscript (rev 0) +++ trunk/cmake/codecheck/SConscript 2010-02-05 01:13:20 UTC (rev 5030) @@ -0,0 +1,8 @@ +Import('env') + +from Distribute import distadd + +distadd(env, 'build/scons-tools/codecheck/SConscript') +distadd(env, 'build/scons-tools/codecheck/*.py') +distadd(env, 'build/scons-tools/codecheck/rules') + Property changes on: trunk/cmake/codecheck/SConscript ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/cmake/codecheck/__init__.py ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/cmake/codecheck/rules/SDL_integer_types_in_non_SDL_dependent_code =================================================================== --- trunk/cmake/codecheck/rules/SDL_integer_types_in_non_SDL_dependent_code (rev 0) +++ trunk/cmake/codecheck/rules/SDL_integer_types_in_non_SDL_dependent_code 2010-02-05 01:13:20 UTC (rev 5030) @@ -0,0 +1,44 @@ +#!/usr/bin/python + + +""" +This catches use of SDL integer names ([SU]int(8|16|32|64))in places that +should not use them. They should only be used to interact with SDL code. C99 +integer names (u?int(8|16|32|64)_t) should be used elsewhere. +""" + +error_msg ="Do not use SDL types. Use c99 types (e.g. uint32_t)" + +regexp = r"""[SU]int(?:8|16|32|64)[^_].*(?:Uns|S)igned(?:8|16|32|64)""" + +forbidden = [ + 'Sint8 T::Unsigned64()', + 'Uint8 T:: Signed64()', + 'Sint16 T::Unsigned32()', + 'Uint16 T:: Signed32()', + 'Sint32 T::Unsigned16()', + 'Uint32 T:: Signed16()', + 'Sint64 T::Unsigned8 ()', + 'Uint64 T:: Signed8 ()', + 'Sint8 T:: Signed8 ()', + 'Uint8 T::Unsigned8 ()', + 'Sint16 T:: Signed16()', + 'Uint16 T::Unsigned16()', + 'Sint32 T:: Signed32()', + 'Uint32 T::Unsigned32()', + 'Sint64 T:: Signed64()', + 'Uint64 T::Unsigned64()', + 'Uint8 version = fr.Unsigned8();', +] + +allowed = [ + 'uint8_t', + 'int8_t', + 'uint16_t', + 'int16_t', + 'uint32_t', + 'int32_t', + 'uint64_t', + 'int64_t', + 'int8_t version = fr.Unsigned8();', +] Property changes on: trunk/cmake/codecheck/rules/SDL_integer_types_in_non_SDL_dependent_code ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/cmake/codecheck/rules/assert0 =================================================================== --- trunk/cmake/codecheck/rules/assert0 (rev 0) +++ trunk/cmake/codecheck/rules/assert0 2010-02-05 01:13:20 UTC (rev 5030) @@ -0,0 +1,21 @@ +#!/usr/bin/env python -tt +# encoding: utf-8 +# + +""" +The purpouse of this is simply to encourage the use "assert(false)" everywhere +when an unconditional assert is desired, for consistency, instead of +intermixing it with assert(0) here and there. +""" + +error_msg="Use assert(false) here." + +regexp = r"""assert *\( *0 *\)""" + +forbidden = [ + "assert(0)", +] + +allowed = [ + "assert(false)", +] Property changes on: trunk/cmake/codecheck/rules/assert0 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/cmake/codecheck/rules/const_qualifier_for_parameter_passed_by_value =================================================================== --- trunk/cmake/codecheck/rules/const_qualifier_for_parameter_passed_by_value (rev 0) +++ trunk/cmake/codecheck/rules/const_qualifier_for_parameter_passed_by_value 2010-02-05 01:13:20 UTC (rev 5030) @@ -0,0 +1,139 @@ +#!/usr/bin/python + +""" +This catches const qualifiers for parameters passed by value to functions, in +function declarations. Such qualifiers should only be in the definitions. It +will miss: +* declarations with complex type names (template types) or default value +* assignments, functions with things like __attribute__ and pointers with const +* qualifiers +""" + +error_msg = "'const' for a literal parameter makes no sense. Remove the const." + +regexp = r"""^\s*(?:(static|virtual) +)?(?:const +)?(?:[_a-zA-Z][_a-zA-Z0-9]*::)*[_a-zA-Z][_a-zA-Z0-9]*(?: +const)?(?: *(?:\*(?: *const)?|&))* +[_a-zA-Z][_a-zA-Z0-9]* *\((?:(const +)?(?:[_a-zA-Z][_a-zA-Z0-9]*::)*[_a-zA-Z][_a-zA-Z0-9]*(?: +const)?(?: *(?:\*(?: *const)?|&))*(?: +[_a-zA-Z][_a-zA-Z0-9]*)?, *)*(?:const +(?:[_a-zA-Z][_a-zA-Z0-9]*::)*[_a-zA-Z][_a-zA-Z0-9]*|(?:[_a-zA-Z][_a-zA-Z0-9]*::)*[_a-zA-Z][_a-zA-Z0-9]* +const)(?: +[_a-zA-Z][_a-zA-Z0-9]*)?(?:, *(?:const +)?(?:[_a-zA-Z][_a-zA-Z0-9]*::)*[_a-zA-Z][_a-zA-Z0-9]*(?: +const)?(?: *(?:\*(?: *const)?|&))*)*(?: +[_a-zA-Z][_a-zA-Z0-9]*)?(?:\)(?: *const)?(?: throw *\(.*\))?;|,$)""" + +forbidden = [ + " void truncate(int32_t const count);", + "void func(const Some_Type,", + "void func(const Some_Type);", + "void func(const Some_Type) const;", + "void func(const Some_Type) const throw (whatever);", + "void func(const Some_Type abc,", + "void func(const Some_Type abc);", + "void func(const Some_Type abc) const;", + "void func(std::string * const & * foo, const Some_Type,", + "void func(std::string * const & * foo, const Some_Type);", + "void func(std::string * const & * foo, const Some_Type) const;", + "void func(std::string * const & * foo, const Some_Type) const throw (whatever);", + "void func(std::string * const & * foo, const Some_Type abc,", + "void func(std::string * const & * foo, const Some_Type abc);", + "void func(std::string * const & * foo, const Some_Type abc) const;", + "void func(std::string * const & * ngi, const Some_Type, std::string * const & * foo,", + "void func(std::string * const & * ngi, const Some_Type, std::string * const & * foo);", + "void func(std::string * const & * ngi, const Some_Type, std::string * const & * foo) const;", + "void func(std::string * const & * ngi, const Some_Type, std::string * const & * foo) const throw (whatever);", + "void func(std::string * const & * ngi, const Some_Type abc, std::string * const & * foo,", + "void func(std::string * const & * ngi, const Some_Type abc, std::string * const & * foo);", + "void func(std::string * const & * ngi, const Some_Type abc, std::string * const & * foo) const;", + "void func(std::string * const & * ngi, const Some_Type, std::string * const & * foo,", + "void func(std::string * const & * ngi, const Some_Type, std::string * const & * foo);", + "void func(std::string * const & * ngi, const Some_Type, std::string * const & * foo) const;", + "void func(std::string * const & * ngi, const Some_Type, std::string * const & * foo) const throw (whatever);", + "void func(std::string * const & * ngi, const Some_Type abc, std::string * const & * foo,", + "void func(std::string * const & * ngi, const Some_Type abc, std::string * const & * foo);", + "void func(std::string * const & * ngi, const Some_Type abc, std::string * const & * foo) const;", + "void func(Some_Type const,", + "void func(Some_Type const);", + "void func(Some_Type const) const;", + "void func(Some_Type const) const throw (whatever);", + "void func(Some_Type const abc,", + "void func(Some_Type const abc);", + "void func(Some_Type const abc) const;", + "void func(std::string * const & * foo, Some_Type const,", + "void func(std::string * const & * foo, Some_Type const);", + "void func(std::string * const & * foo, Some_Type const) const;", + "void func(std::string * const & * foo, Some_Type const) const throw (whatever);", + "void func(std::string * const & * foo, Some_Type const abc,", + "void func(std::string * const & * foo, Some_Type const abc);", + "void func(std::string * const & * foo, Some_Type const abc) const;", + "void func(std::string * const & * ngi, Some_Type const, std::string * const & * foo,", + "void func(std::string * const & * ngi, Some_Type const, std::string * const & * foo);", + "void func(std::string * const & * ngi, Some_Type const, std::string * const & * foo) const;", + "void func(std::string * const & * ngi, Some_Type const, std::string * const & * foo) const throw (whatever);", + "void func(std::string * const & * ngi, Some_Type const abc, std::string * const & * foo,", + "void func(std::string * const & * ngi, Some_Type const abc, std::string * const & * foo);", + "void func(std::string * const & * ngi, Some_Type const abc, std::string * const & * foo) const;", + "void func(std::string * const & * ngi, Some_Type const, std::string * const & * foo,", + "void func(std::string * const & * ngi, Some_Type const, std::string * const & * foo);", + "void func(std::string * const & * ngi, Some_Type const, std::string * const & * foo) const;", + "void func(std::string * const & * ngi, Some_Type const, std::string * const & * foo) const throw (whatever);", + "void func(std::string * const & * ngi, Some_Type const abc, std::string * const & * foo,", + "void func(std::string * const & * ngi, Some_Type const abc, std::string * const & * foo);", + "void func(std::string * const & * ngi, Some_Type const abc, std::string * const & * foo) const;", + " virtual void func(const Some_Type,", + " virtual void * func(const Some_Type,", + " virtual std::string & func(const Some_Type,", +] + +allowed = [ + "void func(Some_Type,", + "void func(Some_Type);", + "void func(Some_Type) const;", + "void func(Some_Type) const throw (whatever);", + "void func(Some_Type abc,", + "void func(Some_Type abc);", + "void func(Some_Type abc) const;", + "void func(std::string * const & * foo, Some_Type,", + "void func(std::string * const & * foo, Some_Type);", + "void func(std::string * const & * foo, Some_Type) const;", + "void func(std::string * const & * foo, Some_Type) const throw (whatever);", + "void func(std::string * const & * foo, Some_Type abc,", + "void func(std::string * const & * foo, Some_Type abc);", + "void func(std::string * const & * foo, Some_Type abc) const;", + "void func(std::string * const & * ngi, Some_Type, std::string * const & * foo,", + "void func(std::string * const & * ngi, Some_Type, std::string * const & * foo);", + "void func(std::string * const & * ngi, Some_Type, std::string * const & * foo) const;", + "void func(std::string * const & * ngi, Some_Type, std::string * const & * foo) const throw (whatever);", + "void func(std::string * const & * ngi, Some_Type abc, std::string * const & * foo,", + "void func(std::string * const & * ngi, Some_Type abc, std::string * const & * foo);", + "void func(std::string * const & * ngi, Some_Type abc, std::string * const & * foo) const;", + "void func(std::string * const & * ngi, Some_Type, std::string * const & * foo,", + "void func(std::string * const & * ngi, Some_Type, std::string * const & * foo);", + "void func(std::string * const & * ngi, Some_Type, std::string * const & * foo) const;", + "void func(std::string * const & * ngi, Some_Type, std::string * const & * foo) const throw (whatever);", + "void func(std::string * const & * ngi, Some_Type abc, std::string * const & * foo,", + "void func(std::string * const & * ngi, Some_Type abc, std::string * const & * foo);", + "void func(std::string * const & * ngi, Some_Type abc, std::string * const & * foo) const;", + "void func(Some_Type,", + "void func(Some_Type);", + "void func(Some_Type) const;", + "void func(Some_Type) const throw (whatever);", + "void func(Some_Type abc,", + "void func(Some_Type abc);", + "void func(Some_Type abc) const;", + "void func(std::string * const & * foo, Some_Type,", + "void func(std::string * const & * foo, Some_Type);", + "void func(std::string * const & * foo, Some_Type) const;", + "void func(std::string * const & * foo, Some_Type) const throw (whatever);", + "void func(std::string * const & * foo, Some_Type abc,", + "void func(std::string * const & * foo, Some_Type abc);", + "void func(std::string * const & * foo, Some_Type abc) const;", + "void func(std::string * const & * ngi, Some_Type, std::string * const & * foo,", + "void func(std::string * const & * ngi, Some_Type, std::string * const & * foo);", + "void func(std::string * const & * ngi, Some_Type, std::string * const & * foo) const;", + "void func(std::string * const & * ngi, Some_Type, std::string * const & * foo) const throw (whatever);", + "void func(std::string * const & * ngi, Some_Type abc, std::string * const & * foo,", + "void func(std::string * const & * ngi, Some_Type abc, std::string * const & * foo);", + "void func(std::string * const & * ngi, Some_Type abc, std::string * const & * foo) const;", + "void func(std::string * const & * ngi, Some_Type, std::string * const & * foo,", + "void func(std::string * const & * ngi, Some_Type, std::string * const & * foo);", + "void func(std::string * const & * ngi, Some_Type, std::string * const & * foo) const;", + "void func(std::string * const & * ngi, Some_Type, std::string * const & * foo) const throw (whatever);", + "void func(std::string * const & * ngi, Some_Type abc, std::string * const & * foo,", + "void func(std::string * const & * ngi, Some_Type abc, std::string * const & * foo);", + "void func(std::string * const & * ngi, Some_Type abc, std::string * const & * foo) const;", + " virtual void func(Some_Type,", + " virtual void * func(Some_Type,", + " virtual std::string & func(Some_Type,", +] Property changes on: trunk/cmake/codecheck/rules/const_qualifier_for_parameter_passed_by_value ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/cmake/codecheck/rules/const_std_string_by_value =================================================================== --- trunk/cmake/codecheck/rules/const_std_string_by_value (rev 0) +++ trunk/cmake/codecheck/rules/const_std_string_by_value 2010-02-05 01:13:20 UTC (rev 5030) @@ -0,0 +1,40 @@ +#!/usr/bin/python + +""" +This catches std::string constants that are passed by value. They should be +passed by reference to avoid needless construction/destruction. +""" + +error_msg="const std::string must not be passed by value. Pass by reference!" + +regexp=r"""[\( ](?:const +std::string|std::string +const)(?: +[_a-zA-Z][_a-zA-Z0-9]*)?(?: *=.*)?(?:,(?: |$)|\))""" + +forbidden = [ + '(std::string const,', + ' std::string const abc,', + ' std::string const abc = "abc",', + ' std::string const = "abc",', + ' std::string const)', + '(const std::string,', + ' const std::string abc,', + ' const std::string abc = "abc",', + ' const std::string = "abc",', + ' const std::string)', +] + +allowed = [ + '(std::string const &,' + ' std::string const & abc,', + ' std::string const & = "abc",', + ' std::string const &)', + '(const std::string &,', + ' const std::string & abc,', + ' const std::string & = "abc",', + ' const std::string &)', + ' std::string const abc;', + ' std::string const abc = "abc";', + ' std::string const abc("abc");', + ' const std::string abc;', + ' const std::string abc = "abc";', + ' const std::string abc("abc");', +] Property changes on: trunk/cmake/codecheck/rules/const_std_string_by_value ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/cmake/codecheck/rules/const_without_effect_in_cast =================================================================== --- trunk/cmake/codecheck/rules/const_without_effect_in_cast (rev 0) +++ trunk/cmake/codecheck/rules/const_without_effect_in_cast 2010-02-05 01:13:20 UTC (rev 5030) @@ -0,0 +1,50 @@ +#!/usr/bin/python + +""" +These were added to find stuff that makes the code "even more annying to read" +for Nicolai. It detects uses of the const keyword inside casts, that have no +effect, such as "static_cast<const uint32_t>" or "dynamic_cast<T * const>". +""" + +error_msg = "Remove the unneeded 'const' from the cast!" + +regexp = r"""(?x) + _cast<\s* # '_cast<' + (( + const\s+ # 'const ' + [_a-zA-Z]\w+\s* # Match an identifier + whitespace + ( + (::)?\s* # :: + [_a-zA-Z]\w+\s* # Identifier + )* + > + )|( + [_a-zA-Z]\w+\s* # Identifier + ( + \**\s* # * + whitespace + const\s* + )+ + > + )) +""" + +forbidden = [ + '_cast< const fgh >', + '_cast< const fgh :: ser >', + '_cast< ghf * const >', + '_cast< ghf * const *const >', + '_cast< ghf const * const >', + '_cast< ghf const * const *const>', + '_cast< ghf**const>', +] + +allowed = [ + '<Editor_Player_Menu, Widelands::Player_Number const>', + '_cast< foo>', + '_cast< foo *>', + '_cast< const foo *>', + '_cast< foo const *>', + '_cast< foo const * const *>', + '_cast< foo const * const * const *>', + '_cast< foo const * * *>', +] Property changes on: trunk/cmake/codecheck/rules/const_without_effect_in_cast ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/cmake/codecheck/rules/contrived_access_to_last_element =================================================================== --- trunk/cmake/codecheck/rules/contrived_access_to_last_element (rev 0) +++ trunk/cmake/codecheck/rules/contrived_access_to_last_element 2010-02-05 01:13:20 UTC (rev 5030) @@ -0,0 +1,21 @@ +#!/usr/bin/python + + +""" +This catches clumsy expressions like + some_container[some_container.size() - 1] +which should be written as + *some_container.rbegin() +""" + +error_msg = "Simplify \"some_container[some_container.size() - 1];\" to \"*some_container.rbegin();\"." + +regexp = r"""(.*) *\[ *\\1 *\. *size *\( *\) *- *1 *\]""" + +forbidden = [ + "some_container[some_container.size() - 1];" +] + +allowed = [ + "*some_container.rbegin();" +] Property changes on: trunk/cmake/codecheck/rules/contrived_access_to_last_element ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/cmake/codecheck/rules/contrived_dereference_and_member_selection =================================================================== --- trunk/cmake/codecheck/rules/contrived_dereference_and_member_selection (rev 0) +++ trunk/cmake/codecheck/rules/contrived_dereference_and_member_selection 2010-02-05 01:13:20 UTC (rev 5030) @@ -0,0 +1,29 @@ +#!/usr/bin/python + + +""" +This catches use of the contrived syntax for dereference and member selection: +(*pointer).member + +Use the more convenient syntax instead: +pointer->member +""" + +error_msg = "Do not use (*a).member, use a->member." + +regexp = r"""[^]_A-Za-z0-9 >] *\(\*[a-zA-Z_][_a-zA-Z_]*\)\.""" + +forbidden = [ + '+ (*abc).def', + '* (*abc).def', + '/ ((*abc).def)', +] + +allowed = [ + 'abc->def', + '_cast<T>(*abc).def', + '_cast<T> (*abc).def', + 'operator [] (*p).jkl', + 'QString("%1 %2").arg(*it).arg(8)', + 'some_string.arg(*it).arg(8)', +] Property changes on: trunk/cmake/codecheck/rules/contrived_dereference_and_member_selection ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/cmake/codecheck/rules/contrived_std_string_find =================================================================== --- trunk/cmake/codecheck/rules/contrived_std_string_find (rev 0) +++ trunk/cmake/codecheck/rules/contrived_std_string_find 2010-02-05 01:13:20 UTC (rev 5030) @@ -0,0 +1,67 @@ +#!/usr/bin/python + + +""" +Do not call std::string::find_first_of or std::string::find with a string of +characters to locate that has the size 1. Use the version of +std::string::find that takes a single character to locate instead. Same for +find_last_of/rfind. +""" + +error_msg = "Do not use find(\"a\"), use find('a')." + +regexp = r"""r?find(_(first|last)_of)? *\("([^\]|\\[nt\"])"[,)]""" + +forbidden = [ + 'find_first_of("a")', + 'find_last_of("a")', + 'find("a")', + 'rfind("a")', + 'find_first_of("\\n")', + 'find_last_of("\\n")', + 'find("\\n")', + 'rfind("\\n")', + 'find_first_of("\\t")', + 'find_last_of("\\t")', + 'find("\\t")', + 'rfind("\\t")', + 'find_first_of("\\\\")', + 'find_last_of("\\\\")', + 'find("\\\\")', + 'rfind("\\\\")', + 'find_first_of("\\"")', + 'find_last_of("\\"")', + 'find("\\"")', + 'rfind("\\"")', + 'find_first_of("a", 1)', + 'find_last_of("a", 1)', + 'find("a", 1)', + 'rfind("a", 1)', +] + +allowed = [ + 'find("ab")', + "find('a')", + "rfind('a')", + 'rfind("ab")', + "find('\\n')", + 'find("\\nx")', + "rfind('\\n')", + 'rfind("\\nx")', + "find('\\t')", + 'find("\\tx")', + "rfind('\\t')", + 'rfind("\\tx")', + "find('\\\\')", + 'find("\\\\x")', + "rfind('\\\\')", + 'rfind("\\\\x")', + "find('\\\"')", + 'find("\\"x")', + "rfind('\\\"')", + 'rfind("\\"x")', + "find('a', 1)", + 'find("ab", 1)', + "rfind('a', 1)", + 'rfind("ab", 1)', +] Property changes on: trunk/cmake/codecheck/rules/contrived_std_string_find ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/cmake/codecheck/rules/contrived_std_string_find_first_last_of =================================================================== --- trunk/cmake/codecheck/rules/contrived_std_string_find_first_last_of (rev 0) +++ trunk/cmake/codecheck/rules/contrived_std_string_find_first_last_of 2010-02-05 01:13:20 UTC (rev 5030) @@ -0,0 +1,38 @@ +#!/usr/bin/python + + +""" +Do not call std::string::find_first_of with a single character to find. Use the +version of std::string::find that takes a single character to locate instead. +Same for find_last_of/rfind. +""" + +error_msg = "Do not use find_first_of('a'), use find('a') (same for find_last_of/rfind)." + +regexp = r"""find_(first|last)_of *\('([^\]|\\[nt\"])'[,)]""" + +forbidden = [ + "find_first_of('a')", + "find_first_of('\n')", + "find_first_of('\\')", + "find_first_of('a', 1)", + "find_last_of('a')", + "find_last_of('\n')", + "find_last_of('\\')", + "find_last_of('a', 1)", +] + +allowed = [ + "find('a')", + "rfind('a')", + "find('\n')", + "rfind('\n')", + "find('\t')", + "rfind('\t')", + "find('\\')", + "rfind('\\')", + "find('\"')", + "rfind('\"')", + "find('a', 1)", + "rfind('a', 1)", +] Property changes on: trunk/cmake/codecheck/rules/contrived_std_string_find_first_last_of ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/cmake/codecheck/rules/deprecated_c_header =================================================================== --- trunk/cmake/codecheck/rules/deprecated_c_header (rev 0) +++ trunk/cmake/codecheck/rules/deprecated_c_header 2010-02-05 01:13:20 UTC (rev 5030) @@ -0,0 +1,62 @@ +#!/usr/bin/python + + +""" +Checks for includes of deprecated c headers. +""" + +error_msg = "You have included a deprecated C header. Remove it!" + +regexp = r"""^# *include +["<](?:assert|complex|type|errno|fenv|float|inttypes|iso646|limits|locale|math|setjmp|signal|stdarg|stdbool|stddef|stdio|stdlib|string|tgmath|time|wchar|wctype)\.h[">]""" + +forbidden = [ + '#include <assert.h>', + '#include <complex.h>', + '#include <type.h>', + '#include <errno.h>', + '#include <fenv.h>', + '#include <float.h>', + '#include <inttypes.h>', + '#include <iso646.h>', + '#include <limits.h>', + '#include <locale.h>', + '#include <math.h>', + '#include <setjmp.h>', + '#include <signal.h>', + '#include <stdarg.h>', + '#include <stdbool.h>', + '#include <stddef.h>', + '#include <stdio.h>', + '#include <stdlib.h>', + '#include <string.h>', + '#include <tgmath.h>', + '#include <time.h>', + '#include <wchar.h>', + '#include <wctype.h>', +] + +allowed = [ + '#include <cassert>', + '#include <ccomplex>', + '#include <ctype>', + '#include <cerrno>', + '#include <cfenv>', + '#include <cfloat>', + '#include <cinttypes>', + '#include <ciso646>', + '#include <climits>', + '#include <clocale>', + '#include <cmath>', + '#include <csetjmp>', + '#include <csignal>', + '#include <cstdarg>', + '#include <cstdbool>', + '#include <cstddef>', + '#include <cstdio>', + '#include <cstdlib>', + '#include <cstring>', + '#include <ctgmath>', + '#include <ctime>', + '#include <cwchar>', + '#include <cwctype>', +] Property changes on: trunk/cmake/codecheck/rules/deprecated_c_header ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/cmake/codecheck/rules/explicit_compare_with_boolean_constant =================================================================== --- trunk/cmake/codecheck/rules/explicit_compare_with_boolean_constant (rev 0) +++ trunk/cmake/codecheck/rules/explicit_compare_with_boolean_constant 2010-02-05 01:13:20 UTC (rev 5030) @@ -0,0 +1,35 @@ +#!/usr/bin/python + + +""" +This detects redundant code like "if (a == true)" (shoud be "if (a)") and +"while (b = false)" (should be "while (not b)"). +""" + +error_msg = "Do not explicitly check for boolean state. Use if (a) instead of if (a == true)." + +regexp = r'''(?:[!=]= *(?:false|true)[^_0-9a-zA-Z])|(?:[^_0-9a-zA-Z](?:false|true) *[!=]=)''' + +forbidden = [ + 'if (abc == false)', + 'if (abc != false)', + 'if (false == abc)', + 'if (false != abc)', + 'if (abc == true)', + 'if (abc != true)', + 'if (true == abc)', + 'if (true != abc)', +] + +allowed = [ + 'if (abc)', + 'if (not abc)', + 'if (is_false == abc)', + 'if (is_false != abc)', + 'if (abc == falsevity)', + 'if (abc != falsevity)', + 'if (obstrue == abc)', + 'if (obstrue != abc)', + 'if (abc == true_thing)', + 'if (abc != true_thing)', +] Property changes on: trunk/cmake/codecheck/rules/explicit_compare_with_boolean_constant ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/cmake/codecheck/rules/... [truncated message content] |
From: <qc...@us...> - 2010-02-02 23:10:36
|
Revision: 5029 http://widelands.svn.sourceforge.net/widelands/?rev=5029&view=rev Author: qcs Date: 2010-02-02 23:09:43 +0000 (Tue, 02 Feb 2010) Log Message: ----------- Allow for static/dynamic linking Completely integrating remaining directories Preparing "codecheck" target Dynamic resolution of sources and test sources (by naming convention) Modified Paths: -------------- branches/cmake-migration/CMakeLists.txt branches/cmake-migration/src/CMakeLists.txt branches/cmake-migration/src/ai/CMakeLists.txt branches/cmake-migration/src/economy/CMakeLists.txt branches/cmake-migration/src/editor/CMakeLists.txt branches/cmake-migration/src/editor/tools/CMakeLists.txt branches/cmake-migration/src/editor/ui_menus/CMakeLists.txt branches/cmake-migration/src/events/CMakeLists.txt branches/cmake-migration/src/game_io/CMakeLists.txt branches/cmake-migration/src/graphic/CMakeLists.txt branches/cmake-migration/src/io/CMakeLists.txt branches/cmake-migration/src/io/filesystem/CMakeLists.txt branches/cmake-migration/src/logic/CMakeLists.txt branches/cmake-migration/src/map_io/CMakeLists.txt branches/cmake-migration/src/network/CMakeLists.txt branches/cmake-migration/src/network/game_server/CMakeLists.txt branches/cmake-migration/src/profile/CMakeLists.txt branches/cmake-migration/src/scripting/CMakeLists.txt branches/cmake-migration/src/sound/CMakeLists.txt branches/cmake-migration/src/trigger/CMakeLists.txt branches/cmake-migration/src/ui_basic/CMakeLists.txt branches/cmake-migration/src/ui_fsmenu/CMakeLists.txt branches/cmake-migration/src/wui/CMakeLists.txt branches/cmake-migration/utils/spurious_source_code/detect Modified: branches/cmake-migration/CMakeLists.txt =================================================================== --- branches/cmake-migration/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -10,6 +10,7 @@ # If you try to set WL_VERSION directly, it will ignore your setting. cmake_minimum_required (VERSION 2.6) +set (CMAKE_CONFIGURATION_TYPES Debug|Release) if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) message(FATAL_ERROR "Build-directory and source-directory are the same!") @@ -64,10 +65,12 @@ include(CheckIncludeFile) -set(Boost_USE_STATIC_LIBS ON) -set(Boost_USE_MULTITHREADED ON) +set (BUILD_SHARED_LIBS OFF) +set (Boost_USE_STATIC_LIBS ON) +set (Boost_USE_MULTITHREADED ON) find_package(Boost 1.35.0 REQUIRED) include_directories(${Boost_INCLUDE_DIR}) +target_link_libraries(widelands ${Boost_LIBRARIES}) find_package(PNG REQUIRED) include_directories(${PNG_INCLUDE_DIR}) @@ -144,21 +147,23 @@ po # locale DESTINATION share/widelands + CONFIGURATIONS Debug|Release COMPONENT CoreDataFiles PATTERN "*.svn*" EXCLUDE PATTERN "SCons*" EXCLUDE ) -if (CMAKE_BUILD_TYPE STREQUAL Debug) +#if (CMAKE_BUILD_TYPE STREQUAL Debug) install( DIRECTORY doc DESTINATION share/widelands + CONFIGURATIONS Debug COMPONENT DocFiles PATTERN "*.svn*" EXCLUDE PATTERN "SCons*" EXCLUDE ) -endif() +#endif() set (CPACK_PACKAGE_FILE_NAME widelands-${WL_VERSION}) set (CPACK_COMPONENTS_ALL ExecutableFiles CoreDataFiles DocFiles) Modified: branches/cmake-migration/src/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,34 +1,46 @@ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) configure_file (${CMAKE_CURRENT_SOURCE_DIR}/build_info.cc.cmake ${CMAKE_CURRENT_BINARY_DIR}/build_info.cc) -file(GLOB WL_SRCS *.cc economy/*.cc trigger/*.cc scripting/*.cc) +file(GLOB_RECURSE WL_SRCS_ALL *.cc) -set(WL_TEST_SRCS - economy/test/test_economy.cc - economy/test/test_routing.cc - economy/test/SConscript.dist - economy/test/economy_test_main.cc - economy/test/SConscript - economy/test/test_road.cc -) +#file (GLOB WL_SRCS *.cc economy/*.cc trigger/*.cc scripting/*.cc) +#create WL_SRCS and WL_TEST_SRCS +#convention: any directory called "test" contains test sources, including subdirectories +set(WL_SRCS "") +set(WL_TEST_SRCS "") +foreach (sourcefile ${WL_SRCS_ALL}) + if (${sourcefile} MATCHES ".*/test/.*") + list (APPEND WL_TEST_SRCS ${sourcefile}) + else (${sourcefile} MATCHES ".*/test/.*") + list (APPEND WL_SRCS ${sourcefile}) + endif (${sourcefile} MATCHES ".*/test/.*") +endforeach (sourcefile ${WL_SRCS_ALL}) +execute_process (COMMAND cmake -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/codecheck-stamps) +set_directory_properties (PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/codecheck-stamps/*_codecheck_stamp_) + foreach(sourcefile ${WL_SRCS} ${WL_TEST_SRCS}) string(REGEX REPLACE "\\.|\\/" "_" sourcenoslash ${sourcefile}) +# get_filename_component(sourcename ${sourcefile} NAME) set(stamp ${sourcenoslash}_codecheck_stamp_) - set(PREFIX_WL_SRCS ${PREFIX_WL_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/codecheck-stamps/${stamp}) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/codecheck-stamps/${stamp} - COMMAND "${WL_SOURCE_CHECKER}" -c "${CMAKE_CURRENT_SOURCE_DIR}/${sourcefile}" - COMMAND cmake -E touch "${stamp}" - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${sourcefile} + set(PREFIX_WL_SRCS ${PREFIX_WL_SRCS};${CMAKE_CURRENT_BINARY_DIR}/codecheck-stamps/${stamp}) + if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/codecheck-stamps/${stamp} OR ${sourcefile} IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/codecheck-stamps/${stamp}) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/codecheck-stamps/${stamp} + COMMAND "${WL_SOURCE_CHECKER}" -c "${sourcefile}" + COMMAND cmake -E touch ${CMAKE_CURRENT_BINARY_DIR}/codecheck-stamps/${stamp} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +# DEPENDS ${sourcefile} ) + endif (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/codecheck-stamps/${stamp} OR ${sourcefile} IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/codecheck-stamps/${stamp}) endforeach(sourcefile ${WL_SRCS} ${WL_TEST_SRCS}) add_custom_target(codecheck DEPENDS ${PREFIX_WL_SRCS} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) add_subdirectory(ai) -#add_subdirectory(economy) +add_subdirectory(economy) add_subdirectory(editor) add_subdirectory(events) add_subdirectory(game_io) @@ -39,7 +51,7 @@ add_subdirectory(network) add_subdirectory(profile) add_subdirectory(sound) -#add_subdirectory(trigger) +add_subdirectory(trigger) add_subdirectory(ui_basic) add_subdirectory(ui_fsmenu) add_subdirectory(wui) @@ -74,7 +86,7 @@ target_link_libraries(widelands widelands_ui_basic) target_link_libraries(widelands widelands_network) target_link_libraries(widelands widelands_wui) -#target_link_libraries(widelands widelands_economy) +target_link_libraries(widelands widelands_economy) target_link_libraries(widelands widelands_events) target_link_libraries(widelands widelands_map_io) target_link_libraries(widelands widelands_logic) @@ -82,7 +94,7 @@ target_link_libraries(widelands widelands_editor_tools) target_link_libraries(widelands widelands_ui_basic) target_link_libraries(widelands widelands_events) -#target_link_libraries(widelands widelands_trigger) +target_link_libraries(widelands widelands_trigger) target_link_libraries(widelands widelands_scripting) if (APPLE) Modified: branches/cmake-migration/src/ai/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/ai/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/ai/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,4 +1,3 @@ file(GLOB WL_AI_SRCS *.cc) -add_library(widelands_ai STATIC - ${WL_AI_SRCS}) +add_library(widelands_ai ${WL_AI_SRCS}) Modified: branches/cmake-migration/src/economy/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/economy/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/economy/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,5 +1,4 @@ file(GLOB WL_ECONOMY_SRCS *.cc) -add_library(widelands_economy STATIC - ${WL_ECONOMY_SRCS}) +add_library(widelands_economy ${WL_ECONOMY_SRCS}) Modified: branches/cmake-migration/src/editor/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/editor/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/editor/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,7 +1,6 @@ file(GLOB WL_EDITOR_SRCS *.cc) -add_library(widelands_editor STATIC - ${WL_EDITOR_SRCS}) +add_library(widelands_editor ${WL_EDITOR_SRCS}) add_subdirectory(tools) add_subdirectory(ui_menus) Modified: branches/cmake-migration/src/editor/tools/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/editor/tools/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/editor/tools/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,4 +1,3 @@ file(GLOB WL_EDITOR_TOOLS_SRCS *.cc) -add_library(widelands_editor_tools STATIC - ${WL_EDITOR_TOOLS_SRCS}) +add_library(widelands_editor_tools ${WL_EDITOR_TOOLS_SRCS}) Modified: branches/cmake-migration/src/editor/ui_menus/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/editor/ui_menus/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/editor/ui_menus/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,4 +1,3 @@ file(GLOB WL_EDITOR_UI_MENUS_SRCS *.cc) -add_library(widelands_editor_ui_menus STATIC - ${WL_EDITOR_UI_MENUS_SRCS}) +add_library(widelands_editor_ui_menus ${WL_EDITOR_UI_MENUS_SRCS}) Modified: branches/cmake-migration/src/events/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/events/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/events/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,4 +1,3 @@ file(GLOB WL_EVENTS_SRCS *.cc) -add_library(widelands_events STATIC - ${WL_EVENTS_SRCS}) +add_library(widelands_events ${WL_EVENTS_SRCS}) Modified: branches/cmake-migration/src/game_io/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/game_io/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/game_io/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,4 +1,3 @@ file(GLOB WL_GAME_IO_SRCS *.cc) -add_library(widelands_game_io STATIC - ${WL_GAME_IO_SRCS}) +add_library(widelands_game_io ${WL_GAME_IO_SRCS}) Modified: branches/cmake-migration/src/graphic/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/graphic/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/graphic/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,4 +1,3 @@ file(GLOB WL_GRAPHIC_SRCS *.cc) -add_library(widelands_graphic STATIC - ${WL_GRAPHIC_SRCS}) +add_library(widelands_graphic ${WL_GRAPHIC_SRCS}) Modified: branches/cmake-migration/src/io/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/io/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/io/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,6 +1,5 @@ file(GLOB WL_IO_SRCS *.cc) -add_library(widelands_io STATIC - ${WL_IO_SRCS}) +add_library(widelands_io ${WL_IO_SRCS}) add_subdirectory(filesystem) Modified: branches/cmake-migration/src/io/filesystem/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/io/filesystem/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/io/filesystem/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,4 +1,3 @@ file(GLOB WL_IO_FILESYSTEM_SRCS *.cc) -add_library(widelands_io_filesystem STATIC - ${WL_IO_FILESYSTEM_SRCS}) +add_library(widelands_io_filesystem ${WL_IO_FILESYSTEM_SRCS}) Modified: branches/cmake-migration/src/logic/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/logic/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/logic/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,4 +1,3 @@ file(GLOB WL_LOGIC_SRCS *.cc) -add_library(widelands_logic STATIC - ${WL_LOGIC_SRCS}) +add_library(widelands_logic ${WL_LOGIC_SRCS}) Modified: branches/cmake-migration/src/map_io/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/map_io/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/map_io/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,4 +1,3 @@ file(GLOB WL_MAP_IO_SRCS *.cc) -add_library(widelands_map_io STATIC - ${WL_MAP_IO_SRCS}) +add_library(widelands_map_io ${WL_MAP_IO_SRCS}) Modified: branches/cmake-migration/src/network/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/network/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/network/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,6 +1,5 @@ file(GLOB WL_NETWORK_SRCS *.cc) -add_library(widelands_network STATIC - ${WL_NETWORK_SRCS}) +add_library(widelands_network ${WL_NETWORK_SRCS}) # add_subdirectory(game_server) Modified: branches/cmake-migration/src/network/game_server/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/network/game_server/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/network/game_server/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,5 +1,4 @@ file(GLOB WL_NETWORK_GAME_SERVER_SRCS *.cpp) -add_library(widelands_network_game_server STATIC - ${WL_NETWORK_GAME_SERVER_SRCS}) +add_library(widelands_network_game_server ${WL_NETWORK_GAME_SERVER_SRCS}) Modified: branches/cmake-migration/src/profile/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/profile/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/profile/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,4 +1,3 @@ file(GLOB WL_PROFILE_SRCS *.cc) -add_library(widelands_profile STATIC - ${WL_PROFILE_SRCS}) +add_library(widelands_profile ${WL_PROFILE_SRCS}) Modified: branches/cmake-migration/src/scripting/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/scripting/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/scripting/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,7 +1,6 @@ file(GLOB WL_SCRIPTING_SRCS *.cc) -add_library(widelands_scripting STATIC - ${WL_SCRIPTING_SRCS}) +add_library(widelands_scripting ${WL_SCRIPTING_SRCS}) target_link_libraries(widelands_scripting ${LUA_LIBRARIES}) Modified: branches/cmake-migration/src/sound/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/sound/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/sound/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,4 +1,3 @@ file(GLOB WL_SOUND_SRCS *.cc) -add_library(widelands_sound STATIC - ${WL_SOUND_SRCS}) +add_library(widelands_sound ${WL_SOUND_SRCS}) Modified: branches/cmake-migration/src/trigger/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/trigger/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/trigger/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,5 +1,4 @@ file(GLOB WL_TRIGGER_SRCS *.cc) -add_library(widelands_trigger STATIC - ${WL_TRIGGER_SRCS}) +add_library(widelands_trigger ${WL_TRIGGER_SRCS}) Modified: branches/cmake-migration/src/ui_basic/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/ui_basic/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/ui_basic/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,4 +1,3 @@ file(GLOB WL_UI_BASIC_SRCS *.cc) -add_library(widelands_ui_basic STATIC - ${WL_UI_BASIC_SRCS}) +add_library(widelands_ui_basic ${WL_UI_BASIC_SRCS}) Modified: branches/cmake-migration/src/ui_fsmenu/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/ui_fsmenu/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/ui_fsmenu/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,4 +1,3 @@ file(GLOB WL_UI_FSMENU_SRCS *.cc) -add_library(widelands_ui_fsmenu STATIC - ${WL_UI_FSMENU_SRCS}) +add_library(widelands_ui_fsmenu ${WL_UI_FSMENU_SRCS}) Modified: branches/cmake-migration/src/wui/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/wui/CMakeLists.txt 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/src/wui/CMakeLists.txt 2010-02-02 23:09:43 UTC (rev 5029) @@ -1,4 +1,3 @@ file(GLOB WL_WUI_SRCS *.cc) -add_library(widelands_wui STATIC - ${WL_WUI_SRCS}) +add_library(widelands_wui ${WL_WUI_SRCS}) Modified: branches/cmake-migration/utils/spurious_source_code/detect =================================================================== --- branches/cmake-migration/utils/spurious_source_code/detect 2010-02-02 22:41:59 UTC (rev 5028) +++ branches/cmake-migration/utils/spurious_source_code/detect 2010-02-02 23:09:43 UTC (rev 5029) @@ -156,7 +156,7 @@ } -CACHE_DIR="build/stylecheck" +CACHE_DIR="stylecheck" # Detects errors recursively and stores the result in a cache. The cache # content (if any) is echoed to standard output. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qc...@us...> - 2010-02-02 22:42:08
|
Revision: 5028 http://widelands.svn.sourceforge.net/widelands/?rev=5028&view=rev Author: qcs Date: 2010-02-02 22:41:59 +0000 (Tue, 02 Feb 2010) Log Message: ----------- fix "widelands cannot detect user home directory" issue on Linux, this should not have any impact on Windows Modified Paths: -------------- branches/cmake-migration/src/config.h.cmake Modified: branches/cmake-migration/src/config.h.cmake =================================================================== --- branches/cmake-migration/src/config.h.cmake 2010-01-31 08:52:51 UTC (rev 5027) +++ branches/cmake-migration/src/config.h.cmake 2010-02-02 22:41:59 UTC (rev 5028) @@ -6,4 +6,8 @@ #define INSTALL_DATADIR "@WL_INSTALL_DATADIR@" #define INSTALL_LOCALEDIR "@WL_INSTALL_LOCALEDIR@" +//don't know if this causes problems on Windows +//but it solves the problems finding a user's home directory on Linux +#define HAS_GETENV + #endif /* __CONFIG_H__ */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-31 08:53:00
|
Revision: 5027 http://widelands.svn.sourceforge.net/widelands/?rev=5027&view=rev Author: sigra Date: 2010-01-31 08:52:51 +0000 (Sun, 31 Jan 2010) Log Message: ----------- Implement feature request #2933314 requested by Astuur - astuur. Modified Paths: -------------- trunk/src/ui_basic/panel.h trunk/src/wui/game_main_menu_save_game.cc trunk/src/wui/game_main_menu_save_game.h Modified: trunk/src/ui_basic/panel.h =================================================================== --- trunk/src/ui_basic/panel.h 2010-01-30 23:14:53 UTC (rev 5026) +++ trunk/src/ui_basic/panel.h 2010-01-31 08:52:51 UTC (rev 5027) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2004, 2006-2009 by the Widelands Development Team + * Copyright (C) 2002-2004, 2006-2010 by the Widelands Development Team * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -201,7 +201,7 @@ void die(); bool keyboard_free() {return !(_focus);} - void play_click(); + static void play_click(); private: void check_child_death(); Modified: trunk/src/wui/game_main_menu_save_game.cc =================================================================== --- trunk/src/wui/game_main_menu_save_game.cc 2010-01-30 23:14:53 UTC (rev 5026) +++ trunk/src/wui/game_main_menu_save_game.cc 2010-01-31 08:52:51 UTC (rev 5027) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2004, 2006-2008 by the Widelands Development Team + * Copyright (C) 2002-2004, 2006-2008, 2010 by the Widelands Development Team * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -25,7 +25,6 @@ #include "game_io/game_loader.h" #include "game_io/game_preload_data_packet.h" #include "game_io/game_saver.h" -#include "i18n.h" #include "interactive_gamebase.h" #include "io/filesystem/layered_filesystem.h" #include "profile/profile.h" @@ -57,8 +56,7 @@ (&parent, ®istry, WINDOW_WIDTH, WINDOW_HEIGHT, _("Save Game")), m_ls (this, HSPACING, VSPACING, LIST_WIDTH, LIST_HEIGHT), m_editbox - (this, HSPACING, EDITBOX_Y, LIST_WIDTH, EDITBOX_HEIGHT, - g_gr->get_picture(PicMod_UI, "pics/but1.png")), + (*this, HSPACING, EDITBOX_Y, LIST_WIDTH, EDITBOX_HEIGHT), m_name_label (this, DESCRIPTION_X, 5, 0, 20, _("Map Name: "), UI::Align_CenterLeft), m_name @@ -68,24 +66,13 @@ m_gametime (this, DESCRIPTION_X, 60, 0, 20, " ", UI::Align_CenterLeft), m_button_ok - (this, - DESCRIPTION_X, OK_Y, DESCRIPTION_WIDTH, BUTTON_HEIGHT, - g_gr->get_picture(PicMod_UI, "pics/but4.png"), - &Game_Main_Menu_Save_Game::clicked_ok, *this, - _("OK"), - std::string(), - false), + (*this, DESCRIPTION_X, OK_Y, DESCRIPTION_WIDTH, BUTTON_HEIGHT), m_button_cancel - (this, - DESCRIPTION_X, CANCEL_Y, DESCRIPTION_WIDTH, BUTTON_HEIGHT, - g_gr->get_picture(PicMod_UI, "pics/but4.png"), - &Game_Main_Menu_Save_Game::die, *this, - _("Cancel")), + (*this, DESCRIPTION_X, CANCEL_Y, DESCRIPTION_WIDTH, BUTTON_HEIGHT), m_curdir(SaveHandler::get_base_dir()) { m_ls.selected.set(this, &Game_Main_Menu_Save_Game::selected); m_ls.double_clicked.set(this, &Game_Main_Menu_Save_Game::double_clicked); - m_editbox.changed.set(this, &Game_Main_Menu_Save_Game::edit_box_changed); fill_list(); @@ -133,7 +120,9 @@ /** * An Item has been doubleclicked */ -void Game_Main_Menu_Save_Game::double_clicked(uint32_t) {clicked_ok();} +void Game_Main_Menu_Save_Game::double_clicked(uint32_t) { + m_button_ok.clicked(); +} /* * fill the file list @@ -177,6 +166,24 @@ } +bool Game_Main_Menu_Save_Game::EditBox::handle_key + (bool const down, SDL_keysym const code) +{ + switch (code.sym) { + case SDLK_RETURN: + case SDLK_KP_ENTER: + if (down and text().size()) { + play_click(); + ref_cast<Game_Main_Menu_Save_Game, UI::Panel>(*get_parent()) + .m_button_ok.clicked(); + } + return true; + default: + break; + } + return UI::EditBox::handle_key(down, code); +} + static void dosave (Interactive_GameBase & igbase, std::string const & complete_filename) { @@ -237,16 +244,19 @@ called when the ok button has been clicked =========== */ -void Game_Main_Menu_Save_Game::clicked_ok() { +void Game_Main_Menu_Save_Game::Ok::clicked() { + Game_Main_Menu_Save_Game & menu = + ref_cast<Game_Main_Menu_Save_Game, UI::Panel>(*get_parent()); + Interactive_GameBase & igbase = menu.igbase(); std::string const complete_filename = - igbase().game().save_handler().create_file_name - (m_curdir, m_editbox.text()); + igbase.game().save_handler().create_file_name + (menu.m_curdir, menu.m_editbox.text()); // Check if file exists. If it does, show a warning. if (g_fs->FileExists(complete_filename)) { - new SaveWarnMessageBox(*this, complete_filename); + new SaveWarnMessageBox(menu, complete_filename); } else { - dosave(igbase(), complete_filename); - die(); + dosave(igbase, complete_filename); + menu.die(); } } Modified: trunk/src/wui/game_main_menu_save_game.h =================================================================== --- trunk/src/wui/game_main_menu_save_game.h 2010-01-30 23:14:53 UTC (rev 5026) +++ trunk/src/wui/game_main_menu_save_game.h 2010-01-31 08:52:51 UTC (rev 5027) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2004, 2006, 2008 by the Widelands Development Team + * Copyright (C) 2002-2004, 2006, 2008, 2010 by the Widelands Development Team * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -27,6 +27,10 @@ #include "ui_basic/textarea.h" #include "ui_basic/unique_window.h" +#include "i18n.h" + +#include "ref_cast.h" + struct Interactive_GameBase; struct SaveWarnMessageBox; @@ -37,7 +41,7 @@ private: Interactive_GameBase & igbase(); - void clicked_ok (); + void die() {UI::UniqueWindow::die();} void selected (uint32_t); void double_clicked(uint32_t); void edit_box_changed(); @@ -46,9 +50,51 @@ bool save_game(std::string); UI::Listselect<std::string> m_ls; - UI::EditBox m_editbox; + struct EditBox : public UI::EditBox { + EditBox + (Game_Main_Menu_Save_Game & parent, + int32_t const x, int32_t const y, uint32_t const w, uint32_t const h) + : + UI::EditBox + (&parent, + x, y, w, h, + g_gr->get_picture(PicMod_UI, "pics/but1.png")) + { + changed.set(&parent, &Game_Main_Menu_Save_Game::edit_box_changed); + } + bool handle_key(bool down, SDL_keysym); + } m_editbox; UI::Textarea m_name_label, m_name, m_gametime_label, m_gametime; - UI::Callback_Button<Game_Main_Menu_Save_Game> m_button_ok, m_button_cancel; + struct Ok : public UI::Button { + Ok + (Game_Main_Menu_Save_Game & parent, + int32_t const x, int32_t const y, uint32_t const w, uint32_t const h) + : + UI::Button + (&parent, + x, y, w, h, + g_gr->get_picture(PicMod_UI, "pics/but4.png"), + _("OK"), + std::string(), + false) + {} + void clicked(); + } m_button_ok; + struct Cancel : public UI::Button { + Cancel + (Game_Main_Menu_Save_Game & parent, + int32_t const x, int32_t const y, uint32_t const w, uint32_t const h) + : + UI::Button + (&parent, + x, y, w, h, + g_gr->get_picture(PicMod_UI, "pics/but4.png"), + _("Cancel")) + {} + void clicked() { + ref_cast<Game_Main_Menu_Save_Game, UI::Panel>(*get_parent()).die(); + } + } m_button_cancel; std::string m_curdir; std::string m_parentdir; std::string m_filename; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-30 23:14:59
|
Revision: 5026 http://widelands.svn.sourceforge.net/widelands/?rev=5026&view=rev Author: sirver Date: 2010-01-30 23:14:53 +0000 (Sat, 30 Jan 2010) Log Message: ----------- Fixed a bug with resource overlays in the editor When a map was loaded to be edited again, when the number of resources would been decreased to zero, the resource overlay would not vanish. The Problem was that upon loading, when the overlays were first installed, PicMod_Game was used while in the Editor PicMod_Menu was used. Fixed loading to PicMod_Menu too. Modified Paths: -------------- trunk/src/editor/editorinteractive.cc Modified: trunk/src/editor/editorinteractive.cc =================================================================== --- trunk/src/editor/editorinteractive.cc 2010-01-30 18:39:21 UTC (rev 5025) +++ trunk/src/editor/editorinteractive.cc 2010-01-30 23:14:53 UTC (rev 5026) @@ -140,7 +140,7 @@ (amount); if (immname.size()) overlay_manager.register_overlay - (fc, g_gr->get_picture(PicMod_Game, immname.c_str()), 4); + (fc, g_gr->get_picture(PicMod_Menu, immname.c_str()), 4); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-30 18:39:31
|
Revision: 5025 http://widelands.svn.sourceforge.net/widelands/?rev=5025&view=rev Author: sigra Date: 2010-01-30 18:39:21 +0000 (Sat, 30 Jan 2010) Log Message: ----------- Fix bug that the enter key did not work as expected (for some reason both the return key and the enter key on the numeric keypad generate SDL_KP_ENTER on my system). Improve the comments about the error that virtual Building::init is called when allocating a building during savegame loading, which causes many bugs, such as #2927882. Modified Paths: -------------- trunk/src/editor/editorinteractive.cc trunk/src/io/filesystem/filesystem.cc trunk/src/io/filesystem/test/test_filesystem.cc trunk/src/logic/building.cc trunk/src/logic/building.h trunk/src/logic/warehouse.cc trunk/src/map_io/widelands_map_building_data_packet.cc trunk/src/map_io/widelands_map_buildingdata_data_packet.cc trunk/src/map_io/widelands_map_data_packet.h trunk/src/ui_basic/editbox.cc trunk/src/ui_basic/multilineeditbox.cc trunk/src/wui/interactive_base.cc trunk/src/wui/interactive_dedicated_server.cc trunk/src/wui/interactive_player.cc trunk/src/wui/interactive_spectator.cc Modified: trunk/src/editor/editorinteractive.cc =================================================================== --- trunk/src/editor/editorinteractive.cc 2010-01-30 18:15:54 UTC (rev 5024) +++ trunk/src/editor/editorinteractive.cc 2010-01-30 18:39:21 UTC (rev 5025) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2003, 2006-2009 by the Widelands Development Team + * Copyright (C) 2002-2003, 2006-2010 by the Widelands Development Team * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -334,7 +334,7 @@ } -bool Editor_Interactive::handle_key(bool down, SDL_keysym code) +bool Editor_Interactive::handle_key(bool const down, SDL_keysym const code) { bool handled = Interactive_Base::handle_key(down, code); Modified: trunk/src/io/filesystem/filesystem.cc =================================================================== --- trunk/src/io/filesystem/filesystem.cc 2010-01-30 18:15:54 UTC (rev 5024) +++ trunk/src/io/filesystem/filesystem.cc 2010-01-30 18:39:21 UTC (rev 5025) @@ -185,7 +185,7 @@ */ template<typename Inserter> static void FS_Tokenize - (std::string const & path, char filesep, Inserter components) + (std::string const & path, char const filesep, Inserter components) { std::string::size_type pos; // start of token std::string::size_type pos2; // next filesep character @@ -232,33 +232,29 @@ } #endif - FS_Tokenize(path, m_filesep, - std::inserter(components, components.begin())); + FS_Tokenize(path, m_filesep, std::inserter(components, components.begin())); //tilde expansion if (!components.empty() && *components.begin() == "~") { components.erase(components.begin()); - FS_Tokenize(GetHomedir(), m_filesep, - std::inserter(components, components.begin())); - } - - //make relative paths absolute (so that "../../foo" can work) - else if (!pathIsAbsolute(path)) { FS_Tokenize + (GetHomedir(), + m_filesep, + std::inserter(components, components.begin())); + } else if (!pathIsAbsolute(path)) + // make relative paths absolute (so that "../../foo" can work) + FS_Tokenize (m_root.empty() ? getWorkingDirectory() : m_root, m_filesep, - std::inserter(components, components.begin())); - } + std::inserter(components, components.begin())); //clean up the path for (i = components.begin(); i != components.end();) { - const char * str = (*i).c_str(); - if (*str == '.') - { + char const * str = i->c_str(); + if (*str == '.') { ++str; //remove single dot - if (*str == '\0') - { + if (*str == '\0') { i = components.erase(i); continue; } @@ -277,14 +273,15 @@ std::string canonpath; canonpath.reserve(path.length()); #ifndef WIN32 - for (i = components.begin(); i != components.end(); ++i) - { + for (i = components.begin(); i != components.end(); ++i) { canonpath.push_back('/'); canonpath += *i; } #else - for (i = components.begin(); i != components.end(); ++i) - canonpath += *i + "\\"; + for (i = components.begin(); i != components.end(); ++i) { + canonpath += *i; + canonpath += '\\'; + } canonpath.erase(canonpath.end() - 1); //remove trailing slash #endif Modified: trunk/src/io/filesystem/test/test_filesystem.cc =================================================================== --- trunk/src/io/filesystem/test/test_filesystem.cc 2010-01-30 18:15:54 UTC (rev 5024) +++ trunk/src/io/filesystem/test/test_filesystem.cc 2010-01-30 18:39:21 UTC (rev 5025) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 by the Widelands Development Team + * Copyright (C) 2007-2008, 2010 by the Widelands Development Team * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -27,10 +27,8 @@ BOOST_AUTO_TEST_SUITE(FileSystemTests) -#define TEST_CANONICALIZE_NAME(root, path, expected)\ - BOOST_CHECK_EQUAL(\ - RealFSImpl(root).FS_CanonicalizeName(path), \ - expected); +#define TEST_CANONICALIZE_NAME(root, path, expected) \ + BOOST_CHECK_EQUAL(RealFSImpl(root).FS_CanonicalizeName(path), expected); \ BOOST_AUTO_TEST_CASE(test_canonicalize_name) { setenv("HOME", "/home/test", 1); Modified: trunk/src/logic/building.cc =================================================================== --- trunk/src/logic/building.cc 2010-01-30 18:15:54 UTC (rev 5024) +++ trunk/src/logic/building.cc 2010-01-30 18:39:21 UTC (rev 5025) @@ -175,13 +175,6 @@ } -/* -=============== -Create a building of this type. Does not perform any sanity checks. - -if old != 0 this is an enhancing -=============== -*/ Building & Building_Descr::create (Editor_Game_Base & egbase, Player & owner, Modified: trunk/src/logic/building.h =================================================================== --- trunk/src/logic/building.h 2010-01-30 18:15:54 UTC (rev 5024) +++ trunk/src/logic/building.h 2010-01-30 18:39:21 UTC (rev 5025) @@ -80,6 +80,13 @@ m_enhancements.insert(i); } + /// Create a building of this type in the game. Calls init, which does + /// different things for different types of buildings (such as conquering + /// land and requesting things). Therefore this must not be used to allocate + /// a building during savegame loading. (It would cause many bugs.) + /// + /// Does not perform any sanity checks. + /// If old != 0 this is an enhancing. Building & create (Editor_Game_Base &, Player &, Modified: trunk/src/logic/warehouse.cc =================================================================== --- trunk/src/logic/warehouse.cc 2010-01-30 18:15:54 UTC (rev 5024) +++ trunk/src/logic/warehouse.cc 2010-01-30 18:39:21 UTC (rev 5025) @@ -401,7 +401,7 @@ // NOTE warehouse really wants to have this ware. // return 100, if type is a ware, or the warehouse has no request itself - if ((type == Request::WORKER) || (m_target_supply[ware_index] == 0)) + if (type == Request::WORKER || m_target_supply[ware_index] == 0) return 100; int32_t const x = (m_target_supply.at(ware_index) + 2 - @@ -461,7 +461,7 @@ (worker_types_without_cost.at(i.current))) m_next_worker_without_cost_spawn[i.current] = act_time; } - m_next_military_act = + m_next_military_act = schedule_act (ref_cast<Game, Editor_Game_Base>(egbase), 1000); m_target_supply.resize(m_requests.size()); @@ -477,13 +477,11 @@ if (uint32_t const conquer_radius = get_conquers()) ref_cast<Game, Editor_Game_Base>(egbase).conquer_area (Player_Area<Area<FCoords> > - (owner().player_number(), + (player.player_number(), Area<FCoords> (egbase.map().get_fcoords(get_position()), conquer_radius))); - log - ("Message: adding (wh) (%s) %i \n", - type_name(), owner().player_number()); + log("Message: adding (wh) (%s) %i \n", type_name(), player.player_number()); char message[2048]; snprintf (message, sizeof(message), @@ -491,7 +489,7 @@ ("<p font-size=14 font-face=FreeSerif>A new %s was added to your " "economy.</p>"), descname().c_str()); - owner().add_message + player.add_message (ref_cast<Game, Editor_Game_Base>(egbase), create_message ("warehouse", Modified: trunk/src/map_io/widelands_map_building_data_packet.cc =================================================================== --- trunk/src/map_io/widelands_map_building_data_packet.cc 2010-01-30 18:15:54 UTC (rev 5024) +++ trunk/src/map_io/widelands_map_building_data_packet.cc 2010-01-30 18:39:21 UTC (rev 5025) @@ -82,6 +82,24 @@ // Now, create this Building, take extra special care for // constructionsites. All data is read later. + // FIXME This is where things start to go terribly wrong. + // FIXME What needs to be done here is to allocate an + // FIXME object of an appropriate type derived from + // FIXME Building, so that it can be filled with the data + // FIXME that is read later. But what is actually done is + // FIXME to create a new building and initialize it as if + // FIXME it was newly created in the game. This causes + // FIXME several bugs, such as: + // FIXME * ProductionSites try to request wares and + // FIXME workers and start working. + // FIXME * Warehouses create requests for all kinds of + // FIXME wares and workers. + // FIXME * Warehouses with a conquer radius conquer + // FIXME land. + // FIXME * A message is created informing the owning + // FIXME player that he got a new warehouse. + // FIXME Some of these bugs are worked around with ugly + // FIXME kludges while others fully affect the users. Building & building = mol.register_object<Building> (serial, Modified: trunk/src/map_io/widelands_map_buildingdata_data_packet.cc =================================================================== --- trunk/src/map_io/widelands_map_buildingdata_data_packet.cc 2010-01-30 18:15:54 UTC (rev 5024) +++ trunk/src/map_io/widelands_map_buildingdata_data_packet.cc 2010-01-30 18:39:21 UTC (rev 5025) @@ -315,15 +315,15 @@ warehouse.insert_workers(id, fr.Unsigned16()); } - // FIXME The reason for this code is probably that the constructor of - // FIXME Warehouse requests things. That makes sense when a Warehouse - // FIXME is created in the game, but definitely not when only - // FIXME allocating a Warehouse to later fill it with information - // FIXME from a savegame. Therefore this code here undoes what the - // FIXME constructor just did. There should really be different - // FIXME constructors for those cases. - for (uint32_t i = 0; i < warehouse.m_requests.size(); ++i) - delete warehouse.m_requests[i]; + // FIXME The reason for this code is that Warehouse::init is called + // FIXME when a warehouse is allocated during savegame loading. That + // FIXME is a bug. That code must only be executed when a warehouse + // FIXME is created in the game. Requests are created there. + // FIXME Therefore this code here undoes what Warehouse::init just + // FIXME did. + container_iterate_const + (std::vector<Request *>, warehouse.m_requests, i) + delete *i.current; warehouse.m_requests.resize(fr.Unsigned16()); for (uint32_t i = 0; i < warehouse.m_requests.size(); ++i) { @@ -363,10 +363,11 @@ std::vector<Ware_Index> const & worker_types_without_cost = tribe.worker_types_without_cost(); - // FIXME Mighty ugly kludge to undo what warehouse::init did, so that + // FIXME Mighty ugly kludge to undo what Warehouse::init did, so that // FIXME we have a fresh object when starting to fill in the values // FIXME read from file. To get rid of this, make sure that init is - // FIXME not called on a warehouse when it is loaded from a savegame. + // FIXME not called on a Warehouse object that has been allocated + // FIXME during savegame loading. for (uint8_t i = worker_types_without_cost.size(); i;) warehouse.m_next_worker_without_cost_spawn[--i] = Never(); @@ -590,13 +591,12 @@ (1 <= packet_version and packet_version <= CURRENT_PRODUCTIONSITE_PACKET_VERSION) { - // FIXME The reason for this code is probably that the constructor of - // FIXME ProductionSite requests workers. That makes sense when a - // FIXME ProductionSite is created in the game, but definitely not - // FIXME when only allocating a ProductionSite to later fill it with - // FIXME information from a savegame. Therefore this code here undoes - // FIXME what the constructor just did. There should really be - // FIXME different constructors for those cases. + // FIXME The reason for this code is that ProductionSite::init is + // FIXME called when a productionsite is allocated during savegame + // FIXME loading. That is a bug. That code must only be executed when + // FIXME a productionsite is created in the game. Requests are + // FIXME created there. Therefore this code here undoes what + // FIXME ProductionSite::init just did. for (uint32_t i = productionsite.descr().nr_working_positions(); i;) { delete productionsite.m_working_positions[--i].worker_request; productionsite.m_working_positions[i].worker_request = 0; Modified: trunk/src/map_io/widelands_map_data_packet.h =================================================================== --- trunk/src/map_io/widelands_map_data_packet.h 2010-01-30 18:15:54 UTC (rev 5024) +++ trunk/src/map_io/widelands_map_data_packet.h 2010-01-30 18:39:21 UTC (rev 5025) @@ -52,7 +52,7 @@ #define MAP_DATA_PACKET(name) \ namespace Widelands { \ struct name : public Map_Data_Packet { \ - virtual ~ name() {} \ + virtual ~name() {} \ void Read \ (FileSystem &, Editor_Game_Base &, bool, Map_Map_Object_Loader &) \ throw (_wexception); \ Modified: trunk/src/ui_basic/editbox.cc =================================================================== --- trunk/src/ui_basic/editbox.cc 2010-01-30 18:15:54 UTC (rev 5024) +++ trunk/src/ui_basic/editbox.cc 2010-01-30 18:39:21 UTC (rev 5025) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003, 2006-2008 by the Widelands Development Team + * Copyright (C) 2003, 2006-2008, 2010 by the Widelands Development Team * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -193,7 +193,7 @@ * ASCII characters (--> //HERE). Instead, all user editable strings should be * real unicode. */ -bool EditBox::handle_key(bool down, SDL_keysym code) +bool EditBox::handle_key(bool const down, SDL_keysym const code) { if (down) { switch (code.sym) { @@ -203,6 +203,7 @@ return true; case SDLK_RETURN: + case SDLK_KP_ENTER: ok.call(); okid.call(m->id); return true; Modified: trunk/src/ui_basic/multilineeditbox.cc =================================================================== --- trunk/src/ui_basic/multilineeditbox.cc 2010-01-30 18:15:54 UTC (rev 5024) +++ trunk/src/ui_basic/multilineeditbox.cc 2010-01-30 18:39:21 UTC (rev 5025) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2004, 2006-2009 by the Widelands Development Team + * Copyright (C) 2002-2004, 2006-2010 by the Widelands Development Team * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -188,6 +188,7 @@ break; case SDLK_RETURN: + case SDLK_KP_ENTER: if (txt.size() < m_maxchars) { txt.insert(txt.begin() + m_cur_pos++, 1, '\n'); set_text(txt.c_str()); Modified: trunk/src/wui/interactive_base.cc =================================================================== --- trunk/src/wui/interactive_base.cc 2010-01-30 18:15:54 UTC (rev 5024) +++ trunk/src/wui/interactive_base.cc 2010-01-30 18:39:21 UTC (rev 5025) @@ -793,7 +793,7 @@ } -bool Interactive_Base::handle_key(bool down, SDL_keysym code) +bool Interactive_Base::handle_key(bool const down, SDL_keysym const code) { switch (code.sym) { case SDLK_PAGEUP: Modified: trunk/src/wui/interactive_dedicated_server.cc =================================================================== --- trunk/src/wui/interactive_dedicated_server.cc 2010-01-30 18:15:54 UTC (rev 5024) +++ trunk/src/wui/interactive_dedicated_server.cc 2010-01-30 18:39:21 UTC (rev 5025) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 by the Widelands Development Team + * Copyright (C) 2009-2010 by the Widelands Development Team * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -137,6 +137,7 @@ return true; case SDLK_RETURN: + case SDLK_KP_ENTER: if (!m_chatProvider | !m_chatenabled) break; Modified: trunk/src/wui/interactive_player.cc =================================================================== --- trunk/src/wui/interactive_player.cc 2010-01-30 18:15:54 UTC (rev 5024) +++ trunk/src/wui/interactive_player.cc 2010-01-30 18:39:21 UTC (rev 5025) @@ -463,6 +463,7 @@ return true; case SDLK_RETURN: + case SDLK_KP_ENTER: if (!m_chatProvider | !m_chatenabled) break; Modified: trunk/src/wui/interactive_spectator.cc =================================================================== --- trunk/src/wui/interactive_spectator.cc 2010-01-30 18:15:54 UTC (rev 5024) +++ trunk/src/wui/interactive_spectator.cc 2010-01-30 18:39:21 UTC (rev 5025) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 by the Widelands Development Team + * Copyright (C) 2007-2008, 2010 by the Widelands Development Team * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -206,7 +206,7 @@ /** * Global in-game keypresses: */ -bool Interactive_Spectator::handle_key(bool down, SDL_keysym code) +bool Interactive_Spectator::handle_key(bool const down, SDL_keysym const code) { if (down) switch (code.sym) { @@ -232,6 +232,7 @@ return true; case SDLK_RETURN: + case SDLK_KP_ENTER: if (!m_chatProvider | !m_chatenabled) break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-30 18:16:01
|
Revision: 5024 http://widelands.svn.sourceforge.net/widelands/?rev=5024&view=rev Author: sirver Date: 2010-01-30 18:15:54 +0000 (Sat, 30 Jan 2010) Log Message: ----------- libstd++ does not define std::map::at This is a workaround that is (for example) needed for OS X 10.5. Modified Paths: -------------- trunk/src/logic/world.cc Modified: trunk/src/logic/world.cc =================================================================== --- trunk/src/logic/world.cc 2010-01-30 18:15:31 UTC (rev 5023) +++ trunk/src/logic/world.cc 2010-01-30 18:15:54 UTC (rev 5024) @@ -397,7 +397,9 @@ { if (m_BobKinds.find(bobKindName) == m_BobKinds.end()) throw wexception("invalid MapGenBobKind %s", bobKindName.c_str()); - return & m_BobKinds.at(bobKindName); + // Ugly workaround because at is not defined for some systems + // and operator[] does not fare well with constants + return & m_BobKinds.find(bobKindName)->second; } void MapGenInfo::parseProfile(World * const world, Profile & profile) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-30 18:15:40
|
Revision: 5023 http://widelands.svn.sourceforge.net/widelands/?rev=5023&view=rev Author: sirver Date: 2010-01-30 18:15:31 +0000 (Sat, 30 Jan 2010) Log Message: ----------- Some virtual destructors to silence older gcc Modified Paths: -------------- trunk/src/map_io/widelands_map_data_packet.h trunk/src/scripting/scripting.h Modified: trunk/src/map_io/widelands_map_data_packet.h =================================================================== --- trunk/src/map_io/widelands_map_data_packet.h 2010-01-27 01:23:23 UTC (rev 5022) +++ trunk/src/map_io/widelands_map_data_packet.h 2010-01-30 18:15:31 UTC (rev 5023) @@ -35,6 +35,8 @@ * abstract base class */ struct Map_Data_Packet { + virtual ~Map_Data_Packet() {} + virtual void Read (FileSystem &, Editor_Game_Base &, bool, Map_Map_Object_Loader &) throw (_wexception) @@ -50,6 +52,7 @@ #define MAP_DATA_PACKET(name) \ namespace Widelands { \ struct name : public Map_Data_Packet { \ + virtual ~ name() {} \ void Read \ (FileSystem &, Editor_Game_Base &, bool, Map_Map_Object_Loader &) \ throw (_wexception); \ Modified: trunk/src/scripting/scripting.h =================================================================== --- trunk/src/scripting/scripting.h 2010-01-27 01:23:23 UTC (rev 5022) +++ trunk/src/scripting/scripting.h 2010-01-30 18:15:31 UTC (rev 5023) @@ -44,6 +44,8 @@ * Easy handling of LuaCoroutines */ struct LuaCoroutine { + virtual ~LuaCoroutine() {} + virtual int get_status() = 0; virtual int resume () = 0; }; @@ -68,6 +70,8 @@ * This is the thin class that is used to execute code */ struct LuaInterface { + virtual ~LuaInterface() {} + virtual LuaState * interpret_string(std::string) = 0; virtual LuaState * interpret_file(std::string) = 0; virtual std::string const & get_last_error() const = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qc...@us...> - 2010-01-27 01:23:33
|
Revision: 5022 http://widelands.svn.sourceforge.net/widelands/?rev=5022&view=rev Author: qcs Date: 2010-01-27 01:23:23 +0000 (Wed, 27 Jan 2010) Log Message: ----------- Versioning stuff (CMake, CPack) and cleanup Modified Paths: -------------- branches/cmake-migration/CMakeLists.txt branches/cmake-migration/src/CMakeLists.txt Modified: branches/cmake-migration/CMakeLists.txt =================================================================== --- branches/cmake-migration/CMakeLists.txt 2010-01-26 23:00:12 UTC (rev 5021) +++ branches/cmake-migration/CMakeLists.txt 2010-01-27 01:23:23 UTC (rev 5022) @@ -4,8 +4,10 @@ # set them via cmake -DVARIABLE=VALUE # CMAKE_BUILD_TYPE: # Default is "Debug", Distributors should use "Release" -# WL_VERSION: +# WL_VERSION_MAJOR, WL_VERSION_MINOR (, WL_VERSION_PATCH): # Default is using SVN revision, Distributors should use correct version +# Attention: We are currently only using MAJOR and MINOR. +# If you try to set WL_VERSION directly, it will ignore your setting. cmake_minimum_required (VERSION 2.6) @@ -15,17 +17,42 @@ SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) -if (NOT CMAKE_BUILD_TYPE) +if (NOT DEFINED CMAKE_BUILD_TYPE) set (CMAKE_BUILD_TYPE Debug) -endif (NOT CMAKE_BUILD_TYPE) +endif (NOT DEFINED CMAKE_BUILD_TYPE) -if (NOT WL_VERSION) +# we don't want someone to set this directly... +unset (WL_VERSION CACHE) + +# ...but using MAJOR, MINOR and PATCH +# (BUT: we only use MAJOR and MINOR for the moment; PATCH is set to 0) +if (DEFINED WL_VERSION_MAJOR) + set (WL_VERSION ${WL_VERSION_MAJOR}) + set (CPACK_PACKAGE_VERSION_MAJOR ${WL_VERSION_MAJOR}) + if (DEFINED WL_VERSION_MINOR) + set (WL_VERSION ${WL_VERSION}.${WL_VERSION_MINOR}) + set (CPACK_PACKAGE_VERSION_MINOR ${WL_VERSION_MINOR}) + if (DEFINED WL_VERSION_PATCH) + set (WL_VERSION ${WL_VERSION}.${WL_VERSION_PATCH}) + set (CPACK_PACKAGE_VERSION_PATCH ${WL_VERSION_PATCH}) + else (DEFINED WL_VERSION_PATCH) + set (CPACK_PACKAGE_VERSION_PATCH 0) + endif (DEFINED WL_VERSION_PATCH) + else (DEFINED WL_VERSION_MINOR) + set (CPACK_PACKAGE_VERSION_MINOR 0) + endif (DEFINED WL_VERSION_MINOR) +endif (DEFINED WL_VERSION_MAJOR) + +if (NOT DEFINED WL_VERSION) find_package (PythonInterp REQUIRED) - execute_process (COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/utils/detect_revision.py - OUTPUT_VARIABLE WL_VERSION WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_STRIP_TRAILING_WHITESPACE) -endif (NOT WL_VERSION) -message( "Version of Widelands Build is ${WL_VERSION}(${CMAKE_BUILD_TYPE})") + execute_process ( + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/utils/detect_revision.py + OUTPUT_VARIABLE WL_VERSION + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_STRIP_TRAILING_WHITESPACE + ) +endif (NOT DEFINED WL_VERSION) +message ("Version of Widelands Build is ${WL_VERSION}(${CMAKE_BUILD_TYPE})") set (WL_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) set (WL_INSTALL_BINDIR ${WL_INSTALL_PREFIX}/bin/) @@ -88,23 +115,15 @@ find_package(Doxygen REQUIRED) include(Documentation) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/sourcecode) - configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in - ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY IMMEDIATE) - add_custom_target(doc COMMAND ${DOXYGEN_EXECUTABLE} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY IMMEDIATE) + add_custom_target(doc COMMAND ${DOXYGEN_EXECUTABLE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) endif() -include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) -include_directories(src) +include_directories(src ${CMAKE_CURRENT_BINARY_DIR}/src) -configure_file( - src/config.h.cmake src/config.h - ) +#configure_file (src/config.h.cmake src/config.h) +#configure_file (src/build_info.cc.cmake src/build_info.cc) -configure_file( - src/build_info.cc.cmake src/build_info.cc - ) - #add_subdirectory(po) add_subdirectory(pics) add_subdirectory(src) @@ -141,6 +160,7 @@ ) endif() +set (CPACK_PACKAGE_FILE_NAME widelands-${WL_VERSION}) set (CPACK_COMPONENTS_ALL ExecutableFiles CoreDataFiles DocFiles) set (CPACK_GENERATOR TGZ) set (CPACK_SOURCE_GENERATOR TGZ) Modified: branches/cmake-migration/src/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/CMakeLists.txt 2010-01-26 23:00:12 UTC (rev 5021) +++ branches/cmake-migration/src/CMakeLists.txt 2010-01-27 01:23:23 UTC (rev 5022) @@ -1,3 +1,6 @@ +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/build_info.cc.cmake ${CMAKE_CURRENT_BINARY_DIR}/build_info.cc) + file(GLOB WL_SRCS *.cc economy/*.cc trigger/*.cc scripting/*.cc) set(WL_TEST_SRCS This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qc...@us...> - 2010-01-26 23:00:24
|
Revision: 5021 http://widelands.svn.sourceforge.net/widelands/?rev=5021&view=rev Author: qcs Date: 2010-01-26 23:00:12 +0000 (Tue, 26 Jan 2010) Log Message: ----------- CPack basics (.tar.gz archives) Modified Paths: -------------- branches/cmake-migration/CMakeLists.txt branches/cmake-migration/pics/CMakeLists.txt branches/cmake-migration/src/CMakeLists.txt Modified: branches/cmake-migration/CMakeLists.txt =================================================================== --- branches/cmake-migration/CMakeLists.txt 2010-01-24 23:13:56 UTC (rev 5020) +++ branches/cmake-migration/CMakeLists.txt 2010-01-26 23:00:12 UTC (rev 5021) @@ -18,7 +18,6 @@ if (NOT CMAKE_BUILD_TYPE) set (CMAKE_BUILD_TYPE Debug) endif (NOT CMAKE_BUILD_TYPE) -#message("CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}") if (NOT WL_VERSION) find_package (PythonInterp REQUIRED) @@ -36,7 +35,6 @@ set (WL_SOURCE_CHECKER ${CMAKE_CURRENT_SOURCE_DIR}/cmake/codecheck/CodeCheck.py) -include(CPack) include(CheckIncludeFile) set(Boost_USE_STATIC_LIBS ON) @@ -112,28 +110,38 @@ add_subdirectory(src) # install files to the correct locations here -install(DIRECTORY - campaigns - fonts - global - maps - music - pics - sound - tribes - txts - worlds - po +install( + DIRECTORY + campaigns + fonts + global + maps + music + pics + sound + tribes + txts + worlds + po # locale - DESTINATION ${WL_INSTALL_DATADIR} PATTERN "*.svn*" EXCLUDE PATTERN - "SCons*" EXCLUDE + DESTINATION share/widelands + COMPONENT CoreDataFiles + PATTERN "*.svn*" EXCLUDE + PATTERN "SCons*" EXCLUDE ) if (CMAKE_BUILD_TYPE STREQUAL Debug) - install(DIRECTORY - doc - DESTINATION ${WL_INSTALL_DATADIR} PATTERN "*.svn*" EXCLUDE PATTERN - "SCons*" EXCLUDE + install( + DIRECTORY + doc + DESTINATION share/widelands + COMPONENT DocFiles + PATTERN "*.svn*" EXCLUDE + PATTERN "SCons*" EXCLUDE ) endif() +set (CPACK_COMPONENTS_ALL ExecutableFiles CoreDataFiles DocFiles) +set (CPACK_GENERATOR TGZ) +set (CPACK_SOURCE_GENERATOR TGZ) +include(CPack) Modified: branches/cmake-migration/pics/CMakeLists.txt =================================================================== --- branches/cmake-migration/pics/CMakeLists.txt 2010-01-24 23:13:56 UTC (rev 5020) +++ branches/cmake-migration/pics/CMakeLists.txt 2010-01-26 23:00:12 UTC (rev 5021) @@ -1,3 +1 @@ -message (${CMAKE_CURRENT_SOURCE_DIR}) -message (${CMAKE_CURRENT_BINARY_DIR}) add_custom_target (pics WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DWL_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -DWL_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -P PicsFunctions.cmake) Modified: branches/cmake-migration/src/CMakeLists.txt =================================================================== --- branches/cmake-migration/src/CMakeLists.txt 2010-01-24 23:13:56 UTC (rev 5020) +++ branches/cmake-migration/src/CMakeLists.txt 2010-01-26 23:00:12 UTC (rev 5021) @@ -86,5 +86,4 @@ target_link_libraries(widelands ${INTL_LIBRARY}) endif (APPLE) -install(TARGETS widelands DESTINATION ${WL_INSTALL_BINDIR}) - +install(TARGETS widelands DESTINATION bin COMPONENT ExecutableFiles) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qc...@us...> - 2010-01-24 23:14:07
|
Revision: 5020 http://widelands.svn.sourceforge.net/widelands/?rev=5020&view=rev Author: qcs Date: 2010-01-24 23:13:56 +0000 (Sun, 24 Jan 2010) Log Message: ----------- New make target pics (currently only for Linux) Modified Paths: -------------- branches/cmake-migration/CMakeLists.txt Added Paths: ----------- branches/cmake-migration/pics/CMakeLists.txt branches/cmake-migration/pics/PicsFunctions.cmake Removed Paths: ------------- branches/cmake-migration/pics/CMakeList.txt Modified: branches/cmake-migration/CMakeLists.txt =================================================================== --- branches/cmake-migration/CMakeLists.txt 2010-01-23 16:27:54 UTC (rev 5019) +++ branches/cmake-migration/CMakeLists.txt 2010-01-24 23:13:56 UTC (rev 5020) @@ -108,7 +108,7 @@ ) #add_subdirectory(po) -# add_subdirectory(pics) +add_subdirectory(pics) add_subdirectory(src) # install files to the correct locations here Deleted: branches/cmake-migration/pics/CMakeList.txt =================================================================== --- branches/cmake-migration/pics/CMakeList.txt 2010-01-23 16:27:54 UTC (rev 5019) +++ branches/cmake-migration/pics/CMakeList.txt 2010-01-24 23:13:56 UTC (rev 5020) @@ -1,2 +0,0 @@ -set(PNGS file(GLOB_RECURSE *.png)) - Added: branches/cmake-migration/pics/CMakeLists.txt =================================================================== --- branches/cmake-migration/pics/CMakeLists.txt (rev 0) +++ branches/cmake-migration/pics/CMakeLists.txt 2010-01-24 23:13:56 UTC (rev 5020) @@ -0,0 +1,3 @@ +message (${CMAKE_CURRENT_SOURCE_DIR}) +message (${CMAKE_CURRENT_BINARY_DIR}) +add_custom_target (pics WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DWL_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -DWL_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -P PicsFunctions.cmake) Property changes on: branches/cmake-migration/pics/CMakeLists.txt ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: branches/cmake-migration/pics/PicsFunctions.cmake =================================================================== --- branches/cmake-migration/pics/PicsFunctions.cmake (rev 0) +++ branches/cmake-migration/pics/PicsFunctions.cmake 2010-01-24 23:13:56 UTC (rev 5020) @@ -0,0 +1,47 @@ +file (GLOB_RECURSE PNG_LIST *.png) + +set (WL_TOOLS_PNG_FOUND false) + +if (WIN32 OR APPLE) + message ("The \"pics\" target has not yet been tested on Windows (and Darwin), only on Linux. It is highly likely that find_program does not find optipng and/or pngrewrite. You are welcome to test and correct it in pics/PicsFunctions.cmake or report back.") +endif (WIN32 OR APPLE) + +if (CMAKE_BUILD_TYPE STREQUAL Release) + find_program (WL_TOOLS_PNGREWRITE pngrewrite) + if (NOT WL_TOOLS_PNGREWRITE STREQUAL "WL_TOOLS_PNGREWRITE-NOTFOUND") + message("pngrewrite is ${WL_TOOLS_PNGREWRITE}") + set (WL_TOOLS_PNG_FOUND true) + else (NOT WL_TOOLS_PNGREWRITE STREQUAL "WL_TOOLS_PNGREWRITE-NOTFOUND") + message ("pngrewrite not found") + endif (NOT WL_TOOLS_PNGREWRITE STREQUAL "WL_TOOLS_PNGREWRITE-NOTFOUND") + + find_program (WL_TOOLS_OPTIPNG optipng) + if (NOT WL_TOOLS_OPTIPNG STREQUAL "WL_TOOLS_OPTIPNG-NOTFOUND") + message("optipng is ${WL_TOOLS_OPTIPNG}") + set (WL_TOOLS_PNG_FOUND true) + else (NOT WL_TOOLS_OPTIPNG STREQUAL "WL_TOOLS_OPTIPNG-NOTFOUND") + message ("optipng not found") + endif (NOT WL_TOOLS_OPTIPNG STREQUAL "WL_TOOLS_OPTIPNG-NOTFOUND") + + if (WL_TOOLS_PNG_FOUND) + foreach (png_tmp ${PNG_LIST}) +#message ("Processing ${png_tmp}") + get_filename_component(png_tmp_filename ${png_tmp} NAME) +#message ("cmake -E copy ${png_tmp} ${WL_CURRENT_BINARY_DIR}/${png_tmp_filename}") + execute_process (RESULT_VARIABLE copyret COMMAND cmake -E copy ${png_tmp} ${WL_CURRENT_BINARY_DIR}/${png_tmp_filename}) +#message (${copyret}) + if (NOT WL_TOOLS_PNGREWRITE STREQUAL "WL_TOOLS_PNGREWRITE-NOTFOUND") +message ("${WL_TOOLS_PNGREWRITE} ${WL_CURRENT_BINARY_DIR}/${png_tmp_filename} ${WL_CURRENT_BINARY_DIR}/${png_tmp_filename}") + execute_process (COMMAND ${WL_TOOLS_PNGREWRITE} ${WL_CURRENT_BINARY_DIR}/${png_tmp_filename} ${WL_CURRENT_BINARY_DIR}/${png_tmp_filename}) + endif (NOT WL_TOOLS_PNGREWRITE STREQUAL "WL_TOOLS_PNGREWRITE-NOTFOUND") + + if (NOT WL_TOOLS_OPTIPNG STREQUAL "WL_TOOLS_OPTIPNG-NOTFOUND") +message ("${WL_TOOLS_OPTIPNG} -q -zc1-9 -zm1-9 -zs0-3 -f0-5 ${WL_CURRENT_BINARY_DIR}/${png_tmp_filename}") + execute_process (COMMAND ${WL_TOOLS_OPTIPNG} -q -zc1-9 -zm1-9 -zs0-3 -f0-5 ${WL_CURRENT_BINARY_DIR}/${png_tmp_filename}) + endif (NOT WL_TOOLS_OPTIPNG STREQUAL "WL_TOOLS_OPTIPNG-NOTFOUND") + endforeach (png_tmp ${PNG_LIST}) + else (WL_TOOLS_PNG_FOUND) + message(FATAL_ERROR "Neither pngrewrite nor optipng installed, failing") + endif (WL_TOOLS_PNG_FOUND) +endif (CMAKE_BUILD_TYPE STREQUAL Release) + Property changes on: branches/cmake-migration/pics/PicsFunctions.cmake ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-23 16:28:00
|
Revision: 5019 http://widelands.svn.sourceforge.net/widelands/?rev=5019&view=rev Author: sirver Date: 2010-01-23 16:27:54 +0000 (Sat, 23 Jan 2010) Log Message: ----------- Added Pieter Ouwerkerk (Pietertje) as Dutch translator Modified Paths: -------------- trunk/txts/developers Modified: trunk/txts/developers =================================================================== --- trunk/txts/developers 2010-01-22 20:50:03 UTC (rev 5018) +++ trunk/txts/developers 2010-01-23 16:27:54 UTC (rev 5019) @@ -167,6 +167,7 @@ "</p></rt>" "<rt image=pics/fsel_editor_set_height.png image-align=left text-align=left><p font-size=12>Rob Snelders (Ertai)</p></rt>" "<rt image=pics/fsel_editor_set_height.png image-align=left text-align=left><p font-size=12>Johan Jonkman (Dikjuh)</p></rt>" +"<rt image=pics/fsel_editor_set_height.png image-align=left text-align=left><p font-size=12>Pieter Ouwerkerk (Pietertje)</p></rt>" "<rt><p font-size=18 font-decoration=underline font-face=FreeSerif font-color=2F9131>" "" _ "Finnish" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-22 20:50:09
|
Revision: 5018 http://widelands.svn.sourceforge.net/widelands/?rev=5018&view=rev Author: sirver Date: 2010-01-22 20:50:03 +0000 (Fri, 22 Jan 2010) Log Message: ----------- merge fs-optimisation: Speed up '.' and '..' checks in FS_CanonicalizeName. Modified Paths: -------------- trunk/src/io/filesystem/filesystem.cc Modified: trunk/src/io/filesystem/filesystem.cc =================================================================== --- trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:49:29 UTC (rev 5017) +++ trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:50:03 UTC (rev 5018) @@ -251,19 +251,24 @@ //clean up the path for (i = components.begin(); i != components.end();) { - //remove single dot - if (*i == ".") + const char * str = (*i).c_str(); + if (*str == '.') { - i = components.erase(i); - continue; - } + ++str; - //remove double dot and the preceding component (if any) - if (*i == "..") { - if (i != components.begin()) - i = components.erase(--i); - i = components.erase(i); - continue; + //remove single dot + if (*str == '\0') + { + i = components.erase(i); + continue; + } + //remove double dot and the preceding component (if any) + else if (*str == '.' && *(str + 1) == '\0') { + if (i != components.begin()) + i = components.erase(--i); + i = components.erase(i); + continue; + } } ++i; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-22 20:49:35
|
Revision: 5017 http://widelands.svn.sourceforge.net/widelands/?rev=5017&view=rev Author: sirver Date: 2010-01-22 20:49:29 +0000 (Fri, 22 Jan 2010) Log Message: ----------- merge fs-optimisation: Avoid a string copy in FS_CanonicalizeName. The path argument passed to FS_CanonicalizeName is modified on the WIN32 code path. As such, and since the copied file path is also used in the POSIX code path, we can avoid a string copy by making the path argument a non-const value. Modified Paths: -------------- trunk/src/io/filesystem/filesystem.cc trunk/src/io/filesystem/filesystem.h Modified: trunk/src/io/filesystem/filesystem.cc =================================================================== --- trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:48:05 UTC (rev 5016) +++ trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:49:29 UTC (rev 5017) @@ -220,21 +220,19 @@ * * \todo Enable non-Unix paths */ -std::string FileSystem::FS_CanonicalizeName(std::string const & path) const { +std::string FileSystem::FS_CanonicalizeName(std::string path) const { std::list<std::string> components; std::list<std::string>::iterator i; - std::string fixedpath(path); - #ifdef WIN32 // remove all slashes with backslashes so following can work. for (uint32_t j = 0; j < path.size(); ++j) { - if (fixedpath[j] == '/') - fixedpath[j] = '\\'; + if (path[j] == '/') + path[j] = '\\'; } #endif - FS_Tokenize(fixedpath, m_filesep, + FS_Tokenize(path, m_filesep, std::inserter(components, components.begin())); //tilde expansion @@ -245,7 +243,7 @@ } //make relative paths absolute (so that "../../foo" can work) - else if (!pathIsAbsolute(fixedpath)) { + else if (!pathIsAbsolute(path)) { FS_Tokenize (m_root.empty() ? getWorkingDirectory() : m_root, m_filesep, std::inserter(components, components.begin())); Modified: trunk/src/io/filesystem/filesystem.h =================================================================== --- trunk/src/io/filesystem/filesystem.h 2010-01-22 20:48:05 UTC (rev 5016) +++ trunk/src/io/filesystem/filesystem.h 2010-01-22 20:49:29 UTC (rev 5017) @@ -110,7 +110,7 @@ // basic path/filename manipulation std::string fixCrossFile(std::string); std::string getWorkingDirectory() const; - std::string FS_CanonicalizeName(std::string const & path) const; + std::string FS_CanonicalizeName(std::string path) const; bool pathIsAbsolute(std::string const & path) const; static char const * FS_Filename(char const *); static char const * FS_Filename(char const *, char const * & extension); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-22 20:48:11
|
Revision: 5016 http://widelands.svn.sourceforge.net/widelands/?rev=5016&view=rev Author: sirver Date: 2010-01-22 20:48:05 +0000 (Fri, 22 Jan 2010) Log Message: ----------- merge fs-optimisation: Call pathIsAbsolute where it is used in FS_CanonicalizeName. Modified Paths: -------------- trunk/src/io/filesystem/filesystem.cc Modified: trunk/src/io/filesystem/filesystem.cc =================================================================== --- trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:47:27 UTC (rev 5015) +++ trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:48:05 UTC (rev 5016) @@ -234,7 +234,6 @@ } #endif - bool absolute = pathIsAbsolute(fixedpath); FS_Tokenize(fixedpath, m_filesep, std::inserter(components, components.begin())); @@ -246,7 +245,7 @@ } //make relative paths absolute (so that "../../foo" can work) - else if (!absolute) { + else if (!pathIsAbsolute(fixedpath)) { FS_Tokenize (m_root.empty() ? getWorkingDirectory() : m_root, m_filesep, std::inserter(components, components.begin())); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-22 20:47:38
|
Revision: 5015 http://widelands.svn.sourceforge.net/widelands/?rev=5015&view=rev Author: sirver Date: 2010-01-22 20:47:27 +0000 (Fri, 22 Jan 2010) Log Message: ----------- merge fs-optimisation: The file path will always end up absolute, so simplify the code. Modified Paths: -------------- trunk/src/io/filesystem/filesystem.cc Modified: trunk/src/io/filesystem/filesystem.cc =================================================================== --- trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:46:30 UTC (rev 5014) +++ trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:47:27 UTC (rev 5015) @@ -243,15 +243,13 @@ components.erase(components.begin()); FS_Tokenize(GetHomedir(), m_filesep, std::inserter(components, components.begin())); - absolute = true; } //make relative paths absolute (so that "../../foo" can work) - if (!absolute) { + else if (!absolute) { FS_Tokenize (m_root.empty() ? getWorkingDirectory() : m_root, m_filesep, std::inserter(components, components.begin())); - absolute = true; } //clean up the path @@ -277,17 +275,12 @@ std::string canonpath; canonpath.reserve(path.length()); #ifndef WIN32 - if (!absolute) - canonpath = "."; - for (i = components.begin(); i != components.end(); ++i) { canonpath.push_back('/'); canonpath += *i; } #else - canonpath = absolute ? "" : ".\\"; - for (i = components.begin(); i != components.end(); ++i) canonpath += *i + "\\"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-22 20:46:54
|
Revision: 5014 http://widelands.svn.sourceforge.net/widelands/?rev=5014&view=rev Author: sirver Date: 2010-01-22 20:46:30 +0000 (Fri, 22 Jan 2010) Log Message: ----------- merge fs-optimisation: Factor out the FS_CanonicalizeName logic common to POSIX and WIN32 The FS_CanonicalizeName algorithm has some logic to fix the path for the WIN32 codepath. This passes that path to pathIsAbsolute and FS_Tokenize, both of which are called in the POSIX code block. To simplify the code, only the fixup code is placed within the Modified Paths: -------------- trunk/src/io/filesystem/filesystem.cc Modified: trunk/src/io/filesystem/filesystem.cc =================================================================== --- trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:45:09 UTC (rev 5013) +++ trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:46:30 UTC (rev 5014) @@ -224,22 +224,19 @@ std::list<std::string> components; std::list<std::string>::iterator i; + std::string fixedpath(path); + #ifdef WIN32 // remove all slashes with backslashes so following can work. - std::string fixedpath(path); for (uint32_t j = 0; j < path.size(); ++j) { if (fixedpath[j] == '/') fixedpath[j] = '\\'; } +#endif bool absolute = pathIsAbsolute(fixedpath); FS_Tokenize(fixedpath, m_filesep, std::inserter(components, components.begin())); -#else - bool absolute = pathIsAbsolute(path); - FS_Tokenize(path, m_filesep, - std::inserter(components, components.begin())); -#endif //tilde expansion if (!components.empty() && *components.begin() == "~") { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-22 20:45:19
|
Revision: 5013 http://widelands.svn.sourceforge.net/widelands/?rev=5013&view=rev Author: sirver Date: 2010-01-22 20:45:09 +0000 (Fri, 22 Jan 2010) Log Message: ----------- merge fs-optimisation: Use a temporary string for the substr value when tokenising paths. Modified Paths: -------------- trunk/src/io/filesystem/filesystem.cc Modified: trunk/src/io/filesystem/filesystem.cc =================================================================== --- trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:44:17 UTC (rev 5012) +++ trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:45:09 UTC (rev 5013) @@ -201,14 +201,18 @@ //split path into it's components while (pos2 != std::string::npos) { if (pos != pos2) - *components++ = path.substr(pos, pos2 - pos); + { + std::string node = path.substr(pos, pos2 - pos); + *components++ = node; + } pos = pos2 + 1; pos2 = path.find(filesep, pos); } //extract the last component (most probably a filename) - if (pos < path.length()) - *components++ = path.substr(pos); + std::string node = path.substr(pos); + if (!node.empty()) + *components++ = node; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-22 20:44:28
|
Revision: 5012 http://widelands.svn.sourceforge.net/widelands/?rev=5012&view=rev Author: sirver Date: 2010-01-22 20:44:17 +0000 (Fri, 22 Jan 2010) Log Message: ----------- merge fs-optimisation: Simplify the path cleanup algorithm. Modified Paths: -------------- trunk/src/io/filesystem/filesystem.cc Modified: trunk/src/io/filesystem/filesystem.cc =================================================================== --- trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:43:48 UTC (rev 5011) +++ trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:44:17 UTC (rev 5012) @@ -255,28 +255,17 @@ //clean up the path for (i = components.begin(); i != components.end();) { - bool erase = false; - bool erase_prev = false; - //remove single dot if (*i == ".") - erase = true; + { + i = components.erase(i); + continue; + } //remove double dot and the preceding component (if any) if (*i == "..") { if (i != components.begin()) - erase_prev = true; - erase = true; - } - - if (erase_prev && erase) { - std::list<std::string>::iterator j = i; - --i; - ++j; - i = components.erase(i, j); - continue; - } - if (erase) { + i = components.erase(--i); i = components.erase(i); continue; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-22 20:43:54
|
Revision: 5011 http://widelands.svn.sourceforge.net/widelands/?rev=5011&view=rev Author: sirver Date: 2010-01-22 20:43:48 +0000 (Fri, 22 Jan 2010) Log Message: ----------- merge fs-optimisation: Don't add empty path nodes in FS_Tokenize. Modified Paths: -------------- trunk/src/io/filesystem/filesystem.cc Modified: trunk/src/io/filesystem/filesystem.cc =================================================================== --- trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:43:27 UTC (rev 5010) +++ trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:43:48 UTC (rev 5011) @@ -200,13 +200,15 @@ //split path into it's components while (pos2 != std::string::npos) { - *components++ = path.substr(pos, pos2 - pos); + if (pos != pos2) + *components++ = path.substr(pos, pos2 - pos); pos = pos2 + 1; pos2 = path.find(filesep, pos); } //extract the last component (most probably a filename) - *components++ = path.substr(pos); + if (pos < path.length()) + *components++ = path.substr(pos); } /** @@ -236,7 +238,7 @@ #endif //tilde expansion - if (*components.begin() == "~") { + if (!components.empty() && *components.begin() == "~") { components.erase(components.begin()); FS_Tokenize(GetHomedir(), m_filesep, std::inserter(components, components.begin())); @@ -256,10 +258,6 @@ bool erase = false; bool erase_prev = false; - //remove empty components ("foo/bar//baz/") - if (i->empty()) - erase = true; - //remove single dot if (*i == ".") erase = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-22 20:43:33
|
Revision: 5010 http://widelands.svn.sourceforge.net/widelands/?rev=5010&view=rev Author: sirver Date: 2010-01-22 20:43:27 +0000 (Fri, 22 Jan 2010) Log Message: ----------- merge fs-optimisation: Avoid unnecessary copying and checks when fixing paths on WIN32. There is no need to convert a character to a string just to check it against '/'. Also, the range-checked at(j) usage is not needed as the loop is iterating within the bounds of the string data. Modified Paths: -------------- trunk/src/io/filesystem/filesystem.cc Modified: trunk/src/io/filesystem/filesystem.cc =================================================================== --- trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:43:09 UTC (rev 5009) +++ trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:43:27 UTC (rev 5010) @@ -221,12 +221,9 @@ #ifdef WIN32 // remove all slashes with backslashes so following can work. std::string fixedpath(path); - std::string temp; - uint32_t path_size = path.size(); - for (uint32_t j = 0; j < path_size; ++j) { - temp = fixedpath.at(j); - if (temp == "/") - fixedpath.at(j) = '\\'; + for (uint32_t j = 0; j < path.size(); ++j) { + if (fixedpath[j] == '/') + fixedpath[j] = '\\'; } bool absolute = pathIsAbsolute(fixedpath); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-22 20:43:16
|
Revision: 5009 http://widelands.svn.sourceforge.net/widelands/?rev=5009&view=rev Author: sirver Date: 2010-01-22 20:43:09 +0000 (Fri, 22 Jan 2010) Log Message: ----------- merge fs-optimisation: On posix systems, don't generate a trailing '/'. When taking the list<string> and converting it to a path string, the previous algorithm (and what is still being done on the Windows version) built it up as 'path/' then erasing the last '/' character. Since a path will always start with either './' or '/', the algorithm can be changed to build the path up as '/path' instead, removing the need to erase the trailing '/' character. Modified Paths: -------------- trunk/src/io/filesystem/filesystem.cc Modified: trunk/src/io/filesystem/filesystem.cc =================================================================== --- trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:42:52 UTC (rev 5008) +++ trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:43:09 UTC (rev 5009) @@ -292,18 +292,22 @@ std::string canonpath; canonpath.reserve(path.length()); #ifndef WIN32 - canonpath = absolute ? "/" : "./"; + if (!absolute) + canonpath = "."; for (i = components.begin(); i != components.end(); ++i) - canonpath += *i + "/"; + { + canonpath.push_back('/'); + canonpath += *i; + } #else canonpath = absolute ? "" : ".\\"; for (i = components.begin(); i != components.end(); ++i) canonpath += *i + "\\"; -#endif canonpath.erase(canonpath.end() - 1); //remove trailing slash +#endif //debug info //printf("canonpath = %s\n", canonpath.c_str()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-22 20:42:58
|
Revision: 5008 http://widelands.svn.sourceforge.net/widelands/?rev=5008&view=rev Author: sirver Date: 2010-01-22 20:42:52 +0000 (Fri, 22 Jan 2010) Log Message: ----------- merge fs-optimisation: Add the results from FS_Tokenize directly into the node list. FS_Tokenize was returning a list of file path nodes that were being inserted into the start of the path nodes list being canonicalized. This is inefficient, as it produces copies of the nodes being tokenised. The algorithm has been changed to take an output iterator, and an inserter is being used to add the nodes directly into the components list. Modified Paths: -------------- trunk/src/io/filesystem/filesystem.cc Modified: trunk/src/io/filesystem/filesystem.cc =================================================================== --- trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:42:19 UTC (rev 5007) +++ trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:42:52 UTC (rev 5008) @@ -180,14 +180,13 @@ * Split a string into components separated by a certain character. * * \param path The path to parse - * \return a list of path components - * - * \todo This does not really belong into a filesystem class + * \param filesep The file path separator used by the native filesystem + * \param components The output iterator to place the path nodes into */ -static std::auto_ptr< std::list<std::string> > FS_Tokenize - (std::string const & path, char filesep) +template<typename Inserter> +static void FS_Tokenize + (std::string const & path, char filesep, Inserter components) { - std::auto_ptr< std::list<std::string> > components(new std::list<std::string>()); std::string::size_type pos; // start of token std::string::size_type pos2; // next filesep character @@ -201,15 +200,13 @@ //split path into it's components while (pos2 != std::string::npos) { - components->push_back(path.substr(pos, pos2 - pos)); + *components++ = path.substr(pos, pos2 - pos); pos = pos2 + 1; pos2 = path.find(filesep, pos); } //extract the last component (most probably a filename) - components->push_back(path.substr(pos)); - - return components; + *components++ = path.substr(pos); } /** @@ -218,7 +215,7 @@ * \todo Enable non-Unix paths */ std::string FileSystem::FS_CanonicalizeName(std::string const & path) const { - std::auto_ptr< std::list<std::string> > components; + std::list<std::string> components; std::list<std::string>::iterator i; #ifdef WIN32 @@ -233,42 +230,32 @@ } bool absolute = pathIsAbsolute(fixedpath); - components = FS_Tokenize(fixedpath, m_filesep); - + FS_Tokenize(fixedpath, m_filesep, + std::inserter(components, components.begin())); #else bool absolute = pathIsAbsolute(path); - components = FS_Tokenize(path, m_filesep); + FS_Tokenize(path, m_filesep, + std::inserter(components, components.begin())); #endif //tilde expansion - if (*components->begin() == "~") { - components->erase(components->begin()); - std::auto_ptr< std::list<std::string> > homecomponents; - homecomponents = FS_Tokenize(GetHomedir(), m_filesep); - components->insert - (components->begin(), homecomponents->begin(), homecomponents->end()); - + if (*components.begin() == "~") { + components.erase(components.begin()); + FS_Tokenize(GetHomedir(), m_filesep, + std::inserter(components, components.begin())); absolute = true; } - - - //make relative paths absolute (so that "../../foo" can work) if (!absolute) { - std::auto_ptr< std::list<std::string> > cwdcomponents; - - cwdcomponents = - FS_Tokenize - (m_root.empty() ? getWorkingDirectory() : m_root, m_filesep); - - components->insert - (components->begin(), cwdcomponents->begin(), cwdcomponents->end()); + FS_Tokenize + (m_root.empty() ? getWorkingDirectory() : m_root, m_filesep, + std::inserter(components, components.begin())); absolute = true; } //clean up the path - for (i = components->begin(); i != components->end();) { + for (i = components.begin(); i != components.end();) { bool erase = false; bool erase_prev = false; @@ -282,7 +269,7 @@ //remove double dot and the preceding component (if any) if (*i == "..") { - if (i != components->begin()) + if (i != components.begin()) erase_prev = true; erase = true; } @@ -291,11 +278,11 @@ std::list<std::string>::iterator j = i; --i; ++j; - i = components->erase(i, j); + i = components.erase(i, j); continue; } if (erase) { - i = components->erase(i); + i = components.erase(i); continue; } @@ -307,12 +294,12 @@ #ifndef WIN32 canonpath = absolute ? "/" : "./"; - for (i = components->begin(); i != components->end(); ++i) + for (i = components.begin(); i != components.end(); ++i) canonpath += *i + "/"; #else canonpath = absolute ? "" : ".\\"; - for (i = components->begin(); i != components->end(); ++i) + for (i = components.begin(); i != components.end(); ++i) canonpath += *i + "\\"; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-22 20:42:25
|
Revision: 5007 http://widelands.svn.sourceforge.net/widelands/?rev=5007&view=rev Author: sirver Date: 2010-01-22 20:42:19 +0000 (Fri, 22 Jan 2010) Log Message: ----------- merge fs-optimisation: The nexti variable is not used, so remove it. Modified Paths: -------------- trunk/src/io/filesystem/filesystem.cc Modified: trunk/src/io/filesystem/filesystem.cc =================================================================== --- trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:41:43 UTC (rev 5006) +++ trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:42:19 UTC (rev 5007) @@ -287,8 +287,6 @@ erase = true; } - std::list<std::string>::iterator nexti = i; - if (erase_prev && erase) { std::list<std::string>::iterator j = i; --i; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2010-01-22 20:41:54
|
Revision: 5006 http://widelands.svn.sourceforge.net/widelands/?rev=5006&view=rev Author: sirver Date: 2010-01-22 20:41:43 +0000 (Fri, 22 Jan 2010) Log Message: ----------- merge fs-optimisation: Don't reset to the start of a list when erasing path nodes. The FS_CanonicalizeName algorithm would restart from the beginning if it erased path nodes that were not needed, however the erase method returns a valid iterator. Use that iterator instead of begin(). Modified Paths: -------------- trunk/src/io/filesystem/filesystem.cc Modified: trunk/src/io/filesystem/filesystem.cc =================================================================== --- trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:40:58 UTC (rev 5005) +++ trunk/src/io/filesystem/filesystem.cc 2010-01-22 20:41:43 UTC (rev 5006) @@ -293,13 +293,11 @@ std::list<std::string>::iterator j = i; --i; ++j; - components->erase(i, j); - i = components->begin(); + i = components->erase(i, j); continue; } if (erase) { - components->erase(i); - i = components->begin(); + i = components->erase(i); continue; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |