forked from bartvdbraak/blender
from Cosme
This commit is contained in:
parent
b07d92408b
commit
4293f4738c
@ -157,6 +157,8 @@ endif()
|
|||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)" ON)
|
option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)" ON)
|
||||||
option(WITH_BUILTIN_GLEW "Use GLEW OpenGL wrapper library bundled with blender" ON)
|
option(WITH_BUILTIN_GLEW "Use GLEW OpenGL wrapper library bundled with blender" ON)
|
||||||
|
option(WITH_XDG_USER_DIRS "Build with XDG Base Directory Specification (only config and documents for now)" OFF)
|
||||||
|
mark_as_advanced(WITH_XDG_USER_DIRS)
|
||||||
else()
|
else()
|
||||||
# not an option for other OS's
|
# not an option for other OS's
|
||||||
set(WITH_BUILTIN_GLEW ON)
|
set(WITH_BUILTIN_GLEW ON)
|
||||||
|
@ -108,6 +108,10 @@ if(WITH_INPUT_NDOF)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(WITH_XDG_USER_DIRS)
|
||||||
|
add_definitions(-DWITH_XDG_USER_DIRS)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(WITH_HEADLESS OR WITH_GHOST_SDL)
|
if(WITH_HEADLESS OR WITH_GHOST_SDL)
|
||||||
if(WITH_HEADLESS)
|
if(WITH_HEADLESS)
|
||||||
list(APPEND SRC
|
list(APPEND SRC
|
||||||
|
@ -41,6 +41,11 @@
|
|||||||
#include <stdio.h> // for fprintf only
|
#include <stdio.h> // for fprintf only
|
||||||
#include <cstdlib> // for exit
|
#include <cstdlib> // for exit
|
||||||
|
|
||||||
|
#ifdef WITH_XDG_USER_DIRS
|
||||||
|
# include <pwd.h> // for get home without use getenv()
|
||||||
|
# include <limits.h> // for PATH_MAX
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PREFIX
|
#ifdef PREFIX
|
||||||
static const char *static_path= PREFIX "/share" ;
|
static const char *static_path= PREFIX "/share" ;
|
||||||
#else
|
#else
|
||||||
@ -63,7 +68,27 @@ const GHOST_TUns8* GHOST_SystemPathsX11::getSystemDir() const
|
|||||||
|
|
||||||
const GHOST_TUns8* GHOST_SystemPathsX11::getUserDir() const
|
const GHOST_TUns8* GHOST_SystemPathsX11::getUserDir() const
|
||||||
{
|
{
|
||||||
|
#ifndef WITH_XDG_USER_DIRS
|
||||||
return (const GHOST_TUns8 *)getenv("HOME");
|
return (const GHOST_TUns8 *)getenv("HOME");
|
||||||
|
#else /* WITH_XDG_USER_DIRS */
|
||||||
|
const char *home= getenv("XDG_CONFIG_HOME");
|
||||||
|
|
||||||
|
if (home) {
|
||||||
|
return (const GHOST_TUns8 *)home;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
static char user_path[PATH_MAX];
|
||||||
|
|
||||||
|
home= getenv("HOME");
|
||||||
|
|
||||||
|
if (home == NULL) {
|
||||||
|
home= getpwuid(getuid())->pw_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(user_path, sizeof(user_path), "%s/.config", home);
|
||||||
|
return (const GHOST_TUns8 *)user_path;
|
||||||
|
}
|
||||||
|
#endif /* WITH_XDG_USER_DIRS */
|
||||||
}
|
}
|
||||||
|
|
||||||
const GHOST_TUns8* GHOST_SystemPathsX11::getBinaryDir() const
|
const GHOST_TUns8* GHOST_SystemPathsX11::getBinaryDir() const
|
||||||
|
@ -148,4 +148,8 @@ if(WITH_OPENMP)
|
|||||||
add_definitions(-DPARALLEL=1)
|
add_definitions(-DPARALLEL=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(WITH_XDG_USER_DIRS)
|
||||||
|
add_definitions(-DWITH_XDG_USER_DIRS)
|
||||||
|
endif()
|
||||||
|
|
||||||
blender_add_lib(bf_blenlib "${SRC}" "${INC}" "${INC_SYS}")
|
blender_add_lib(bf_blenlib "${SRC}" "${INC}" "${INC_SYS}")
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
#include "GHOST_Path-api.h"
|
#include "GHOST_Path-api.h"
|
||||||
|
|
||||||
#if defined WIN32 && !defined _LIBC
|
#if defined WIN32 && !defined _LIBC
|
||||||
# include "BLI_fnmatch.h" /* use fnmatch included in blenlib */
|
# include "BLI_fnmatch.h" /* use fnmatch included in blenlib */
|
||||||
#else
|
#else
|
||||||
# ifndef _GNU_SOURCE
|
# ifndef _GNU_SOURCE
|
||||||
# define _GNU_SOURCE
|
# define _GNU_SOURCE
|
||||||
@ -61,35 +61,34 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <io.h>
|
# include <io.h>
|
||||||
|
# ifdef _WIN32_IE
|
||||||
#ifdef _WIN32_IE
|
# undef _WIN32_IE
|
||||||
#undef _WIN32_IE
|
# endif
|
||||||
#endif
|
# define _WIN32_IE 0x0501
|
||||||
#define _WIN32_IE 0x0501
|
# include <windows.h>
|
||||||
#include <windows.h>
|
# include <shlobj.h>
|
||||||
#include <shlobj.h>
|
# include "BLI_winstuff.h"
|
||||||
|
|
||||||
#include "BLI_winstuff.h"
|
|
||||||
|
|
||||||
#else /* non windows */
|
#else /* non windows */
|
||||||
|
# ifdef WITH_BINRELOC
|
||||||
#ifdef WITH_BINRELOC
|
# include "binreloc.h"
|
||||||
#include "binreloc.h"
|
# endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
|
|
||||||
/* standard paths */
|
/* standard paths */
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define BLENDER_USER_FORMAT "%s\\Blender Foundation\\Blender\\%s"
|
# define BLENDER_USER_FORMAT "%s\\Blender Foundation\\Blender\\%s"
|
||||||
#define BLENDER_SYSTEM_FORMAT "%s\\Blender Foundation\\Blender\\%s"
|
# define BLENDER_SYSTEM_FORMAT "%s\\Blender Foundation\\Blender\\%s"
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#define BLENDER_USER_FORMAT "%s/Blender/%s"
|
# define BLENDER_USER_FORMAT "%s/Blender/%s"
|
||||||
#define BLENDER_SYSTEM_FORMAT "%s/Blender/%s"
|
# define BLENDER_SYSTEM_FORMAT "%s/Blender/%s"
|
||||||
#else
|
#else /* UNIX */
|
||||||
#define BLENDER_USER_FORMAT "%s/.blender/%s"
|
# ifndef WITH_XDG_USER_DIRS /* oldschool unix ~/.blender/ */
|
||||||
#define BLENDER_SYSTEM_FORMAT "%s/blender/%s"
|
# define BLENDER_USER_FORMAT "%s/.blender/%s"
|
||||||
|
# else /* new XDG ~/blender/.config/ */
|
||||||
|
# define BLENDER_USER_FORMAT "%s/blender/%s"
|
||||||
|
# endif // WITH_XDG_USER_DIRS
|
||||||
|
# define BLENDER_SYSTEM_FORMAT "%s/blender/%s"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* local */
|
/* local */
|
||||||
@ -797,10 +796,18 @@ void BLI_getlastdir(const char* dir, char *last, const size_t maxlen)
|
|||||||
as default location to save documents */
|
as default location to save documents */
|
||||||
const char *BLI_getDefaultDocumentFolder(void)
|
const char *BLI_getDefaultDocumentFolder(void)
|
||||||
{
|
{
|
||||||
#if !defined(WIN32)
|
#ifndef WIN32
|
||||||
|
|
||||||
|
#ifdef WITH_XDG_USER_DIRS
|
||||||
|
const char *xdg_documents_dir= getenv("XDG_DOCUMENTS_DIR");
|
||||||
|
if (xdg_documents_dir) {
|
||||||
|
return xdg_documents_dir;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return getenv("HOME");
|
return getenv("HOME");
|
||||||
|
|
||||||
#else /* Windows */
|
#else /* Windows */
|
||||||
const char * ret;
|
const char * ret;
|
||||||
static char documentfolder[MAXPATHLEN];
|
static char documentfolder[MAXPATHLEN];
|
||||||
HRESULT hResult;
|
HRESULT hResult;
|
||||||
@ -825,7 +832,7 @@ const char *BLI_getDefaultDocumentFolder(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif /* WIN32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NEW stuff, to be cleaned up when fully migrated */
|
/* NEW stuff, to be cleaned up when fully migrated */
|
||||||
|
Loading…
Reference in New Issue
Block a user