diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2017-11-19 14:24:12 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2017-11-19 15:13:37 +0300 |
commit | 3133d2d58c391544a48342860120336e2a0f944e (patch) | |
tree | 675caccc4008fec4f8a8dc489995761193fa75fd | |
parent | 10a112093fe8dd3553a67c3d671ca66c259f308b (diff) |
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.
-rw-r--r-- | source/blender/blenkernel/intern/appdir.c | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c index 6dd852c7875..8d4776dca0e 100644 --- a/source/blender/blenkernel/intern/appdir.c +++ b/source/blender/blenkernel/intern/appdir.c @@ -290,6 +290,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. * * \param targetpath String to return path @@ -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'; |