Swap priority of system path overrides for dev builds
Suggested by Campbell, thanks! Also moved the exception into own function and improved comments. Fixes T53008.
This commit is contained in:
parent
10a112093f
commit
3133d2d58c
Notes:
blender-bot
2023-02-14 06:30:02 +01:00
Referenced by issue #53008, Blender 2.8: workspace list from user configuration is empty
|
@ -289,6 +289,33 @@ static bool get_path_user(
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Special convenience exception for dev builds to allow overrides to the system path.
|
||||
* With this, need for running 'make install' can be avoided, e.g. by symlinking SOURCE_DIR/release
|
||||
* to EXECUTABLE_DIR/release, or by running Blender from source directory directly.
|
||||
*/
|
||||
static bool get_path_system_dev_build_exception(
|
||||
char *targetpath, size_t targetpath_len, const char *relfolder)
|
||||
{
|
||||
char cwd[FILE_MAX];
|
||||
|
||||
/* Try EXECUTABLE_DIR/release/folder_name. Allows symlinking release folder from source dir. */
|
||||
if (test_path(targetpath, targetpath_len, bprogdir, "release", relfolder)) {
|
||||
return true;
|
||||
}
|
||||
/* Try CWD/release/folder_name. Allows executing Blender from any directory
|
||||
* (usually source dir), even without a release dir in bprogdir. */
|
||||
if (BLI_current_working_dir(cwd, sizeof(cwd))) {
|
||||
if (test_path(targetpath, targetpath_len, cwd, "release", relfolder)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/* never use if not existing. */
|
||||
targetpath[0] = '\0';
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path of a folder within the Blender installation directory.
|
||||
*
|
||||
|
@ -305,7 +332,6 @@ static bool get_path_system(
|
|||
{
|
||||
char system_path[FILE_MAX];
|
||||
const char *system_base_path;
|
||||
char cwd[FILE_MAX];
|
||||
char relfolder[FILE_MAX];
|
||||
|
||||
if (folder_name) {
|
||||
|
@ -320,25 +346,9 @@ static bool get_path_system(
|
|||
relfolder[0] = '\0';
|
||||
}
|
||||
|
||||
/* first allow developer only overrides to the system path
|
||||
* these are only used when running blender from source */
|
||||
|
||||
/* try CWD/release/folder_name */
|
||||
if (BLI_current_working_dir(cwd, sizeof(cwd))) {
|
||||
if (test_path(targetpath, targetpath_len, cwd, "release", relfolder)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/* try EXECUTABLE_DIR/release/folder_name */
|
||||
if (test_path(targetpath, targetpath_len, bprogdir, "release", relfolder)) {
|
||||
if (get_path_system_dev_build_exception(targetpath, targetpath_len, relfolder)) {
|
||||
return true;
|
||||
}
|
||||
/* never use if not existing. */
|
||||
targetpath[0] = '\0';
|
||||
|
||||
/* end developer overrides */
|
||||
|
||||
|
||||
|
||||
system_path[0] = '\0';
|
||||
|
||||
|
|
Loading…
Reference in New Issue