Skip to content

Commit

Permalink
Flatten share/ and user/ in the source and for the RUN_IN_PLACE build
Browse files Browse the repository at this point in the history
  • Loading branch information
celeron55 committed Mar 19, 2012
1 parent 19ed3bb commit 97b6930
Show file tree
Hide file tree
Showing 122 changed files with 57 additions and 43 deletions.
38 changes: 26 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
## Generic ignorable patterns and files
*~
map/*
world/*
.*.swp
*bak*
tags
*.vim

## Non-static Minetest directories
bin/
games/
!games/mesetint
cache/
textures/
sounds/
mods/
worlds/
world/

## Configuration/log files
minetest.conf
debug.txt

## Build files
CMakeFiles/*
src/CMakeFiles/*
src/Makefile
Expand All @@ -10,19 +30,13 @@ src/jthread/CMakeFiles/*
src/jthread/Makefile
src/jthread/cmake_config.h
src/jthread/cmake_install.cmake
.*.swp
minetest.conf
bin/
src/jthread/libjthread.a
src/lua/build/
src/lua/CMakeFiles/
CMakeCache.txt
CPackConfig.cmake
CPackSourceConfig.cmake
Makefile
cmake_install.cmake
src/jthread/libjthread.a
debug.txt
bin/debug.txt
minetestmapper/map.png
locale/
src/lua/build/
src/lua/CMakeFiles/
*bak*

24 changes: 16 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,29 @@ find_package(Irrlicht)
#

if(WIN32)
set(SHAREDIR "share")
set(SHAREDIR ".")
set(BINDIR "bin")
set(DOCDIR "doc")
set(EXAMPLE_CONF_DIR "user")
set(EXAMPLE_CONF_DIR ".")
set(LOCALEDIR "locale")
elseif(APPLE)
# random placeholders
# Random placeholders; this isn't usually used and may not work
# See https://github.com/toabi/minetest-mac/
set(SHAREDIR "share/${PROJECT_NAME}")
set(BINDIR "bin")
set(DOCDIR "share/doc/${PROJECT_NAME}")
set(EXAMPLE_CONF_DIR ${DOCDIR})
set(LOCALEDIR "locale")
elseif(UNIX) # Linux, BSD etc
if(RUN_IN_PLACE)
set(SHAREDIR "share")
set(SHAREDIR ".")
set(BINDIR "bin")
set(DOCDIR "doc")
set(MANDIR "share/unix/man")
set(EXAMPLE_CONF_DIR ${DOCDIR})
set(XDG_APPS_DIR "share/unix/applications")
set(ICONDIR "share/unix/icons")
set(EXAMPLE_CONF_DIR ".")
set(MANDIR "unix/man")
set(XDG_APPS_DIR "unix/applications")
set(ICONDIR "unix/icons")
set(LOCALEDIR "locale")
else()
set(SHAREDIR "share/${PROJECT_NAME}")
set(BINDIR "bin")
Expand All @@ -76,9 +80,13 @@ elseif(UNIX) # Linux, BSD etc
set(EXAMPLE_CONF_DIR ${DOCDIR})
set(XDG_APPS_DIR "share/applications")
set(ICONDIR "share/icons")
set(LOCALEDIR "share/locale")
endif()
endif()

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/builtin" DESTINATION "${SHAREDIR}/")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/games/mesetint" DESTINATION "${SHAREDIR}/games/")

install(FILES "README.txt" DESTINATION "${DOCDIR}")
install(FILES "minetest.conf.example" DESTINATION "${EXAMPLE_CONF_DIR}")

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cmake/Modules/FindGettextLib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ENDIF()
IF(GETTEXT_FOUND)
SET(GETTEXT_PO_PATH ${CMAKE_SOURCE_DIR}/po)
SET(GETTEXT_MO_BUILD_PATH ${CMAKE_BINARY_DIR}/locale/<locale>/LC_MESSAGES)
SET(GETTEXT_MO_DEST_PATH ${DATADIR}/../locale/<locale>/LC_MESSAGES)
SET(GETTEXT_MO_DEST_PATH ${LOCALEDIR}/<locale>/LC_MESSAGES)
FILE(GLOB GETTEXT_AVAILABLE_LOCALES RELATIVE ${GETTEXT_PO_PATH} "${GETTEXT_PO_PATH}/*")
LIST(REMOVE_ITEM GETTEXT_AVAILABLE_LOCALES minetest.pot)
MACRO(SET_MO_PATHS _buildvar _destvar _locale)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ endif()
if(BUILD_CLIENT)
install(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../share/" DESTINATION ${SHAREDIR})
#install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../sounds/base/pack" DESTINATION "${SHAREDIR}/sounds/base/")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../textures/base/pack" DESTINATION "${SHAREDIR}/textures/base/")

if(USE_GETTEXT)
foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})
Expand Down
5 changes: 0 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,12 +1034,7 @@ int main(int argc, char *argv[])
// Check if the world is found from the default directory, and if
// not, see if the legacy world directory exists.
world_path = porting::path_user + DIR_DELIM + "worlds" + DIR_DELIM + "world";
#ifdef RUN_IN_PLACE
std::string legacy_world_path = porting::path_user + DIR_DELIM +
".." + DIR_DELIM + "world";
#else
std::string legacy_world_path = porting::path_user + DIR_DELIM + "world";
#endif
if(!fs::PathExists(world_path) && fs::PathExists(legacy_world_path)){
errorstream<<"Warning: Using legacy world directory \""
<<legacy_world_path<<"\""<<std::endl;
Expand Down
23 changes: 12 additions & 11 deletions src/porting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ void signal_handler_init(void)
Path mangler
*/

std::string path_share = ".." DIR_DELIM "share";
std::string path_user = ".." DIR_DELIM "user";
// Default to RUN_IN_PLACE style relative paths
std::string path_share = "..";
std::string path_user = "..";

std::string getDataPath(const char *subpath)
{
Expand Down Expand Up @@ -167,8 +168,8 @@ void initializePaths()
assert(len < buflen);
pathRemoveFile(buf, '\\');

path_share = std::string(buf) + "\\..\\share";
path_user = std::string(buf) + "\\..\\user";
path_share = std::string(buf) + "\\..";
path_user = std::string(buf) + "\\..";

/*
Linux
Expand All @@ -183,8 +184,8 @@ void initializePaths()

pathRemoveFile(buf, '/');

path_share = std::string(buf) + "/../share";
path_user = std::string(buf) + "/../user";
path_share = std::string(buf) + "/..";
path_user = std::string(buf) + "/..";

/*
OS X
Expand All @@ -194,8 +195,8 @@ void initializePaths()
//TODO: Get path of executable. This assumes working directory is bin/
dstream<<"WARNING: Relative path not properly supported on OS X and FreeBSD"
<<std::endl;
path_share = std::string("../share");
path_user = std::string("../user");
path_share = std::string("..");
path_user = std::string("..");

#endif

Expand All @@ -222,8 +223,8 @@ void initializePaths()
assert(len < buflen);
pathRemoveFile(buf, '\\');

// Use ".\bin\..\share"
path_share = std::string(buf) + "\\..\\share";
// Use ".\bin\.."
path_share = std::string(buf) + "\\..";

// Use "C:\Documents and Settings\user\Application Data\<PROJECT_NAME>"
len = GetEnvironmentVariable("APPDATA", buf, buflen);
Expand All @@ -247,7 +248,7 @@ void initializePaths()
//path_share = std::string(INSTALL_PREFIX) + "/share/" + PROJECT_NAME;
if (!fs::PathExists(path_share)) {
dstream<<"WARNING: system-wide share not found at \""<<path_share<<"\"";
path_share = std::string(buf) + "/../share";
path_share = std::string(buf) + "/..";
dstream<<"WARNING: Using \""<<path_share<<"\" instead."<<std::endl;
}

Expand Down
5 changes: 0 additions & 5 deletions src/subgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,7 @@ std::vector<WorldSpec> getAvailableWorlds()
}
// Check old world location
do{
#ifdef RUN_IN_PLACE
std::string fullpath = porting::path_user + DIR_DELIM + ".."
+ DIR_DELIM + "world";
#else
std::string fullpath = porting::path_user + DIR_DELIM + "world";
#endif
if(!fs::PathExists(fullpath))
break;
std::string name = "Old World";
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes

0 comments on commit 97b6930

Please sign in to comment.