mail[Wesnoth-commits] r28786 - in /trunk: ./ src/ src/tests/


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by paniemin on August 20, 2008 - 15:55:
Author: suokko
Date: Wed Aug 20 15:55:07 2008
New Revision: 28786

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28786&view=rev
Log:
Broken dummylocales runtime configuration implementation. installation fails

Modified:
    trunk/CMakeLists.txt
    trunk/Makefile.am
    trunk/SConstruct
    trunk/src/SConscript
    trunk/src/game.cpp
    trunk/src/game_config.cpp
    trunk/src/game_config.hpp
    trunk/src/language.cpp
    trunk/src/tests/main.cpp
    trunk/src/tests/test_config_cache.cpp

Modified: trunk/CMakeLists.txt
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/CMakeLists.txt?rev=28786&r1=28785&r2=28786&view=diff
==============================================================================
--- trunk/CMakeLists.txt (original)
+++ trunk/CMakeLists.txt Wed Aug 20 15:55:07 2008
@@ -173,35 +173,36 @@
 
 if(ENABLE_DUMMY_LOCALES)
   add_definitions(-DUSE_DUMMYLOCALES)
-  set(DUMMY_LOCALE_C_DIR ${CMAKE_SOURCE_DIR}/locales/C)
-
-  add_custom_command(OUTPUT ${DUMMY_LOCALE_C_DIR}
-                     COMMAND mkdir -p ${DUMMY_LOCALE_C_DIR} 
-                     && echo | localedef --force ${DUMMY_LOCALE_C_DIR} 2> 
/dev/null || true)
-
-  file(GLOB_RECURSE LANGS RELATIVE ${CMAKE_SOURCE_DIR}/data/languages 
data/languages/*.cfg)
-
-  set(DUMMY_LOCALES)
-  foreach(LANGFILE ${LANGS})
-    string(REGEX REPLACE "(.*)\\.cfg" "\\1" LANG ${LANGFILE})
-    if(NOT LANG STREQUAL "C")
-      set(DUMMY_LOCALE_DIR ${CMAKE_SOURCE_DIR}/locales/${LANG})
-      add_custom_command(OUTPUT ${DUMMY_LOCALE_DIR}
-                         COMMAND ln -s 
-                         ARGS ${DUMMY_LOCALE_C_DIR} ${DUMMY_LOCALE_DIR}
-                         DEPENDS ${DUMMY_LOCALE_C_DIR})
-
-      set(DUMMY_LOCALES ${DUMMY_LOCALES} ${DUMMY_LOCALE_DIR})
-    endif()
-
-  endforeach()
-  add_custom_target(dummy-locales ALL DEPENDS ${DUMMY_LOCALES})
-
-  # this is a workaround for a bug in 2.4-7
-  file(MAKE_DIRECTORY locales)
-  install(DIRECTORY locales DESTINATION ${DATADIR} )
-
-endif()
+endif()
+
+set(DUMMY_LOCALE_C_DIR ${CMAKE_SOURCE_DIR}/locales/C)
+
+add_custom_command(OUTPUT ${DUMMY_LOCALE_C_DIR}
+                   COMMAND mkdir -p ${DUMMY_LOCALE_C_DIR} 
+                   && echo | localedef --force ${DUMMY_LOCALE_C_DIR} 2> 
/dev/null || true)
+
+file(GLOB_RECURSE LANGS RELATIVE ${CMAKE_SOURCE_DIR}/data/languages 
data/languages/*.cfg)
+
+set(DUMMY_LOCALES)
+foreach(LANGFILE ${LANGS})
+  string(REGEX REPLACE "(.*)\\.cfg" "\\1" LANG ${LANGFILE})
+  if(NOT LANG STREQUAL "C")
+    set(DUMMY_LOCALE_DIR ${CMAKE_SOURCE_DIR}/locales/${LANG})
+    add_custom_command(OUTPUT ${DUMMY_LOCALE_DIR}
+                       COMMAND ln -s 
+                       ARGS ${DUMMY_LOCALE_C_DIR} ${DUMMY_LOCALE_DIR}
+                       DEPENDS ${DUMMY_LOCALE_C_DIR})
+
+    set(DUMMY_LOCALES ${DUMMY_LOCALES} ${DUMMY_LOCALE_DIR})
+  endif()
+
+endforeach()
+add_custom_target(dummy-locales ALL DEPENDS ${DUMMY_LOCALES})
+
+# this is a workaround for a bug in 2.4-7
+file(MAKE_DIRECTORY locales)
+install(DIRECTORY locales DESTINATION ${DATADIR} )
+
 
 #
 # shrink images for tinygui

Modified: trunk/Makefile.am
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/Makefile.am?rev=28786&r1=28785&r2=28786&view=diff
==============================================================================
--- trunk/Makefile.am (original)
+++ trunk/Makefile.am Wed Aug 20 15:55:07 2008
@@ -92,7 +92,7 @@
          echo $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(docdir)/$$f"; \
          $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(docdir)/$$f"; cd ..; \
        done
-if DUMMYLOCALES
+#if DUMMYLOCALES
        @echo "Create dummy locales beneath the Wesnoth data directory"
        $(mkdir_p) "$(DESTDIR)$(pkgdatadir)/locales"
        if test -d "$(DESTDIR)$(pkgdatadir)/locales/C" ; then rm -r 
"$(DESTDIR)$(pkgdatadir)/locales/C" ; fi
@@ -102,7 +102,7 @@
          if test -L "$$loclnk" ; then rm "$$loclnk" ; fi; \
          ln -s C "$$loclnk"; done; \
        true
-endif
+#endif
 if TINYGUI
        @echo "Shrink installed images by a factor of two."
        (cd $(top_srcdir) && find data/core/images data/campaigns images  \( 
$(findfilterflags) -a -name '*.png' -and -not -name 'bar-energy-tinygui.png' 
-print \) ) | while read p; do \

Modified: trunk/SConstruct
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/SConstruct?rev=28786&r1=28785&r2=28786&view=diff
==============================================================================
--- trunk/SConstruct (original)
+++ trunk/SConstruct Wed Aug 20 15:55:07 2008
@@ -293,10 +293,18 @@
 if env["PLATFORM"] == 'darwin':            # Mac OS X
     env.Append(FRAMEWORKS = "Carbon")            # Carbon GUI
 
-try:
-    env["svnrev"] = Popen(Split("svnversion -n ."), 
stdout=PIPE).communicate()[0]
-except:
-    env["svnrev"] = ""
+if os.path.exists('.git'):
+    import re
+    p = re.compile('Revision: ([0-9]+)');
+    try:
+        env["svnrev"] = p.search(Popen(Split("git-svn info"), 
stdout=PIPE).communicate()[0]).group(1)
+    except:
+        env["svnrev"] = ""
+else:
+    try:
+        env["svnrev"] = Popen(Split("svnversion -n ."), 
stdout=PIPE).communicate()[0]
+    except:
+        env["svnrev"] = ""
 
 Export(Split("env have_client_prereqs have_server_prereqs 
have_test_prereqs"))
 SConscript(dirs = Split("po doc packaging/windows"))
@@ -342,7 +350,7 @@
 # Dummy locales
 #
 
-if env["dummy_locales"]:
+if env["nls"]:
     env.Command(Dir("locales/C"), [], "-mkdir -p locales;echo | localedef 
--force \"$TARGET\" 2> /dev/null")
     language_cfg_re = re.compile(r"data/languages/(.*)\.cfg")
     language_cfgs = glob("data/languages/*.cfg")
@@ -373,7 +381,7 @@
 installable_subs = Split('data fonts icons images sounds')
 if env['nls']:
     installable_subs.append("translations")
-if env['dummy_locales']:
+if env['nls']:
     installable_subs.append("locales")
 fifodir = env['fifodir']
 mandir = env["mandir"]

Modified: trunk/src/SConscript
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/SConscript?rev=28786&r1=28785&r2=28786&view=diff
==============================================================================
--- trunk/src/SConscript (original)
+++ trunk/src/SConscript Wed Aug 20 15:55:07 2008
@@ -66,6 +66,7 @@
     hotkeys.cpp
     image.cpp
     key.cpp
+    language.cpp
     loadscreen.cpp
     map_create.cpp
     map_label.cpp
@@ -104,7 +105,6 @@
     """)
 libwesnoth_sources.extend([
     env.Object("font.cpp", EXTRA_DEFINE = env['fribidi'] and "HAVE_FRIBIDI" 
or None),
-    env.Object("language.cpp", EXTRA_DEFINE = env['dummy_locales'] and 
"USE_DUMMYLOCALES" or None)
     ])
 
 libwesnoth = env.Library("wesnoth", libwesnoth_sources)
@@ -370,6 +370,8 @@
                     "Generating revision.hpp..."
                     ))
     game_config_env.Append(CPPDEFINES = 'HAVE_REVISION')
+if env['dummy_locales']:
+    game_config_env.Append(CPPDEFINES = 'USE_DUMMYLOCALES')
 
 sources = []
 if "TAGS" in COMMAND_LINE_TARGETS:

Modified: trunk/src/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=28786&r1=28785&r2=28786&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Wed Aug 20 15:55:07 2008
@@ -363,6 +363,8 @@
                } else if(val == "-e" || val == "--editor") {
                        jump_to_editor_ = true;
 #endif
+               } else if(val == "--dummylocales") {
+                       game_config::use_dummylocales = true;
                } else if(val[0] == '-') {
                        std::cerr << "unknown option: " << val << std::endl;
                        throw config::error("unknown option");
@@ -1957,6 +1959,7 @@
                        << "                               by id.\n"
                        << "  --turns=value                sets the number of 
turns. The default is \"50\".\n"
                        << "  --exit-at-end                exit Wesnoth at 
end of scenario.\n"
+                       << "  --dummylocales               Enable 
dummylocales for switching to non-system locale.\n"
                        << "  --new-widgets                there is a new WIP 
widget toolkit this switch enables the new toolkit\n"
                        << "                               (VERY EXPERIMENTAL 
don't file bug reports since most are known).\n"
                        ;

Modified: trunk/src/game_config.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_config.cpp?rev=28786&r1=28785&r2=28786&view=diff
==============================================================================
--- trunk/src/game_config.cpp (original)
+++ trunk/src/game_config.cpp Wed Aug 20 15:55:07 2008
@@ -52,6 +52,12 @@
 #endif
        std::string wesnothd_name;
        bool debug = false, editor = false, ignore_replay_errors = false, 
mp_debug = false, exit_at_end = false, no_delay = false, small_gui = false, 
disable_autosave = false;
+
+#ifdef USE_DUMMYLOCALES
+       bool use_dummylocales = true;
+#else
+       bool use_dummylocales = false;
+#endif
 
        std::string game_icon = "wesnoth-icon.png", game_title, game_logo, 
title_music, lobby_music;
        int title_logo_x = 0, title_logo_y = 0, title_buttons_x = 0, 
title_buttons_y = 0, title_buttons_padding = 0,

Modified: trunk/src/game_config.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_config.hpp?rev=28786&r1=28785&r2=28786&view=diff
==============================================================================
--- trunk/src/game_config.hpp (original)
+++ trunk/src/game_config.hpp Wed Aug 20 15:55:07 2008
@@ -47,6 +47,8 @@
        extern const bool gold_carryover_add;
 
        extern bool debug, editor, ignore_replay_errors, mp_debug, 
exit_at_end, no_delay, small_gui, disable_autosave;
+
+       extern bool use_dummylocales;
 
        extern std::string path;
 

Modified: trunk/src/language.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/language.cpp?rev=28786&r1=28785&r2=28786&view=diff
==============================================================================
--- trunk/src/language.cpp (original)
+++ trunk/src/language.cpp Wed Aug 20 15:55:07 2008
@@ -104,21 +104,22 @@
 
 bool language_def::available() const
 {
-#ifdef USE_DUMMYLOCALES
-       // Dummy has every language available.
-       return true;
-#else
-       if(has_language(localename)) {
+       if (game_config::use_dummylocales)
+       {
+               // Dummy has every language available.
                return true;
-       } else {
-               foreach(const std::string& lang, alternates) {
-                       if(has_language(lang)) {
-                               return true;
+       }else{
+               if(has_language(localename)) {
+                       return true;
+               } else {
+                       foreach(const std::string& lang, alternates) {
+                               if(has_language(lang)) {
+                                       return true;
+                               }
                        }
                }
-       }
-       return false;
-#endif
+               return false;
+       }
 }
 
 symbol_table string_table;
@@ -218,28 +219,29 @@
            category = LC_ALL;
 #endif
 
-#ifdef USE_DUMMYLOCALES
-       static enum { UNINIT, NONE, PRESENT } status = UNINIT;
-       static std::string locpath;
-       if (status == UNINIT) {
-               if (char const *p = getenv("LOCPATH")) {
-                       locpath = p;
-                       status = PRESENT;
-               } else status = NONE;
-       }
-       if (slocale.empty())
-               if (status == NONE)
-                       unsetenv("LOCPATH");
-               else
-                       setenv("LOCPATH", locpath.c_str(), 1);
-       else setenv("LOCPATH", (game_config::path + "/locales").c_str(), 1);
-       std::string xlocale;
-       if (!slocale.empty()) {
-               // dummy suffix to prevent locale aliasing from kicking in
-               xlocale = slocale + "@wesnoth";
-               locale = xlocale.c_str();
-       }
-#endif
+       if (game_config::use_dummylocales)
+       {
+               static enum { UNINIT, NONE, PRESENT } status = UNINIT;
+               static std::string locpath;
+               if (status == UNINIT) {
+                       if (char const *p = getenv("LOCPATH")) {
+                               locpath = p;
+                               status = PRESENT;
+                       } else status = NONE;
+               }
+               if (slocale.empty())
+                       if (status == NONE)
+                               unsetenv("LOCPATH");
+                       else
+                               setenv("LOCPATH", locpath.c_str(), 1);
+               else setenv("LOCPATH", (game_config::path + 
"/locales").c_str(), 1);
+               std::string xlocale;
+               if (!slocale.empty()) {
+                       // dummy suffix to prevent locale aliasing from 
kicking in
+                       xlocale = slocale + "@wesnoth";
+                       locale = xlocale.c_str();
+               }
+       }
 
        char *res = NULL;
        #ifdef _WIN32

Modified: trunk/src/tests/main.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/main.cpp?rev=28786&r1=28785&r2=28786&view=diff
==============================================================================
--- trunk/src/tests/main.cpp (original)
+++ trunk/src/tests/main.cpp Wed Aug 20 15:55:07 2008
@@ -19,10 +19,12 @@
 
 #include "SDL.h"
 
+#include "game_config.hpp"
 #include "game_errors.hpp"
 #include "network.hpp"
 #include "config.hpp"
 #include "log.hpp"
+#include "language.hpp"
 
 #include "tests/utils/fake_display.hpp"
 /**
@@ -47,12 +49,13 @@
 struct wesnoth_global_fixture {
        wesnoth_global_fixture() 
        {
+               game_config::use_dummylocales = true;
 
                // Initialize unit tests
                SDL_Init(SDL_INIT_TIMER);
                test_utils::get_fake_display();
 
-//             lg::set_log_domain_severity("all",3);
+               lg::set_log_domain_severity("all",3);
 
                // Set more report as default
                if (boost::unit_test::runtime_config::log_level() == 
boost::unit_test::invalid_log_level)
@@ -63,6 +66,7 @@
                
boost::unit_test::unit_test_monitor.register_exception_translator<game::error>(&exception_translator_game);
                
boost::unit_test::unit_test_monitor.register_exception_translator<network::error>(&exception_translator_network);
                
boost::unit_test::unit_test_monitor.register_exception_translator<config::error>(&exception_translator_config);
+               load_language_list();
        }
        ~wesnoth_global_fixture() 
        {

Modified: trunk/src/tests/test_config_cache.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/test_config_cache.cpp?rev=28786&r1=28785&r2=28786&view=diff
==============================================================================
--- trunk/src/tests/test_config_cache.cpp (original)
+++ trunk/src/tests/test_config_cache.cpp Wed Aug 20 15:55:07 2008
@@ -146,7 +146,7 @@
        std::vector<language_def>::const_iterator German = 
std::find_if(languages.begin(),
                                                                        
languages.end(),
                                                                        
match_german); // Using German because the most active translation
-       BOOST_REQUIRE_MESSAGE(German != languages.end(), "German translation 
not found");
+       BOOST_REQUIRE_MESSAGE(German != languages.end() && 
German->available(), "German translation not found");
        ::set_language(*German);
        cache.reload_translations();
 




Related Messages


Powered by MHonArc, Updated Wed Aug 20 16:01:37 2008