Skip to content

Commit

Permalink
Merge branch 'AI_BFS_part_II' into 1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Oct 26, 2014
2 parents 164a02f + b0b42c4 commit 5935287
Show file tree
Hide file tree
Showing 13 changed files with 1,000 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -4,7 +4,7 @@ compiler:
- gcc
install:
- sudo apt-get update -qq
- sudo apt-get install -qq libboost-iostreams-dev libboost-program-options-dev libboost-regex-dev libboost-system-dev libboost-test-dev libcairo2-dev libfribidi-dev libpango1.0-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
- sudo apt-get install -qq libboost-filesystem-dev libboost-iostreams-dev libboost-program-options-dev libboost-regex-dev libboost-system-dev libboost-test-dev libcairo2-dev libfribidi-dev libpango1.0-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
script: scons cxxtool=$CXX strict=True wesnoth wesnothd campaignd test
after_script:
- "export DISPLAY=:99.0"
Expand Down
10 changes: 9 additions & 1 deletion SConstruct
Expand Up @@ -73,6 +73,7 @@ opts.AddVariables(
BoolVariable('lowmem', 'Set to reduce memory usage by removing extra functionality', False),
BoolVariable('notifications', 'Enable support for desktop notifications', True),
BoolVariable('nls','enable compile/install of gettext message catalogs',True),
BoolVariable('boostfilesystem', 'Use boost filesystem', True),
PathVariable('prefix', 'autotools-style installation prefix', "/usr/local", PathVariable.PathAccept),
PathVariable('prefsdir', 'user preferences directory', "", PathVariable.PathAccept),
PathVariable('default_prefs_file', 'default preferences file name', "", PathVariable.PathAccept),
Expand Down Expand Up @@ -273,6 +274,10 @@ configure_args = dict(custom_tests = init_metasconf(env, ["cplusplus", "python_d
log_file="$build_dir/config.log", conf_dir="$build_dir/sconf_temp")

env.MergeFlags(env["extra_flags_config"])

# Some tests need to load parts of boost
if env["boostfilesystem"]:
env.PrependENVPath('LD_LIBRARY_PATH', env["boostlibdir"])
if env["prereqs"]:
conf = env.Configure(**configure_args)

Expand Down Expand Up @@ -324,7 +329,10 @@ if env["prereqs"]:
conf.CheckBoostIostreamsBZip2() and \
conf.CheckBoost("smart_ptr", header_only = True) and \
conf.CheckSDL(require_version = '1.2.7') and \
conf.CheckSDL('SDL_net') or Warning("Base prerequisites are not met.")
conf.CheckSDL('SDL_net') & \
conf.CheckBoost("system") & \
((not env["boostfilesystem"]) or (conf.CheckBoost("filesystem", require_version = "1.44.0"))) \
or Warning("Base prerequisites are not met.")

env = conf.Finish()
client_env = env.Clone()
Expand Down
1 change: 1 addition & 0 deletions scons/boost.py
Expand Up @@ -59,6 +59,7 @@ def CheckBoost(context, boost_lib, require_version = None, header_only = False):
boost_headers = { "regex" : "regex/config.hpp",
"iostreams" : "iostreams/constants.hpp",
"unit_test_framework" : "test/unit_test.hpp",
"filesystem" : "filesystem/operations.hpp",
"system" : "system/error_code.hpp"}

header_name = boost_headers.get(boost_lib, boost_lib + ".hpp")
Expand Down
2 changes: 1 addition & 1 deletion src/SConscript
Expand Up @@ -62,8 +62,8 @@ if env['default_prefs_file']:

libwesnoth_core_sources.extend([
game_config_env.Object("game_config.cpp"),
filesystem_env.Object("filesystem.cpp"),
filesystem_env.Object("filesystem_common.cpp"),
filesystem_env.Object("filesystem_boost.cpp") if env["boostfilesystem"] else filesystem_env.Object("filesystem.cpp")
])

libwesnoth_core = [env.Library("wesnoth_core", libwesnoth_core_sources)]
Expand Down
15 changes: 12 additions & 3 deletions src/filesystem.cpp
Expand Up @@ -346,6 +346,15 @@ bool delete_directory(const std::string& path, const bool keep_pbl)
}
return ret;
}
bool delete_file(const std::string& path)
{
bool ret = true;
if(remove(path.c_str()) != 0 && errno != ENOENT) {
ERR_FS << "remove(" << path << "): " << strerror(errno) << "\n";
ret = false;
}
return ret;
}

std::string get_cwd()
{
Expand Down Expand Up @@ -593,7 +602,7 @@ static void setup_user_data_dir()
#endif
}

const std::string& get_user_data_dir()
std::string get_user_data_dir()
{
// ensure setup gets called only once per session
// FIXME: this is okay and optimized, but how should we react
Expand All @@ -605,7 +614,7 @@ const std::string& get_user_data_dir()
return user_data_dir;
}

const std::string &get_user_config_dir()
std::string get_user_config_dir()
{
if (user_config_dir.empty())
{
Expand All @@ -630,7 +639,7 @@ const std::string &get_user_config_dir()
return user_config_dir;
}

const std::string &get_cache_dir()
std::string get_cache_dir()
{
if (cache_dir.empty())
{
Expand Down
7 changes: 4 additions & 3 deletions src/filesystem.hpp
Expand Up @@ -81,15 +81,16 @@ std::string get_next_filename(const std::string& name, const std::string& extens
void set_user_config_dir(std::string path);
void set_user_data_dir(std::string path);

const std::string &get_user_config_dir();
const std::string &get_user_data_dir();
const std::string &get_cache_dir();
std::string get_user_config_dir();
std::string get_user_data_dir();
std::string get_cache_dir();

std::string get_cwd();
std::string get_exe_dir();

bool make_directory(const std::string& dirname);
bool delete_directory(const std::string& dirname, const bool keep_pbl = false);
bool delete_file(const std::string &filename);

bool looks_like_pbl(const std::string& file);

Expand Down

0 comments on commit 5935287

Please sign in to comment.